log21
Advanced tools
+4
-3
| Metadata-Version: 2.1 | ||
| Name: log21 | ||
| Version: 2.9.1 | ||
| Version: 2.9.2 | ||
| Summary: A simple logging package that helps you log colorized messages in Windows console. | ||
@@ -95,5 +95,6 @@ Author-email: "CodeWriter21(Mehrad Pooryoussof)" <CodeWriter21@gmail.com> | ||
| ### 2.9.1 | ||
| ### 2.9.2 | ||
| + Update `README.md`. | ||
| + Added `Sequence[T]` as a supported type to the ColorizingArgumentParser. | ||
| + Bug fixes. | ||
@@ -100,0 +101,0 @@ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md) |
+1
-1
@@ -29,3 +29,3 @@ [build-system] | ||
| ] | ||
| version = "2.9.1" | ||
| version = "2.9.2" | ||
@@ -32,0 +32,0 @@ [tool.setuptools.packages.find] |
+3
-2
@@ -64,5 +64,6 @@ log21 | ||
| ### 2.9.1 | ||
| ### 2.9.2 | ||
| + Update `README.md`. | ||
| + Added `Sequence[T]` as a supported type to the ColorizingArgumentParser. | ||
| + Bug fixes. | ||
@@ -69,0 +70,0 @@ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md) |
| Metadata-Version: 2.1 | ||
| Name: log21 | ||
| Version: 2.9.1 | ||
| Version: 2.9.2 | ||
| Summary: A simple logging package that helps you log colorized messages in Windows console. | ||
@@ -95,5 +95,6 @@ Author-email: "CodeWriter21(Mehrad Pooryoussof)" <CodeWriter21@gmail.com> | ||
| ### 2.9.1 | ||
| ### 2.9.2 | ||
| + Update `README.md`. | ||
| + Added `Sequence[T]` as a supported type to the ColorizingArgumentParser. | ||
| + Bug fixes. | ||
@@ -100,0 +101,0 @@ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md) |
@@ -26,3 +26,3 @@ # log21.__init__.py | ||
| __author__ = 'CodeWriter21 (Mehrad Pooryoussof)' | ||
| __version__ = '2.9.1' | ||
| __version__ = '2.9.2' | ||
| __github__ = 'Https://GitHub.com/MPCodeWriter21/log21' | ||
@@ -29,0 +29,0 @@ __all__ = [ |
+44
-28
@@ -11,5 +11,6 @@ # log21.Argparse.py | ||
| import argparse as _argparse | ||
| import collections.abc | ||
| from enum import Enum as _Enum | ||
| from typing import (Tuple as _Tuple, Mapping as _Mapping, Optional as _Optional, | ||
| Sequence as _Sequence) | ||
| from typing import (Tuple as _Tuple, Mapping as _Mapping, NoReturn, | ||
| Optional as _Optional, Sequence as _Sequence) | ||
| from gettext import gettext as _gettext | ||
@@ -82,3 +83,3 @@ from textwrap import TextWrapper as _TextWrapper | ||
| class _Section(object): | ||
| class _Section: | ||
@@ -566,6 +567,20 @@ def __init__(self, formatter, parent, heading=None): | ||
| # Handle `Union` and `Optional` as a type (e.g. `Union[int, str]` and | ||
| # `Optional[int]`) | ||
| elif (hasattr(_typing, '_UnionGenericAlias') | ||
| and isinstance(func_type, _typing._UnionGenericAlias)): # type: ignore | ||
| # Optional[T] is just Union[T, NoneType] | ||
| # Optional | ||
| if (hasattr(_types, 'NoneType') and len(func_type.__args__) == 2 | ||
| and func_type.__args__[1] is _types.NoneType): | ||
| action.required = False | ||
| func_type = func_type.__args__[0] | ||
| # Union | ||
| else: | ||
| func_type = func_type.__args__ # type: ignore | ||
| # Handle `List` as a type (e.g. `List[int]`) | ||
| elif (hasattr(_typing, '_GenericAlias') | ||
| and isinstance(func_type, _typing._GenericAlias) # type: ignore | ||
| and func_type.__origin__ is list): | ||
| and getattr(func_type, '__origin__') is list): | ||
| func_type = func_type.__args__[0] | ||
@@ -575,24 +590,17 @@ if kwargs.get('nargs') is None: | ||
| # Handle `Sequence` as a type (e.g. `Sequence[int]`) | ||
| elif (hasattr(_typing, '_GenericAlias') | ||
| and isinstance(func_type, _typing._GenericAlias) # type: ignore | ||
| and getattr(func_type, '__origin__') is collections.abc.Sequence): | ||
| func_type = func_type.__args__[0] | ||
| if kwargs.get('nargs') is None: | ||
| action.nargs = '+' | ||
| # Handle `Required` as a type (e.g. `Required[int]`) | ||
| elif (hasattr(_typing, 'Required') and hasattr(_typing, '_GenericAlias') | ||
| and isinstance(func_type, _typing._GenericAlias) # type: ignore | ||
| and func_type.__origin__ is _typing.Required | ||
| ): | ||
| and getattr(func_type, '__origin__') is _typing.Required): | ||
| func_type = func_type.__args__[0] | ||
| action.required = True | ||
| # Handle `Union` and `Optional` as a type (e.g. `Union[int, str]` and | ||
| # `Optional[int]`) | ||
| elif (hasattr(_types, 'NoneType') and hasattr(_typing, '_UnionGenericAlias') | ||
| and isinstance(func_type, _typing._UnionGenericAlias)): # type: ignore | ||
| # Optional[T] is just Union[T, NoneType] | ||
| # Optional | ||
| if (len(func_type.__args__) == 2 | ||
| and func_type.__args__[1] is _types.NoneType): | ||
| action.required = False | ||
| func_type = func_type.__args__[0] | ||
| # Union | ||
| else: | ||
| func_type = func_type.__args__ # type: ignore | ||
| # Handle Enum as a type | ||
@@ -754,2 +762,3 @@ elif callable(func_type) and isinstance(func_type, type) and issubclass( | ||
| ) | ||
| return NoReturn | ||
@@ -759,8 +768,6 @@ def _get_formatter(self): | ||
| return self.formatter_class(prog=self.prog, colors=self.colors) | ||
| else: | ||
| return self.formatter_class(prog=self.prog) | ||
| return self.formatter_class(prog=self.prog) | ||
| def _get_value(self, action, arg_string): | ||
| """Override _get_value to add support for types such as Union and | ||
| Literal.""" | ||
| """Override _get_value to add support for types such as Union and Literal.""" | ||
@@ -851,3 +858,4 @@ func_type = self._registry_get('type', action.type, action.type) | ||
| # for regular arguments, just add them back into the list | ||
| if not arg_string or arg_string[0] not in self.fromfile_prefix_chars: | ||
| if not arg_string or arg_string[0] not in (self.fromfile_prefix_chars | ||
| or ''): | ||
| new_arg_strings.append(arg_string) | ||
@@ -858,3 +866,3 @@ | ||
| try: | ||
| with open(arg_string[1:]) as args_file: | ||
| with open(arg_string[1:], encoding='utf-8') as args_file: | ||
| arg_strings = [] | ||
@@ -1121,3 +1129,7 @@ for arg_line in args_file.read().splitlines(): | ||
| self.error( | ||
| _gettext(f'one of the arguments {" ".join(names)} is required') | ||
| _gettext( | ||
| 'one of the arguments ' + | ||
| ' '.join(name for name in names if name is not None) + | ||
| ' is required' | ||
| ) | ||
| ) | ||
@@ -1139,3 +1151,7 @@ | ||
| self.error( | ||
| _gettext(f'one of the arguments {" ".join(names)} is required') | ||
| _gettext( | ||
| 'one of the arguments ' + | ||
| ' '.join(name for name in names if name is not None) + | ||
| ' is required' | ||
| ) | ||
| ) | ||
@@ -1142,0 +1158,0 @@ |
@@ -265,7 +265,6 @@ # log21.Argparse.py | ||
| } | ||
| if isinstance(argument.annotation, type): | ||
| config['type'] = argument.annotation | ||
| if argument.annotation == bool: | ||
| config['action'] = 'store_true' | ||
| config.pop('type') | ||
| elif argument.annotation: | ||
| config['type'] = argument.annotation | ||
| if argument.kind == _inspect._ParameterKind.POSITIONAL_ONLY: | ||
@@ -272,0 +271,0 @@ config['required'] = True |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
273260
0.35%5662
0.25%