dotlocalslashbin 0.0.15__tar.gz → 0.0.16__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.15 → dotlocalslashbin-0.0.16}/PKG-INFO +1 -1
- {dotlocalslashbin-0.0.15 → dotlocalslashbin-0.0.16}/src/dotlocalslashbin.py +21 -25
- {dotlocalslashbin-0.0.15 → dotlocalslashbin-0.0.16}/LICENSES/MPL-2.0.txt +0 -0
- {dotlocalslashbin-0.0.15 → dotlocalslashbin-0.0.16}/README.md +0 -0
- {dotlocalslashbin-0.0.15 → dotlocalslashbin-0.0.16}/pyproject.toml +0 -0
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
# ///
|
|
9
9
|
"""Download and extract files to `~/.local/bin/`."""
|
|
10
10
|
import tarfile
|
|
11
|
-
from argparse import
|
|
12
|
-
ArgumentDefaultsHelpFormatter,
|
|
13
|
-
ArgumentParser,
|
|
14
|
-
BooleanOptionalAction,
|
|
15
|
-
Namespace,
|
|
16
|
-
)
|
|
11
|
+
from argparse import ArgumentParser, BooleanOptionalAction, Namespace
|
|
17
12
|
from dataclasses import dataclass
|
|
18
13
|
from enum import Enum
|
|
19
14
|
from hashlib import file_digest
|
|
@@ -28,16 +23,18 @@ from urllib.request import urlopen
|
|
|
28
23
|
from zipfile import ZipFile
|
|
29
24
|
|
|
30
25
|
|
|
31
|
-
__version__ = "0.0.
|
|
26
|
+
__version__ = "0.0.16"
|
|
32
27
|
|
|
28
|
+
_CACHE = Path("~/.cache/dotlocalslashbin/")
|
|
33
29
|
_HOME = str(Path("~").expanduser())
|
|
30
|
+
_INPUT = "bin.toml"
|
|
34
31
|
_OUTPUT = Path("~/.local/bin/")
|
|
35
32
|
_SHA512_LENGTH = 128
|
|
36
33
|
|
|
37
34
|
|
|
38
35
|
class _CustomNamespace(Namespace):
|
|
39
36
|
output: Path
|
|
40
|
-
input: Path
|
|
37
|
+
input: list[Path]
|
|
41
38
|
cache: Path
|
|
42
39
|
|
|
43
40
|
|
|
@@ -68,8 +65,10 @@ def main() -> int:
|
|
|
68
65
|
for path in args.cache.expanduser().iterdir():
|
|
69
66
|
path.unlink()
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
data: dict[str, dict] = {}
|
|
69
|
+
for i in args.input:
|
|
70
|
+
with i.expanduser().open("rb") as file:
|
|
71
|
+
data |= load(file)
|
|
73
72
|
|
|
74
73
|
for name, record in data.items():
|
|
75
74
|
item = Item()
|
|
@@ -144,24 +143,21 @@ def _process(item: Item) -> None:
|
|
|
144
143
|
def _parse_args() -> _CustomNamespace:
|
|
145
144
|
parser = ArgumentParser(
|
|
146
145
|
prog=Path(__file__).name,
|
|
147
|
-
|
|
146
|
+
epilog="¹ --input can be specified multiple times",
|
|
148
147
|
)
|
|
149
148
|
parser.add_argument("--version", action="version", version=__version__)
|
|
150
|
-
help_ = "TOML specification"
|
|
151
|
-
parser.add_argument("--input",
|
|
152
|
-
help_ = "Target directory"
|
|
149
|
+
help_ = f"TOML specification (default: {_INPUT})¹"
|
|
150
|
+
parser.add_argument("--input", action="append", help=help_, type=Path)
|
|
151
|
+
help_ = f"Target directory (default: {_OUTPUT})"
|
|
153
152
|
parser.add_argument("--output", default=_OUTPUT, help=help_, type=Path)
|
|
154
|
-
help_ = "Cache directory"
|
|
155
|
-
default =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
parser.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
help=help_,
|
|
163
|
-
)
|
|
164
|
-
return parser.parse_args(namespace=_CustomNamespace())
|
|
153
|
+
help_ = f"Cache directory (default: {_CACHE})"
|
|
154
|
+
parser.add_argument("--cache", default=_CACHE, help=help_, type=Path)
|
|
155
|
+
help_ = "Clear the cache directory first (default: --no-clear)"
|
|
156
|
+
parser.add_argument("--clear", action=BooleanOptionalAction, help=help_)
|
|
157
|
+
result = parser.parse_args(namespace=_CustomNamespace())
|
|
158
|
+
if not result.input:
|
|
159
|
+
result.input = [Path(_INPUT)]
|
|
160
|
+
return result
|
|
165
161
|
|
|
166
162
|
|
|
167
163
|
def _download(item: Item) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|