lockss-pybasic 0.1.0.dev17__tar.gz → 0.1.0.dev19__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.
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/PKG-INFO +2 -1
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/pyproject.toml +2 -1
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/src/lockss/pybasic/__init__.py +1 -1
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/src/lockss/pybasic/cliutil.py +17 -2
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/LICENSE +0 -0
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/README.rst +0 -0
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/src/lockss/pybasic/errorutil.py +0 -0
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/src/lockss/pybasic/fileutil.py +0 -0
- {lockss_pybasic-0.1.0.dev17 → lockss_pybasic-0.1.0.dev19}/src/lockss/pybasic/outpututil.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lockss-pybasic
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev19
|
|
4
4
|
Summary: Basic Python utilities
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Author: Thib Guicherd-Callin
|
|
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Requires-Dist: pydantic (>=2.11.0,<3.0.0)
|
|
17
17
|
Requires-Dist: pydantic-argparse (>=0.10.0,<0.11.0)
|
|
18
|
+
Requires-Dist: rich-argparse (>=1.7.0,<1.8.0)
|
|
18
19
|
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
19
20
|
Description-Content-Type: text/x-rst
|
|
20
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lockss-pybasic"
|
|
3
|
-
version = "0.1.0-
|
|
3
|
+
version = "0.1.0-dev19"
|
|
4
4
|
description = "Basic Python utilities"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Thib Guicherd-Callin", email = "thib@cs.stanford.edu" }
|
|
@@ -11,6 +11,7 @@ requires-python = ">=3.9,<4.0"
|
|
|
11
11
|
dependencies = [
|
|
12
12
|
"pydantic (>=2.11.0,<3.0.0)",
|
|
13
13
|
"pydantic-argparse (>=0.10.0,<0.11.0)",
|
|
14
|
+
"rich-argparse (>=1.7.0,<1.8.0)",
|
|
14
15
|
"tabulate (>=0.9.0,<0.10.0)"
|
|
15
16
|
]
|
|
16
17
|
|
|
@@ -32,14 +32,13 @@
|
|
|
32
32
|
Command line utilities.
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
|
-
from abc import ABC, abstractmethod
|
|
36
35
|
from collections.abc import Callable
|
|
37
36
|
import sys
|
|
38
37
|
from typing import Any, Dict, Generic, Optional, TypeVar
|
|
39
38
|
|
|
40
39
|
from pydantic.v1 import BaseModel, Field
|
|
41
40
|
from pydantic_argparse import ArgumentParser
|
|
42
|
-
|
|
41
|
+
from rich_argparse import RichHelpFormatter
|
|
43
42
|
|
|
44
43
|
class ActionCommand(Callable, BaseModel):
|
|
45
44
|
"""
|
|
@@ -110,6 +109,7 @@ class BaseCli(Generic[BaseModelT]):
|
|
|
110
109
|
self._parser: ArgumentParser = ArgumentParser(model=self.extra.get('model'),
|
|
111
110
|
prog=self.extra.get('prog'),
|
|
112
111
|
description=self.extra.get('description'))
|
|
112
|
+
self._initialize_rich_argparse()
|
|
113
113
|
self._args = self._parser.parse_typed_args()
|
|
114
114
|
self.dispatch()
|
|
115
115
|
|
|
@@ -134,6 +134,21 @@ class BaseCli(Generic[BaseModelT]):
|
|
|
134
134
|
else:
|
|
135
135
|
self._parser.error(f'unknown command; expected one of {', '.join(field_names)}')
|
|
136
136
|
|
|
137
|
+
def _initialize_rich_argparse(self) -> None:
|
|
138
|
+
for cls in [RichHelpFormatter]:
|
|
139
|
+
cls.styles.update({
|
|
140
|
+
'argparse.args': f'bold {cls.styles["argparse.args"]}',
|
|
141
|
+
'argparse.groups': f'bold {cls.styles["argparse.groups"]}',
|
|
142
|
+
'argparse.metavar': f'bold {cls.styles["argparse.metavar"]}',
|
|
143
|
+
'argparse.prog': f'bold {cls.styles["argparse.prog"]}',
|
|
144
|
+
})
|
|
145
|
+
def _add_formatter_class(container):
|
|
146
|
+
container.formatter_class = RichHelpFormatter
|
|
147
|
+
if container._subcommands:
|
|
148
|
+
for subcommand in container._subcommands:
|
|
149
|
+
_add_formatter_class(subcommand)
|
|
150
|
+
_add_formatter_class(self._parser)
|
|
151
|
+
|
|
137
152
|
|
|
138
153
|
def at_most_one_from_enum(model_cls, values: Dict[str, Any], enum_cls) -> Dict[str, Any]:
|
|
139
154
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|