lockss-pybasic 0.1.0.dev23__py3-none-any.whl → 0.1.1__py3-none-any.whl
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.
- lockss/pybasic/__init__.py +1 -1
- lockss/pybasic/cliutil.py +6 -6
- lockss/pybasic/outpututil.py +2 -2
- {lockss_pybasic-0.1.0.dev23.dist-info → lockss_pybasic-0.1.1.dist-info}/METADATA +3 -6
- lockss_pybasic-0.1.1.dist-info/RECORD +9 -0
- lockss_pybasic-0.1.0.dev23.dist-info/RECORD +0 -9
- {lockss_pybasic-0.1.0.dev23.dist-info → lockss_pybasic-0.1.1.dist-info}/LICENSE +0 -0
- {lockss_pybasic-0.1.0.dev23.dist-info → lockss_pybasic-0.1.1.dist-info}/WHEEL +0 -0
lockss/pybasic/__init__.py
CHANGED
lockss/pybasic/cliutil.py
CHANGED
|
@@ -144,7 +144,7 @@ class BaseCli(Generic[BaseModelT]):
|
|
|
144
144
|
self._parser.exit(1, f'internal error: no _{field_name} callable for the {field_name} command')
|
|
145
145
|
break
|
|
146
146
|
else:
|
|
147
|
-
self._parser.error(f'unknown command; expected one of {
|
|
147
|
+
self._parser.error(f'unknown command; expected one of {", ".join(field_names)}')
|
|
148
148
|
|
|
149
149
|
def _initialize_rich_argparse(self) -> None:
|
|
150
150
|
"""
|
|
@@ -192,7 +192,7 @@ def at_most_one_from_enum(model_cls, values: Dict[str, Any], enum_cls) -> Dict[s
|
|
|
192
192
|
enum_names = [field_name for field_name, model_field in model_cls.__fields__.items() if model_field.field_info.extra.get('enum') == enum_cls]
|
|
193
193
|
ret = [field_name for field_name in enum_names if values.get(field_name)]
|
|
194
194
|
if (length := len(ret)) > 1:
|
|
195
|
-
raise ValueError(f'at most one of {
|
|
195
|
+
raise ValueError(f'at most one of {", ".join([option_name(enum_name) for enum_name in enum_names])} is allowed, got {length} ({", ".join([option_name(enum_name) for enum_name in ret])})')
|
|
196
196
|
return values
|
|
197
197
|
|
|
198
198
|
|
|
@@ -218,24 +218,24 @@ def get_from_enum(model_inst, enum_cls, default=None):
|
|
|
218
218
|
|
|
219
219
|
def at_most_one(values: Dict[str, Any], *names: str):
|
|
220
220
|
if (length := _matchy_length(values, *names)) > 1:
|
|
221
|
-
raise ValueError(f'at most one of {
|
|
221
|
+
raise ValueError(f'at most one of {", ".join([option_name(name) for name in names])} is allowed, got {length}')
|
|
222
222
|
return values
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
def exactly_one(values: Dict[str, Any], *names: str):
|
|
226
226
|
if (length := _matchy_length(values, *names)) != 1:
|
|
227
|
-
raise ValueError(f'exactly one of {
|
|
227
|
+
raise ValueError(f'exactly one of {", ".join([option_name(name) for name in names])} is required, got {length}')
|
|
228
228
|
return values
|
|
229
229
|
|
|
230
230
|
|
|
231
231
|
def one_or_more(values: Dict[str, Any], *names: str):
|
|
232
232
|
if _matchy_length(values, *names) == 0:
|
|
233
|
-
raise ValueError(f'one or more of {
|
|
233
|
+
raise ValueError(f'one or more of {", ".join([option_name(name) for name in names])} is required')
|
|
234
234
|
return values
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
def option_name(name: str) -> str:
|
|
238
|
-
return f'{(
|
|
238
|
+
return f'{("-" if len(name) == 1 else "--")}{name.replace("_", "-")}'
|
|
239
239
|
|
|
240
240
|
|
|
241
241
|
def _matchy_length(values: Dict[str, Any], *names: str) -> int:
|
lockss/pybasic/outpututil.py
CHANGED
|
@@ -46,7 +46,7 @@ DEFAULT_OUTPUT_FORMAT = 'simple' # from tabulate
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class OutputFormatOptions(BaseModel):
|
|
49
|
-
output_format: Optional[str] = Field(DEFAULT_OUTPUT_FORMAT, description=f'[output] set the output format; choices: {
|
|
49
|
+
output_format: Optional[str] = Field(DEFAULT_OUTPUT_FORMAT, description=f'[output] set the output format; choices: {", ".join(OutputFormat.__members__.keys())}')
|
|
50
50
|
|
|
51
51
|
@validator('output_format')
|
|
52
52
|
def _validate_output_format(cls, val: str):
|
|
@@ -54,4 +54,4 @@ class OutputFormatOptions(BaseModel):
|
|
|
54
54
|
_ = OutputFormat[val]
|
|
55
55
|
return val
|
|
56
56
|
except KeyError:
|
|
57
|
-
raise ValueError(f'must be one of {
|
|
57
|
+
raise ValueError(f'must be one of {", ".join(OutputFormat.__members__.keys())}; got {val}')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lockss-pybasic
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Basic Python utilities
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Author: Thib Guicherd-Callin
|
|
@@ -12,12 +12,9 @@ Classifier: Development Status :: 4 - Beta
|
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Framework :: Pydantic :: 2
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: Intended Audience :: System Administrators
|
|
16
15
|
Classifier: License :: OSI Approved :: BSD License
|
|
17
16
|
Classifier: Programming Language :: Python
|
|
18
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
-
Classifier: Topic :: System :: Archiving
|
|
20
|
-
Classifier: Topic :: Utilities
|
|
21
18
|
Requires-Dist: pydantic (>=2.11.0,<3.0.0)
|
|
22
19
|
Requires-Dist: pydantic-argparse (>=0.10.0,<0.11.0)
|
|
23
20
|
Requires-Dist: rich-argparse (>=1.7.0,<1.8.0)
|
|
@@ -29,8 +26,8 @@ Description-Content-Type: text/x-rst
|
|
|
29
26
|
lockss-pybasic
|
|
30
27
|
==============
|
|
31
28
|
|
|
32
|
-
.. |RELEASE| replace:: 0.1.
|
|
33
|
-
.. |RELEASE_DATE| replace::
|
|
29
|
+
.. |RELEASE| replace:: 0.1.1
|
|
30
|
+
.. |RELEASE_DATE| replace:: 2025-10-02
|
|
34
31
|
|
|
35
32
|
**Latest release:** |RELEASE| (|RELEASE_DATE|)
|
|
36
33
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
lockss/pybasic/__init__.py,sha256=5NRdbEb_7GIZas3_wlx8I8qoaWR2HaYAgLF-pKKi_nY,1673
|
|
2
|
+
lockss/pybasic/cliutil.py,sha256=zsIU_GJX31UM4XZbMhUxFMS2zVpA09_1q1GQAMW2HOc,10347
|
|
3
|
+
lockss/pybasic/errorutil.py,sha256=XI84PScZ851_-gfoazivJ8ceieMYWaxQr7qih5ltga0,1951
|
|
4
|
+
lockss/pybasic/fileutil.py,sha256=BpdoPWL70xYTuhyQRBEurScRVnPQg0mX-XW8yyKPGjw,2958
|
|
5
|
+
lockss/pybasic/outpututil.py,sha256=8naQEZ1rM6vOFNL-9mWoK4dMBWokHmzQ0FkHaz8dyuM,2345
|
|
6
|
+
lockss_pybasic-0.1.1.dist-info/LICENSE,sha256=O9ONND4uDxY_jucI4jZDf2liAk05ScEJaYu-Al7EOdQ,1506
|
|
7
|
+
lockss_pybasic-0.1.1.dist-info/METADATA,sha256=1FRG9Ulhphoea8-n_lUCnc8oczgxzzgfOutbttcoMQE,4242
|
|
8
|
+
lockss_pybasic-0.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
9
|
+
lockss_pybasic-0.1.1.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
lockss/pybasic/__init__.py,sha256=jmOhJI5PiH3jLMWLGSCBYvv8hV2yG9PTPUfvYGtP1oU,1679
|
|
2
|
-
lockss/pybasic/cliutil.py,sha256=Q7WNFbtZzMBfEXjhqsUJlYOdsKYQm0Mgerf7aVe5VK8,10347
|
|
3
|
-
lockss/pybasic/errorutil.py,sha256=XI84PScZ851_-gfoazivJ8ceieMYWaxQr7qih5ltga0,1951
|
|
4
|
-
lockss/pybasic/fileutil.py,sha256=BpdoPWL70xYTuhyQRBEurScRVnPQg0mX-XW8yyKPGjw,2958
|
|
5
|
-
lockss/pybasic/outpututil.py,sha256=JyXKXlkaCcCGvonUvmDGRdI6PxwN5t7DPVIk64S8-2g,2345
|
|
6
|
-
lockss_pybasic-0.1.0.dev23.dist-info/LICENSE,sha256=O9ONND4uDxY_jucI4jZDf2liAk05ScEJaYu-Al7EOdQ,1506
|
|
7
|
-
lockss_pybasic-0.1.0.dev23.dist-info/METADATA,sha256=viCY_etc3kouRMBzEAcl44-zfDWo2Fkzk767I91jBKM,4372
|
|
8
|
-
lockss_pybasic-0.1.0.dev23.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
9
|
-
lockss_pybasic-0.1.0.dev23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|