log21 3.3.0__tar.gz → 3.3.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.
- {log21-3.3.0 → log21-3.3.1}/PKG-INFO +23 -33
- {log21-3.3.0 → log21-3.3.1}/README.md +22 -32
- {log21-3.3.0 → log21-3.3.1}/pyproject.toml +1 -1
- {log21-3.3.0 → log21-3.3.1}/src/log21/__init__.py +1 -1
- {log21-3.3.0 → log21-3.3.1}/src/log21/argparse.py +2 -1
- {log21-3.3.0 → log21-3.3.1}/src/log21/argumentify.py +3 -3
- {log21-3.3.0 → log21-3.3.1}/src/log21/_argparse.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/_module_helper.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/colors.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/crash_reporter/__init__.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/crash_reporter/formatters.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/crash_reporter/reporters.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/file_handler.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/formatters.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/helper_types.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/levels.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/logger.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/logging_window.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/manager.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/pprint.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/progress_bar.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/stream_handler.py +0 -0
- {log21-3.3.0 → log21-3.3.1}/src/log21/tree_print.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: log21
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.1
|
|
4
4
|
Summary: A simple logging package
|
|
5
5
|
Keywords: python,log,colorize,color,logging,Python3,CodeWriter21
|
|
6
6
|
Author: CodeWriter21(Mehrad Pooryoussof)
|
|
@@ -94,55 +94,45 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
94
94
|
Changelog
|
|
95
95
|
---------
|
|
96
96
|
|
|
97
|
-
### v3.3.
|
|
97
|
+
### v3.3.1
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Get rid of `invalid NoneType value` error message.
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"21MiB", or "4.56 GB" to bytes. Can also be used to represent bytes value in more
|
|
106
|
-
human-readable formats.
|
|
107
|
-
|
|
108
|
-
For even more control you can still define Logger, Handlers, and Formatters manually.
|
|
101
|
+
In the previous versions, if you used an optional union type such as `int | float | None`
|
|
102
|
+
which ended with `None`, you'd get an error saying `invalid NoneType value` that didn't
|
|
103
|
+
make any sense to the user. The code has been updated to use the name of the last
|
|
104
|
+
non-None type for the error message in these situations.
|
|
109
105
|
|
|
110
106
|
#### Example
|
|
111
107
|
|
|
112
108
|
```python
|
|
113
|
-
from pathlib import Path
|
|
114
|
-
|
|
115
109
|
import log21
|
|
116
110
|
from log21.helper_types import FileSize
|
|
117
111
|
|
|
118
112
|
|
|
119
|
-
def main(
|
|
120
|
-
log21.info(
|
|
121
|
-
"Files that are smaller than %s or bigger than %s will be ignored.",
|
|
122
|
-
args=(min_size, max_size),
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
for file in path.iterdir():
|
|
126
|
-
if not file.is_file():
|
|
127
|
-
continue
|
|
128
|
-
if min_size <= (size := file.stat().st_size) <= max_size:
|
|
129
|
-
log21.print(
|
|
130
|
-
"`%s` is %s.",
|
|
131
|
-
args=(file, FileSize(size).humanize(binary=False, fmt="%.4f")),
|
|
132
|
-
)
|
|
133
|
-
|
|
113
|
+
def main(min_size: FileSize | None = None, max_size: FileSize | None = None) -> None:
|
|
114
|
+
log21.info("Min Size: %s, Max Size: %s", args=(min_size, max_size))
|
|
134
115
|
|
|
135
116
|
if __name__ == "__main__":
|
|
136
117
|
log21.argumentify(main)
|
|
137
118
|
```
|
|
138
119
|
|
|
139
|
-
|
|
120
|
+
Before v3.3.1:
|
|
140
121
|
|
|
141
122
|
```shell
|
|
142
|
-
$
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
123
|
+
$ python test.py -m Hello
|
|
124
|
+
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
125
|
+
|
|
126
|
+
test.py: error: argument --min-size/-m: invalid NoneType value: 'Hello'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
With v3.3.1 update:
|
|
130
|
+
|
|
131
|
+
```shell
|
|
132
|
+
$ python test.py -m Hello
|
|
133
|
+
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
134
|
+
|
|
135
|
+
test.py: error: argument --min-size/-m: invalid FileSize value: 'Hello'
|
|
146
136
|
```
|
|
147
137
|
|
|
148
138
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
@@ -69,55 +69,45 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
69
69
|
Changelog
|
|
70
70
|
---------
|
|
71
71
|
|
|
72
|
-
### v3.3.
|
|
72
|
+
### v3.3.1
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Get rid of `invalid NoneType value` error message.
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"21MiB", or "4.56 GB" to bytes. Can also be used to represent bytes value in more
|
|
81
|
-
human-readable formats.
|
|
82
|
-
|
|
83
|
-
For even more control you can still define Logger, Handlers, and Formatters manually.
|
|
76
|
+
In the previous versions, if you used an optional union type such as `int | float | None`
|
|
77
|
+
which ended with `None`, you'd get an error saying `invalid NoneType value` that didn't
|
|
78
|
+
make any sense to the user. The code has been updated to use the name of the last
|
|
79
|
+
non-None type for the error message in these situations.
|
|
84
80
|
|
|
85
81
|
#### Example
|
|
86
82
|
|
|
87
83
|
```python
|
|
88
|
-
from pathlib import Path
|
|
89
|
-
|
|
90
84
|
import log21
|
|
91
85
|
from log21.helper_types import FileSize
|
|
92
86
|
|
|
93
87
|
|
|
94
|
-
def main(
|
|
95
|
-
log21.info(
|
|
96
|
-
"Files that are smaller than %s or bigger than %s will be ignored.",
|
|
97
|
-
args=(min_size, max_size),
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
for file in path.iterdir():
|
|
101
|
-
if not file.is_file():
|
|
102
|
-
continue
|
|
103
|
-
if min_size <= (size := file.stat().st_size) <= max_size:
|
|
104
|
-
log21.print(
|
|
105
|
-
"`%s` is %s.",
|
|
106
|
-
args=(file, FileSize(size).humanize(binary=False, fmt="%.4f")),
|
|
107
|
-
)
|
|
108
|
-
|
|
88
|
+
def main(min_size: FileSize | None = None, max_size: FileSize | None = None) -> None:
|
|
89
|
+
log21.info("Min Size: %s, Max Size: %s", args=(min_size, max_size))
|
|
109
90
|
|
|
110
91
|
if __name__ == "__main__":
|
|
111
92
|
log21.argumentify(main)
|
|
112
93
|
```
|
|
113
94
|
|
|
114
|
-
|
|
95
|
+
Before v3.3.1:
|
|
115
96
|
|
|
116
97
|
```shell
|
|
117
|
-
$
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
98
|
+
$ python test.py -m Hello
|
|
99
|
+
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
100
|
+
|
|
101
|
+
test.py: error: argument --min-size/-m: invalid NoneType value: 'Hello'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
With v3.3.1 update:
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
$ python test.py -m Hello
|
|
108
|
+
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
109
|
+
|
|
110
|
+
test.py: error: argument --min-size/-m: invalid FileSize value: 'Hello'
|
|
121
111
|
```
|
|
122
112
|
|
|
123
113
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
@@ -33,7 +33,7 @@ from .stream_handler import StreamHandler, ColorizingStreamHandler
|
|
|
33
33
|
# yapf: enable
|
|
34
34
|
|
|
35
35
|
__author__ = 'CodeWriter21 (Mehrad Pooryoussof)'
|
|
36
|
-
__version__ = '3.3.
|
|
36
|
+
__version__ = '3.3.1'
|
|
37
37
|
__github__ = 'https://GitHub.com/MPCodeWriter21/log21'
|
|
38
38
|
__all__ = [
|
|
39
39
|
'ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter',
|
|
@@ -784,7 +784,8 @@ class ColorizingArgumentParser(_argparse.ArgumentParser, _ActionsContainer):
|
|
|
784
784
|
else:
|
|
785
785
|
exception = ValueError()
|
|
786
786
|
for type_ in func_type:
|
|
787
|
-
|
|
787
|
+
if type_ is not type(None):
|
|
788
|
+
name = getattr(type_, '__name__', repr(type_))
|
|
788
789
|
try:
|
|
789
790
|
result = type_(arg_string)
|
|
790
791
|
break
|
|
@@ -451,7 +451,7 @@ def _argumentify(functions: _Dict[str, Callable]) -> None:
|
|
|
451
451
|
args = []
|
|
452
452
|
kwargs = {}
|
|
453
453
|
info = None
|
|
454
|
-
for
|
|
454
|
+
for _name, (function, info) in functions_info.items(): # noqa: B007
|
|
455
455
|
if function == cli_args.func:
|
|
456
456
|
break
|
|
457
457
|
else:
|
|
@@ -475,7 +475,7 @@ def _argumentify(functions: _Dict[str, Callable]) -> None:
|
|
|
475
475
|
|
|
476
476
|
def argumentify(
|
|
477
477
|
entry_point: _Union[Callable, _List[Callable], _Dict[str, Callable]]
|
|
478
|
-
) ->
|
|
478
|
+
) -> _Union[Callable, _List[Callable], _Dict[str, Callable]]:
|
|
479
479
|
"""This function argumentifies one or more functions as the entry point of the
|
|
480
480
|
script.
|
|
481
481
|
|
|
@@ -493,7 +493,7 @@ def argumentify(
|
|
|
493
493
|
12 if __name__ == '__main__':
|
|
494
494
|
13 argumentify(main)
|
|
495
495
|
|
|
496
|
-
$ python argumentified.py Ahmad
|
|
496
|
+
$ python argumentified.py Ahmad Mohammadi --age 20
|
|
497
497
|
Ahmad Ahmadi is 20 years old.
|
|
498
498
|
$ python argumentified.py Mehrad Pooryoussof
|
|
499
499
|
Mehrad Pooryoussof is not yet born.
|
|
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
|