dotlocalslashbin 0.0.12__tar.gz → 0.0.15__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.
- {dotlocalslashbin-0.0.12 → dotlocalslashbin-0.0.15}/PKG-INFO +4 -2
- {dotlocalslashbin-0.0.12 → dotlocalslashbin-0.0.15}/README.md +1 -0
- {dotlocalslashbin-0.0.12 → dotlocalslashbin-0.0.15}/pyproject.toml +1 -0
- {dotlocalslashbin-0.0.12 → dotlocalslashbin-0.0.15}/src/dotlocalslashbin.py +22 -6
- {dotlocalslashbin-0.0.12 → dotlocalslashbin-0.0.15}/LICENSES/MPL-2.0.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: dotlocalslashbin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.15
|
|
4
4
|
Summary: Download and extract files to `~/.local/bin/`.
|
|
5
5
|
Author-email: Keith Maxwell <keith.maxwell@gmail.com>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -16,6 +16,7 @@ Requires-Dist: reuse ; extra == "test"
|
|
|
16
16
|
Requires-Dist: ruff ; extra == "test"
|
|
17
17
|
Requires-Dist: twine ; extra == "test"
|
|
18
18
|
Requires-Dist: usort ; extra == "test"
|
|
19
|
+
Requires-Dist: yamllint ; extra == "test"
|
|
19
20
|
Project-URL: Home, https://github.com/maxwell-k/dotlocalslashbin/
|
|
20
21
|
Provides-Extra: test
|
|
21
22
|
|
|
@@ -42,6 +43,7 @@ Optionally can:
|
|
|
42
43
|
- invoke the target with an argument, for example `--version`
|
|
43
44
|
- strip a prefix while extracting
|
|
44
45
|
- ignore certain files while extracting
|
|
46
|
+
- clear the cache beforehand
|
|
45
47
|
|
|
46
48
|
\* if the URL is an absolute path on the local file system; it is not downloaded
|
|
47
49
|
to the cache.
|
|
@@ -21,6 +21,7 @@ Optionally can:
|
|
|
21
21
|
- invoke the target with an argument, for example `--version`
|
|
22
22
|
- strip a prefix while extracting
|
|
23
23
|
- ignore certain files while extracting
|
|
24
|
+
- clear the cache beforehand
|
|
24
25
|
|
|
25
26
|
\* if the URL is an absolute path on the local file system; it is not downloaded
|
|
26
27
|
to the cache.
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
# ///
|
|
9
9
|
"""Download and extract files to `~/.local/bin/`."""
|
|
10
10
|
import tarfile
|
|
11
|
-
from argparse import
|
|
11
|
+
from argparse import (
|
|
12
|
+
ArgumentDefaultsHelpFormatter,
|
|
13
|
+
ArgumentParser,
|
|
14
|
+
BooleanOptionalAction,
|
|
15
|
+
Namespace,
|
|
16
|
+
)
|
|
12
17
|
from dataclasses import dataclass
|
|
13
18
|
from enum import Enum
|
|
14
19
|
from hashlib import file_digest
|
|
@@ -23,7 +28,7 @@ from urllib.request import urlopen
|
|
|
23
28
|
from zipfile import ZipFile
|
|
24
29
|
|
|
25
30
|
|
|
26
|
-
__version__ = "0.0.
|
|
31
|
+
__version__ = "0.0.15"
|
|
27
32
|
|
|
28
33
|
_HOME = str(Path("~").expanduser())
|
|
29
34
|
_OUTPUT = Path("~/.local/bin/")
|
|
@@ -33,7 +38,7 @@ _SHA512_LENGTH = 128
|
|
|
33
38
|
class _CustomNamespace(Namespace):
|
|
34
39
|
output: Path
|
|
35
40
|
input: Path
|
|
36
|
-
|
|
41
|
+
cache: Path
|
|
37
42
|
|
|
38
43
|
|
|
39
44
|
Action = Enum("Action", ["command", "copy", "symlink", "untar", "unzip"])
|
|
@@ -59,6 +64,10 @@ def main() -> int:
|
|
|
59
64
|
"""Parse command line arguments and download each file."""
|
|
60
65
|
args = _parse_args()
|
|
61
66
|
|
|
67
|
+
if args.clear:
|
|
68
|
+
for path in args.cache.expanduser().iterdir():
|
|
69
|
+
path.unlink()
|
|
70
|
+
|
|
62
71
|
with args.input.expanduser().open("rb") as file:
|
|
63
72
|
data = load(file)
|
|
64
73
|
|
|
@@ -80,7 +89,7 @@ def main() -> int:
|
|
|
80
89
|
item.action = _guess_action(item)
|
|
81
90
|
|
|
82
91
|
if item.url.startswith("https://"):
|
|
83
|
-
item.downloaded = args.
|
|
92
|
+
item.downloaded = args.cache.expanduser() / item.url.rsplit("/", 1)[1]
|
|
84
93
|
else:
|
|
85
94
|
item.downloaded = Path(item.url)
|
|
86
95
|
try:
|
|
@@ -142,9 +151,16 @@ def _parse_args() -> _CustomNamespace:
|
|
|
142
151
|
parser.add_argument("--input", default="bin.toml", help=help_, type=Path)
|
|
143
152
|
help_ = "Target directory"
|
|
144
153
|
parser.add_argument("--output", default=_OUTPUT, help=help_, type=Path)
|
|
145
|
-
help_ = "
|
|
154
|
+
help_ = "Cache directory"
|
|
146
155
|
default = "~/.cache/dotlocalslashbin/"
|
|
147
|
-
parser.add_argument("--
|
|
156
|
+
parser.add_argument("--cache", default=default, help=help_, type=Path)
|
|
157
|
+
help_ = "Clear the cache directory first"
|
|
158
|
+
parser.add_argument(
|
|
159
|
+
"--clear",
|
|
160
|
+
default=False,
|
|
161
|
+
action=BooleanOptionalAction,
|
|
162
|
+
help=help_,
|
|
163
|
+
)
|
|
148
164
|
return parser.parse_args(namespace=_CustomNamespace())
|
|
149
165
|
|
|
150
166
|
|
|
File without changes
|