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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli3
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: A highly configurable, dynamic, fast, and easy solution to managing a command-line application.
5
5
  Home-page: https://github.com/imgurbot12/cli
6
6
  Author: Andrew Scott
@@ -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, bytes, bytearray, int, float):
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli3
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: A highly configurable, dynamic, fast, and easy solution to managing a command-line application.
5
5
  Home-page: https://github.com/imgurbot12/cli
6
6
  Author: Andrew Scott
@@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
5
5
 
6
6
  setup(
7
7
  name='cli3',
8
- version='1.1.0',
8
+ version='1.1.1',
9
9
  license='MIT',
10
10
  packages=find_packages(),
11
11
  url='https://github.com/imgurbot12/cli',
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