cli3 1.1.0__tar.gz → 1.1.1__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.
- {cli3-1.1.0/cli3.egg-info → cli3-1.1.1}/PKG-INFO +1 -1
- {cli3-1.1.0 → cli3-1.1.1}/cli/argument.py +12 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/wraps.py +3 -1
- {cli3-1.1.0 → cli3-1.1.1/cli3.egg-info}/PKG-INFO +1 -1
- {cli3-1.1.0 → cli3-1.1.1}/setup.py +1 -1
- {cli3-1.1.0 → cli3-1.1.1}/LICENSE +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/README.md +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/__init__.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/abc.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/app.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/command.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/flag.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/help.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/parser.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/tests/__init__.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/tests/app.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/tests/content/__init__.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/tests/content/v1.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli/tests/content/v2.py +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli3.egg-info/SOURCES.txt +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli3.egg-info/dependency_links.txt +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli3.egg-info/requires.txt +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/cli3.egg-info/top_level.txt +0 -0
- {cli3-1.1.0 → cli3-1.1.1}/setup.cfg +0 -0
|
@@ -19,6 +19,7 @@ __all__ = [
|
|
|
19
19
|
'parse_new_file',
|
|
20
20
|
'parse_existing_file',
|
|
21
21
|
'parse_list_function',
|
|
22
|
+
'parse_bytes_function',
|
|
22
23
|
|
|
23
24
|
'range_args',
|
|
24
25
|
'exact_args',
|
|
@@ -116,6 +117,17 @@ def parse_list_function(typefunc: TypeFunc, origin: type = list) -> TypeFunc:
|
|
|
116
117
|
"""
|
|
117
118
|
return lambda l: origin([typefunc(v) for v in l.split(',')])
|
|
118
119
|
|
|
120
|
+
def parse_bytes_function(origin: Union[Type[bytes], Type[bytearray]]) -> TypeFunc:
|
|
121
|
+
"""
|
|
122
|
+
generate bytes parser for the following type
|
|
123
|
+
|
|
124
|
+
:param origin: type to convert into
|
|
125
|
+
:return: function to parse string into bytes/bytearray
|
|
126
|
+
"""
|
|
127
|
+
if origin == bytes:
|
|
128
|
+
return lambda s: s.encode()
|
|
129
|
+
return lambda s: bytearray(s.encode())
|
|
130
|
+
|
|
119
131
|
def range_args(min: int = 0, max: Optional[int] = None) -> Callable:
|
|
120
132
|
"""
|
|
121
133
|
generate before action function to validate the number of arguments
|
|
@@ -83,8 +83,10 @@ def compile_typehint(attr: str, hint: Any, depth: int = 0) -> Optional[TypeFunc]
|
|
|
83
83
|
if hint in (Context, ):
|
|
84
84
|
return
|
|
85
85
|
# parse basic typehints
|
|
86
|
-
if hint in (str,
|
|
86
|
+
if hint in (str, int, float):
|
|
87
87
|
return hint
|
|
88
|
+
if hint in (bytes, bytearray):
|
|
89
|
+
return parse_bytes_function(hint)
|
|
88
90
|
if hint in (set, list, tuple):
|
|
89
91
|
return parse_list_function(str, hint)
|
|
90
92
|
if hint == bool:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|