delayed-rm 2.6.0__tar.gz → 2.8.0__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.
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/PKG-INFO +3 -4
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm/delayed_rm.py +45 -35
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm.egg-info/PKG-INFO +4 -5
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm.egg-info/SOURCES.txt +0 -1
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/pyproject.toml +3 -3
- delayed_rm-2.8.0/setup.cfg +4 -0
- delayed_rm-2.6.0/setup.cfg +0 -28
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/LICENSE +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/README.md +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm/__init__.py +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm/py.typed +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm.egg-info/dependency_links.txt +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm.egg-info/entry_points.txt +0 -0
- {delayed_rm-2.6.0 → delayed_rm-2.8.0}/delayed_rm.egg-info/top_level.txt +0 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: delayed_rm
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: Ever wish you had a few minutes to undo an rm? Now you do!
|
|
5
|
-
Home-page: https://github.com/zwimer/delayed_rm
|
|
6
5
|
License: GPL
|
|
7
6
|
Project-URL: Homepage, https://github.com/zwimer/delayed_rm
|
|
8
7
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.
|
|
10
|
-
Requires-Python: >=3.
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Requires-Python: >=3.10
|
|
11
10
|
Description-Content-Type: text/markdown
|
|
12
11
|
License-File: LICENSE
|
|
13
12
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Callable
|
|
2
2
|
from collections import defaultdict
|
|
3
3
|
from tempfile import gettempdir
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from typing import Callable
|
|
6
5
|
from pathlib import Path
|
|
7
6
|
import subprocess
|
|
8
7
|
import argparse
|
|
@@ -13,7 +12,7 @@ import sys
|
|
|
13
12
|
import os
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
__version__ = "2.
|
|
15
|
+
__version__ = "2.8.0"
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
#
|
|
@@ -128,36 +127,43 @@ def delayed_rm(paths: list[Path], delay: int, rf: bool) -> bool:
|
|
|
128
127
|
where: dict[str, set[Path]] = defaultdict(set)
|
|
129
128
|
full_where: dict[Path, Path] = {}
|
|
130
129
|
# Delete files
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
ctrlc = False
|
|
131
|
+
edited = False
|
|
132
|
+
try:
|
|
133
|
+
for p in paths:
|
|
134
|
+
# Select an output directory that an item of name p.name does not exist
|
|
135
|
+
outd: Path
|
|
136
|
+
if len(out_dirs) != len(where[p.name]):
|
|
137
|
+
outd = next(iter(out_dirs - where[p.name]))
|
|
138
|
+
else:
|
|
139
|
+
outd = _mkdir(base / str(len(out_dirs)))
|
|
140
|
+
out_dirs.add(outd)
|
|
141
|
+
# Move file into the temp directory
|
|
142
142
|
try:
|
|
143
|
-
p.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
shutil.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
143
|
+
new: Path = outd / p.name
|
|
144
|
+
try:
|
|
145
|
+
p.rename(new)
|
|
146
|
+
except OSError:
|
|
147
|
+
copyf = lambda src, dst: shutil.copy2(src, dst, follow_symlinks=False)
|
|
148
|
+
if p.is_dir():
|
|
149
|
+
shutil.copytree(p, new, copy_function=copyf, symlinks=False)
|
|
150
|
+
edited = True
|
|
151
|
+
shutil.rmtree(p)
|
|
152
|
+
else:
|
|
153
|
+
copyf(p, new)
|
|
154
|
+
edited = True
|
|
155
|
+
p.unlink()
|
|
156
|
+
success.append(p)
|
|
157
|
+
full_where[p] = new
|
|
158
|
+
where[p.name].add(outd)
|
|
159
|
+
except OSError as e:
|
|
160
|
+
failed.append(p)
|
|
161
|
+
_eprint(e)
|
|
162
|
+
except KeyboardInterrupt:
|
|
163
|
+
ctrlc = True
|
|
158
164
|
# Inform user of failures
|
|
159
165
|
failed_plus: list[str] = [str(i) for i in failed]
|
|
160
|
-
if len(failed) > 0:
|
|
166
|
+
if len(failed) > 0 and not ctrlc:
|
|
161
167
|
_eprint("failed to rm:\n " + "\n ".join(failed_plus))
|
|
162
168
|
# Log result
|
|
163
169
|
success_plus: list[str] = [f"{i} ---> {full_where[i]}" for i in success]
|
|
@@ -167,7 +173,7 @@ def delayed_rm(paths: list[Path], delay: int, rf: bool) -> bool:
|
|
|
167
173
|
+ "\n "
|
|
168
174
|
+ "\n".join(
|
|
169
175
|
(
|
|
170
|
-
f"Delay: {delay}",
|
|
176
|
+
("Interrupted by: SIGINT\n" if ctrlc else "") + f"Delay: {delay}",
|
|
171
177
|
f"rf: {rf}",
|
|
172
178
|
f"Storage Directory: {base}",
|
|
173
179
|
f"Succeeded:{fmt(success_plus)}",
|
|
@@ -176,10 +182,14 @@ def delayed_rm(paths: list[Path], delay: int, rf: bool) -> bool:
|
|
|
176
182
|
).replace("\n", "\n ")
|
|
177
183
|
+ "\n\n"
|
|
178
184
|
)
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
try:
|
|
186
|
+
with log_f.open("a") as f:
|
|
187
|
+
f.write(msg)
|
|
188
|
+
except OSError:
|
|
189
|
+
print(msg)
|
|
190
|
+
raise
|
|
181
191
|
# Delay rm and die
|
|
182
|
-
if not
|
|
192
|
+
if not edited:
|
|
183
193
|
shutil.rmtree(base)
|
|
184
194
|
else:
|
|
185
195
|
subprocess.Popen( # pylint: disable=consider-using-with
|
|
@@ -188,7 +198,7 @@ def delayed_rm(paths: list[Path], delay: int, rf: bool) -> bool:
|
|
|
188
198
|
stdout=subprocess.DEVNULL,
|
|
189
199
|
stderr=subprocess.DEVNULL,
|
|
190
200
|
)
|
|
191
|
-
return not failed
|
|
201
|
+
return not failed and not ctrlc
|
|
192
202
|
|
|
193
203
|
|
|
194
204
|
def delayed_rm_raw(delay: int, log: bool, r: bool, f: bool, paths: list[Path]) -> bool:
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 2.
|
|
2
|
+
Name: delayed_rm
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: Ever wish you had a few minutes to undo an rm? Now you do!
|
|
5
|
-
Home-page: https://github.com/zwimer/delayed_rm
|
|
6
5
|
License: GPL
|
|
7
6
|
Project-URL: Homepage, https://github.com/zwimer/delayed_rm
|
|
8
7
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.
|
|
10
|
-
Requires-Python: >=3.
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Requires-Python: >=3.10
|
|
11
10
|
Description-Content-Type: text/markdown
|
|
12
11
|
License-File: LICENSE
|
|
13
12
|
|
|
@@ -6,12 +6,12 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "delayed_rm"
|
|
7
7
|
classifiers = [
|
|
8
8
|
"Programming Language :: Python :: 3",
|
|
9
|
-
"Programming Language :: Python :: 3.
|
|
9
|
+
"Programming Language :: Python :: 3.10",
|
|
10
10
|
]
|
|
11
11
|
license = {text = "GPL"}
|
|
12
12
|
description = "Ever wish you had a few minutes to undo an rm? Now you do!"
|
|
13
13
|
urls = {Homepage = "https://github.com/zwimer/delayed_rm"}
|
|
14
|
-
requires-python = ">= 3.
|
|
14
|
+
requires-python = ">= 3.10"
|
|
15
15
|
dynamic = ["version"]
|
|
16
16
|
|
|
17
17
|
[project.readme]
|
|
@@ -38,7 +38,7 @@ version = {attr = "delayed_rm.__version__"}
|
|
|
38
38
|
|
|
39
39
|
[tool.black]
|
|
40
40
|
line-length = 120
|
|
41
|
-
target-version = ["
|
|
41
|
+
target-version = ["py310"]
|
|
42
42
|
|
|
43
43
|
[tool.ruff]
|
|
44
44
|
ignore=["E731","E741"]
|
delayed_rm-2.6.0/setup.cfg
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
[metadata]
|
|
2
|
-
name = delayed_rm
|
|
3
|
-
version = attr: delayed_rm.__version__
|
|
4
|
-
url = https://github.com/zwimer/delayed_rm
|
|
5
|
-
classifiers =
|
|
6
|
-
Programming Language :: Python :: 3
|
|
7
|
-
Programming Language :: Python :: 3.8
|
|
8
|
-
license = GPL
|
|
9
|
-
license_files = LICENSE
|
|
10
|
-
description = Ever wish you had a few minutes to undo an rm? Now you do!
|
|
11
|
-
long_description = file: README.md
|
|
12
|
-
long_description_content_type = text/markdown
|
|
13
|
-
|
|
14
|
-
[options]
|
|
15
|
-
python_requires = >= 3.8
|
|
16
|
-
packages = find:
|
|
17
|
-
|
|
18
|
-
[options.package_data]
|
|
19
|
-
delayed_rm = py.typed
|
|
20
|
-
|
|
21
|
-
[options.entry_points]
|
|
22
|
-
console_scripts =
|
|
23
|
-
delayed_rm = delayed_rm:cli
|
|
24
|
-
|
|
25
|
-
[egg_info]
|
|
26
|
-
tag_build =
|
|
27
|
-
tag_date = 0
|
|
28
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|