delayed-rm 2.9.0__tar.gz → 2.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: delayed_rm
3
- Version: 2.9.0
3
+ Version: 2.9.2
4
4
  Summary: Ever wish you had a few minutes to undo an rm? Now you do!
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/delayed_rm
@@ -3,16 +3,16 @@ from collections import defaultdict
3
3
  from tempfile import gettempdir
4
4
  from datetime import datetime
5
5
  from pathlib import Path
6
+ from os import environ
6
7
  import subprocess
7
8
  import argparse
8
9
  import tempfile
9
10
  import shutil
10
11
  import time
11
12
  import sys
12
- import os
13
13
 
14
14
 
15
- __version__ = "2.9.0"
15
+ __version__ = "2.9.2"
16
16
 
17
17
 
18
18
  #
@@ -83,9 +83,8 @@ def _prep(paths: list[Path], rf: bool) -> list[Path]:
83
83
  # Normalize paths and error checking
84
84
  try:
85
85
  paths = [i.parent.resolve(strict=True) / i.name for i in paths]
86
- # pathlib.stat does not support follow_symlinks until 3.10
87
- if len(paths) != len({os.stat(i, follow_symlinks=False).st_ino for i in paths}):
88
- raise RMError("duplicate items passed")
86
+ if len(paths) != len({i.stat(follow_symlinks=False).st_ino for i in paths}):
87
+ raise RMError("duplicate or hardlinked items passed")
89
88
  except (FileNotFoundError, RuntimeError) as e:
90
89
  raise RMError(e) from e
91
90
  for i in paths:
@@ -214,12 +213,7 @@ def delayed_rm_raw(delay: int, log: bool, r: bool, f: bool, paths: list[Path]) -
214
213
  if r or f or paths:
215
214
  _eprint("--log may not be used with other arguments")
216
215
  return False
217
- if log_f.exists():
218
- with log_f.open("r") as file:
219
- data: str = file.read()
220
- print(data + f"Log file: {log_f}")
221
- else:
222
- print("Log is empty")
216
+ print(f"{log_f.read_text()}Log file: {log_f}" if log_f.exists() else "Log is empty")
223
217
  return True
224
218
  if not paths:
225
219
  _eprint("nothing to remove")
@@ -236,7 +230,7 @@ def delayed_rm_raw(delay: int, log: bool, r: bool, f: bool, paths: list[Path]) -
236
230
 
237
231
 
238
232
  def main(prog: str, *args: str) -> bool:
239
- base: str = os.path.basename(prog)
233
+ base: str = Path(prog).name
240
234
  parser = argparse.ArgumentParser(prog=base)
241
235
  parser.add_argument("--version", action="version", version=f"{base} {__version__}")
242
236
  parser.add_argument("--delay", "--ttl", type=int, default=900, help="The deletion delay in seconds")
@@ -264,12 +258,12 @@ def cli() -> None:
264
258
  def _secret_cli():
265
259
  """
266
260
  This CLI is invoked on import and not will do nothing by default
267
- This CLI will only active if argv was intentionally configured to do so
261
+ This CLI will only activate if argv was intentionally configured to do so
268
262
  This entrypoint is for the spawned process to act
269
263
  """
270
264
  try:
271
265
  if len(sys.argv) == 4 and sys.argv[1] == _Secret.value:
272
- if os.environ.get(_Secret.key, None) == _Secret.value:
266
+ if environ.get(_Secret.key, None) == _Secret.value:
273
267
  delay = int(sys.argv[2])
274
268
  d = Path(sys.argv[3]).resolve()
275
269
  time.sleep(delay)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: delayed_rm
3
- Version: 2.9.0
3
+ Version: 2.9.2
4
4
  Summary: Ever wish you had a few minutes to undo an rm? Now you do!
5
5
  License: GPLv3
6
6
  Project-URL: Homepage, https://github.com/zwimer/delayed_rm
File without changes
File without changes
File without changes
File without changes