log21 2.9.1__tar.gz → 2.9.2__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.
- {log21-2.9.1/src/log21.egg-info → log21-2.9.2}/PKG-INFO +4 -3
- {log21-2.9.1 → log21-2.9.2}/README.md +3 -2
- {log21-2.9.1 → log21-2.9.2}/pyproject.toml +1 -1
- {log21-2.9.1 → log21-2.9.2}/src/log21/Argparse.py +44 -28
- {log21-2.9.1 → log21-2.9.2}/src/log21/Argumentify.py +2 -3
- {log21-2.9.1 → log21-2.9.2}/src/log21/__init__.py +1 -1
- {log21-2.9.1 → log21-2.9.2/src/log21.egg-info}/PKG-INFO +4 -3
- {log21-2.9.1 → log21-2.9.2}/LICENSE.txt +0 -0
- {log21-2.9.1 → log21-2.9.2}/setup.cfg +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/Colors.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/CrashReporter/Formatters.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/CrashReporter/Reporters.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/CrashReporter/__init__.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/FileHandler.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/Formatters.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/Levels.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/Logger.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/LoggingWindow.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/Manager.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/PPrint.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/ProgressBar.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/StreamHandler.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21/TreePrint.py +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21.egg-info/SOURCES.txt +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21.egg-info/dependency_links.txt +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21.egg-info/requires.txt +0 -0
- {log21-2.9.1 → log21-2.9.2}/src/log21.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: log21
|
|
3
|
-
Version: 2.9.
|
|
3
|
+
Version: 2.9.2
|
|
4
4
|
Summary: A simple logging package that helps you log colorized messages in Windows console.
|
|
5
5
|
Author-email: "CodeWriter21(Mehrad Pooryoussof)" <CodeWriter21@gmail.com>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -92,9 +92,10 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
92
92
|
Changes
|
|
93
93
|
-------
|
|
94
94
|
|
|
95
|
-
### 2.9.
|
|
95
|
+
### 2.9.2
|
|
96
96
|
|
|
97
|
-
+
|
|
97
|
+
+ Added `Sequence[T]` as a supported type to the ColorizingArgumentParser.
|
|
98
|
+
+ Bug fixes.
|
|
98
99
|
|
|
99
100
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
100
101
|
|
|
@@ -61,9 +61,10 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
61
61
|
Changes
|
|
62
62
|
-------
|
|
63
63
|
|
|
64
|
-
### 2.9.
|
|
64
|
+
### 2.9.2
|
|
65
65
|
|
|
66
|
-
+
|
|
66
|
+
+ Added `Sequence[T]` as a supported type to the ColorizingArgumentParser.
|
|
67
|
+
+ Bug fixes.
|
|
67
68
|
|
|
68
69
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
69
70
|
|
|
@@ -8,9 +8,10 @@ import sys as _sys
|
|
|
8
8
|
import types as _types
|
|
9
9
|
import typing as _typing
|
|
10
10
|
import argparse as _argparse
|
|
11
|
+
import collections.abc
|
|
11
12
|
from enum import Enum as _Enum
|
|
12
|
-
from typing import (Tuple as _Tuple, Mapping as _Mapping,
|
|
13
|
-
Sequence as _Sequence)
|
|
13
|
+
from typing import (Tuple as _Tuple, Mapping as _Mapping, NoReturn,
|
|
14
|
+
Optional as _Optional, Sequence as _Sequence)
|
|
14
15
|
from gettext import gettext as _gettext
|
|
15
16
|
from textwrap import TextWrapper as _TextWrapper
|
|
16
17
|
from collections import OrderedDict as _OrderedDict
|
|
@@ -78,7 +79,7 @@ class ColorizingHelpFormatter(_argparse.HelpFormatter):
|
|
|
78
79
|
if key in self.colors:
|
|
79
80
|
self.colors[key] = value
|
|
80
81
|
|
|
81
|
-
class _Section
|
|
82
|
+
class _Section:
|
|
82
83
|
|
|
83
84
|
def __init__(self, formatter, parent, heading=None):
|
|
84
85
|
self.formatter = formatter
|
|
@@ -561,10 +562,32 @@ class _ActionsContainer(_argparse._ActionsContainer):
|
|
|
561
562
|
and isinstance(func_type, _typing._LiteralGenericAlias)): # type: ignore
|
|
562
563
|
func_type = Literal(func_type)
|
|
563
564
|
|
|
565
|
+
# Handle `Union` and `Optional` as a type (e.g. `Union[int, str]` and
|
|
566
|
+
# `Optional[int]`)
|
|
567
|
+
elif (hasattr(_typing, '_UnionGenericAlias')
|
|
568
|
+
and isinstance(func_type, _typing._UnionGenericAlias)): # type: ignore
|
|
569
|
+
# Optional[T] is just Union[T, NoneType]
|
|
570
|
+
# Optional
|
|
571
|
+
if (hasattr(_types, 'NoneType') and len(func_type.__args__) == 2
|
|
572
|
+
and func_type.__args__[1] is _types.NoneType):
|
|
573
|
+
action.required = False
|
|
574
|
+
func_type = func_type.__args__[0]
|
|
575
|
+
# Union
|
|
576
|
+
else:
|
|
577
|
+
func_type = func_type.__args__ # type: ignore
|
|
578
|
+
|
|
564
579
|
# Handle `List` as a type (e.g. `List[int]`)
|
|
565
580
|
elif (hasattr(_typing, '_GenericAlias')
|
|
566
581
|
and isinstance(func_type, _typing._GenericAlias) # type: ignore
|
|
567
|
-
and func_type
|
|
582
|
+
and getattr(func_type, '__origin__') is list):
|
|
583
|
+
func_type = func_type.__args__[0]
|
|
584
|
+
if kwargs.get('nargs') is None:
|
|
585
|
+
action.nargs = '+'
|
|
586
|
+
|
|
587
|
+
# Handle `Sequence` as a type (e.g. `Sequence[int]`)
|
|
588
|
+
elif (hasattr(_typing, '_GenericAlias')
|
|
589
|
+
and isinstance(func_type, _typing._GenericAlias) # type: ignore
|
|
590
|
+
and getattr(func_type, '__origin__') is collections.abc.Sequence):
|
|
568
591
|
func_type = func_type.__args__[0]
|
|
569
592
|
if kwargs.get('nargs') is None:
|
|
570
593
|
action.nargs = '+'
|
|
@@ -572,25 +595,10 @@ class _ActionsContainer(_argparse._ActionsContainer):
|
|
|
572
595
|
# Handle `Required` as a type (e.g. `Required[int]`)
|
|
573
596
|
elif (hasattr(_typing, 'Required') and hasattr(_typing, '_GenericAlias')
|
|
574
597
|
and isinstance(func_type, _typing._GenericAlias) # type: ignore
|
|
575
|
-
and func_type
|
|
576
|
-
):
|
|
598
|
+
and getattr(func_type, '__origin__') is _typing.Required):
|
|
577
599
|
func_type = func_type.__args__[0]
|
|
578
600
|
action.required = True
|
|
579
601
|
|
|
580
|
-
# Handle `Union` and `Optional` as a type (e.g. `Union[int, str]` and
|
|
581
|
-
# `Optional[int]`)
|
|
582
|
-
elif (hasattr(_types, 'NoneType') and hasattr(_typing, '_UnionGenericAlias')
|
|
583
|
-
and isinstance(func_type, _typing._UnionGenericAlias)): # type: ignore
|
|
584
|
-
# Optional[T] is just Union[T, NoneType]
|
|
585
|
-
# Optional
|
|
586
|
-
if (len(func_type.__args__) == 2
|
|
587
|
-
and func_type.__args__[1] is _types.NoneType):
|
|
588
|
-
action.required = False
|
|
589
|
-
func_type = func_type.__args__[0]
|
|
590
|
-
# Union
|
|
591
|
-
else:
|
|
592
|
-
func_type = func_type.__args__ # type: ignore
|
|
593
|
-
|
|
594
602
|
# Handle Enum as a type
|
|
595
603
|
elif callable(func_type) and isinstance(func_type, type) and issubclass(
|
|
596
604
|
func_type, _Enum) and action.choices is None and level == 0:
|
|
@@ -747,16 +755,15 @@ class ColorizingArgumentParser(_argparse.ArgumentParser, _ActionsContainer):
|
|
|
747
755
|
f'%(prog)s: {_gc("r")}error{_gc("lr")}:{_gc("rst")} %(message)s\n'
|
|
748
756
|
) % args
|
|
749
757
|
)
|
|
758
|
+
return NoReturn
|
|
750
759
|
|
|
751
760
|
def _get_formatter(self):
|
|
752
761
|
if hasattr(self.formatter_class, 'colors'):
|
|
753
762
|
return self.formatter_class(prog=self.prog, colors=self.colors)
|
|
754
|
-
|
|
755
|
-
return self.formatter_class(prog=self.prog)
|
|
763
|
+
return self.formatter_class(prog=self.prog)
|
|
756
764
|
|
|
757
765
|
def _get_value(self, action, arg_string):
|
|
758
|
-
"""Override _get_value to add support for types such as Union and
|
|
759
|
-
Literal."""
|
|
766
|
+
"""Override _get_value to add support for types such as Union and Literal."""
|
|
760
767
|
|
|
761
768
|
func_type = self._registry_get('type', action.type, action.type)
|
|
762
769
|
if not callable(func_type) and not isinstance(func_type, tuple):
|
|
@@ -842,13 +849,14 @@ class ColorizingArgumentParser(_argparse.ArgumentParser, _ActionsContainer):
|
|
|
842
849
|
for arg_string in arg_strings:
|
|
843
850
|
|
|
844
851
|
# for regular arguments, just add them back into the list
|
|
845
|
-
if not arg_string or arg_string[0] not in self.fromfile_prefix_chars
|
|
852
|
+
if not arg_string or arg_string[0] not in (self.fromfile_prefix_chars
|
|
853
|
+
or ''):
|
|
846
854
|
new_arg_strings.append(arg_string)
|
|
847
855
|
|
|
848
856
|
# replace arguments referencing files with the file content
|
|
849
857
|
else:
|
|
850
858
|
try:
|
|
851
|
-
with open(arg_string[1:]) as args_file:
|
|
859
|
+
with open(arg_string[1:], encoding='utf-8') as args_file:
|
|
852
860
|
arg_strings = []
|
|
853
861
|
for arg_line in args_file.read().splitlines():
|
|
854
862
|
for arg in self.convert_arg_line_to_args(arg_line):
|
|
@@ -1110,7 +1118,11 @@ class ColorizingArgumentParser(_argparse.ArgumentParser, _ActionsContainer):
|
|
|
1110
1118
|
if action.help is not _argparse.SUPPRESS
|
|
1111
1119
|
]
|
|
1112
1120
|
self.error(
|
|
1113
|
-
_gettext(
|
|
1121
|
+
_gettext(
|
|
1122
|
+
'one of the arguments ' +
|
|
1123
|
+
' '.join(name for name in names if name is not None) +
|
|
1124
|
+
' is required'
|
|
1125
|
+
)
|
|
1114
1126
|
)
|
|
1115
1127
|
|
|
1116
1128
|
for group in self._action_groups:
|
|
@@ -1127,7 +1139,11 @@ class ColorizingArgumentParser(_argparse.ArgumentParser, _ActionsContainer):
|
|
|
1127
1139
|
if action.help is not _argparse.SUPPRESS
|
|
1128
1140
|
]
|
|
1129
1141
|
self.error(
|
|
1130
|
-
_gettext(
|
|
1142
|
+
_gettext(
|
|
1143
|
+
'one of the arguments ' +
|
|
1144
|
+
' '.join(name for name in names if name is not None) +
|
|
1145
|
+
' is required'
|
|
1146
|
+
)
|
|
1131
1147
|
)
|
|
1132
1148
|
|
|
1133
1149
|
# return the updated namespace and the extra arguments
|
|
@@ -262,11 +262,10 @@ def _add_arguments(
|
|
|
262
262
|
'dest': argument.name,
|
|
263
263
|
'help': argument.help
|
|
264
264
|
}
|
|
265
|
-
if isinstance(argument.annotation, type):
|
|
266
|
-
config['type'] = argument.annotation
|
|
267
265
|
if argument.annotation == bool:
|
|
268
266
|
config['action'] = 'store_true'
|
|
269
|
-
|
|
267
|
+
elif argument.annotation:
|
|
268
|
+
config['type'] = argument.annotation
|
|
270
269
|
if argument.kind == _inspect._ParameterKind.POSITIONAL_ONLY:
|
|
271
270
|
config['required'] = True
|
|
272
271
|
if argument.kind == _inspect._ParameterKind.VAR_POSITIONAL:
|
|
@@ -23,7 +23,7 @@ from .LoggingWindow import LoggingWindow, LoggingWindowHandler
|
|
|
23
23
|
from .StreamHandler import StreamHandler, ColorizingStreamHandler
|
|
24
24
|
|
|
25
25
|
__author__ = 'CodeWriter21 (Mehrad Pooryoussof)'
|
|
26
|
-
__version__ = '2.9.
|
|
26
|
+
__version__ = '2.9.2'
|
|
27
27
|
__github__ = 'Https://GitHub.com/MPCodeWriter21/log21'
|
|
28
28
|
__all__ = [
|
|
29
29
|
'ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: log21
|
|
3
|
-
Version: 2.9.
|
|
3
|
+
Version: 2.9.2
|
|
4
4
|
Summary: A simple logging package that helps you log colorized messages in Windows console.
|
|
5
5
|
Author-email: "CodeWriter21(Mehrad Pooryoussof)" <CodeWriter21@gmail.com>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -92,9 +92,10 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
92
92
|
Changes
|
|
93
93
|
-------
|
|
94
94
|
|
|
95
|
-
### 2.9.
|
|
95
|
+
### 2.9.2
|
|
96
96
|
|
|
97
|
-
+
|
|
97
|
+
+ Added `Sequence[T]` as a supported type to the ColorizingArgumentParser.
|
|
98
|
+
+ Bug fixes.
|
|
98
99
|
|
|
99
100
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
100
101
|
|
|
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
|
|
File without changes
|