log21 3.3.1__tar.gz → 3.3.3__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.1 → log21-3.3.3}/PKG-INFO +62 -43
- log21-3.3.3/README.md +166 -0
- {log21-3.3.1 → log21-3.3.3}/pyproject.toml +5 -4
- {log21-3.3.1 → log21-3.3.3}/src/log21/__init__.py +1 -1
- {log21-3.3.1 → log21-3.3.3}/src/log21/argparse.py +18 -2
- log21-3.3.1/README.md +0 -148
- {log21-3.3.1 → log21-3.3.3}/src/log21/_argparse.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/_module_helper.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/argumentify.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/colors.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/crash_reporter/__init__.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/crash_reporter/formatters.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/crash_reporter/reporters.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/file_handler.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/formatters.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/helper_types.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/levels.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/logger.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/logging_window.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/manager.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/pprint.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/progress_bar.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/src/log21/stream_handler.py +0 -0
- {log21-3.3.1 → log21-3.3.3}/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.3
|
|
4
4
|
Summary: A simple logging package
|
|
5
5
|
Keywords: python,log,colorize,color,logging,Python3,CodeWriter21
|
|
6
6
|
Author: CodeWriter21(Mehrad Pooryoussof)
|
|
@@ -18,19 +18,18 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
18
18
|
Requires-Dist: webcolors
|
|
19
19
|
Requires-Dist: docstring-parser
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
|
-
Project-URL: Donations, https://
|
|
22
|
-
Project-URL: Homepage, https://
|
|
23
|
-
Project-URL:
|
|
21
|
+
Project-URL: Donations, https://gitlab.com/CodeWriter21/log21/-/blob/master/DONATE.md
|
|
22
|
+
Project-URL: Homepage, https://gitlab.com/CodeWriter21/log21
|
|
23
|
+
Project-URL: Repository, https://gitlab.com/CodeWriter21/log21
|
|
24
|
+
Project-URL: Source, https://gitlab.com/CodeWriter21/log21
|
|
24
25
|
Description-Content-Type: text/markdown
|
|
25
26
|
|
|
26
27
|
log21
|
|
27
28
|
=====
|
|
28
29
|
|
|
29
30
|

|
|
30
|
-

|
|
33
|
-
[](https://www.codefactor.io/repository/github/mpcodewriter21/log21)
|
|
31
|
+
[](https://gitlab.com/CodeWriter21/log21/-/commits/master)
|
|
32
|
+
[](https://gitlab.com/CodeWriter21/log21)
|
|
34
33
|
|
|
35
34
|
A simple logging package that helps you log colorized messages in Windows console and
|
|
36
35
|
other operating systems.
|
|
@@ -59,11 +58,11 @@ Features
|
|
|
59
58
|
reporter functions and use them instead!
|
|
60
59
|
+ Argumentify : You can use the argumentify feature to decrease the number of lines you
|
|
61
60
|
need to write to parse command-line arguments. It's colored by the way!
|
|
62
|
-
+ Any idea? Feel free to [open an issue](https://
|
|
63
|
-
or submit a
|
|
61
|
+
+ Any idea? Feel free to [open an issue](https://gitlab.com/CodeWriter21/log21/-/issues)
|
|
62
|
+
or submit a merge request.
|
|
64
63
|
|
|
65
|
-
](https://gitlab.com/CodeWriter21/log21/-/issues)
|
|
65
|
+
[](https://gitlab.com/CodeWriter21/log21/-/graphs/master)
|
|
67
66
|
|
|
68
67
|
Installation
|
|
69
68
|
------------
|
|
@@ -79,7 +78,7 @@ Then you can install log21 using pip module:
|
|
|
79
78
|
python -m pip install log21 -U
|
|
80
79
|
```
|
|
81
80
|
|
|
82
|
-
Or you can clone [the repository](https://
|
|
81
|
+
Or you can clone [the repository](https://gitlab.com/CodeWriter21/log21) and run:
|
|
83
82
|
|
|
84
83
|
```bash
|
|
85
84
|
pip install .
|
|
@@ -88,72 +87,92 @@ pip install .
|
|
|
88
87
|
Or let the pip get it using git:
|
|
89
88
|
|
|
90
89
|
```bash
|
|
91
|
-
pip install git+https://
|
|
90
|
+
pip install git+https://gitlab.com/CodeWriter21/log21.git
|
|
92
91
|
```
|
|
93
92
|
|
|
94
93
|
Changelog
|
|
95
94
|
---------
|
|
96
95
|
|
|
97
|
-
### v3.3.
|
|
96
|
+
### v3.3.2
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
Handle percent signs in arguments' help text.
|
|
100
99
|
|
|
101
|
-
In the
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
In the older versions, if you had a percent sign in the help text of an argument, it
|
|
101
|
+
would cause an error when you try to show the help. This is because the argparse
|
|
102
|
+
module uses percent signs for string formatting, and it would try to format the help
|
|
103
|
+
text as a string, which would fail if there are any percent signs in it.
|
|
105
104
|
|
|
106
|
-
|
|
105
|
+
The workaround for this issue was to escape the percent signs by doubling them, but it
|
|
106
|
+
was not a good solution. Now, in v3.3.2, log21 handles percent signs in arguments' help
|
|
107
|
+
text properly, so you can use percent signs without any issues.
|
|
108
|
+
|
|
109
|
+
#### Example (works before and after v3.3.2)
|
|
107
110
|
|
|
108
111
|
```python
|
|
109
112
|
import log21
|
|
110
|
-
from log21.helper_types import FileSize
|
|
111
113
|
|
|
112
114
|
|
|
113
|
-
def
|
|
114
|
-
|
|
115
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
116
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
117
|
+
200, the percentage would be 25.00%.
|
|
118
|
+
|
|
119
|
+
:param a: The first number. (a %% b)
|
|
120
|
+
:param b: The second number. (a %% b)
|
|
121
|
+
:return: The percentage of a in b.
|
|
122
|
+
"""
|
|
123
|
+
if b == 0:
|
|
124
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
125
|
+
percentage = (a / b) * 100
|
|
126
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
127
|
+
|
|
115
128
|
|
|
116
129
|
if __name__ == "__main__":
|
|
117
|
-
log21.argumentify(
|
|
130
|
+
log21.argumentify(show_percentage)
|
|
118
131
|
```
|
|
119
132
|
|
|
120
|
-
|
|
133
|
+
#### Example (Works only after v3.3.2)
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import log21
|
|
121
137
|
|
|
122
|
-
```shell
|
|
123
|
-
$ python test.py -m Hello
|
|
124
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
125
138
|
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
140
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
141
|
+
200, the percentage would be 25.00%.
|
|
128
142
|
|
|
129
|
-
|
|
143
|
+
:param a: The first number. (a % b)
|
|
144
|
+
:param b: The second number. (a % b)
|
|
145
|
+
:return: The percentage of a in b.
|
|
146
|
+
"""
|
|
147
|
+
if b == 0:
|
|
148
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
149
|
+
percentage = (a / b) * 100
|
|
150
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
130
151
|
|
|
131
|
-
```shell
|
|
132
|
-
$ python test.py -m Hello
|
|
133
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
134
152
|
|
|
135
|
-
|
|
153
|
+
if __name__ == "__main__":
|
|
154
|
+
log21.argumentify(show_percentage)
|
|
136
155
|
```
|
|
137
156
|
|
|
138
|
-
[Full CHANGELOG](https://
|
|
157
|
+
[Full CHANGELOG](https://gitlab.com/CodeWriter21/log21/-/blob/master/CHANGELOG.md)
|
|
139
158
|
|
|
140
159
|
Usage Examples
|
|
141
160
|
---------------
|
|
142
161
|
|
|
143
|
-
See [EXAMPLES.md](https://
|
|
162
|
+
See [EXAMPLES.md](https://gitlab.com/CodeWriter21/log21/-/blob/master/EXAMPLES.md)
|
|
144
163
|
|
|
145
164
|
About
|
|
146
165
|
-----
|
|
147
166
|
|
|
148
167
|
Author: CodeWriter21 (Mehrad Pooryoussof)
|
|
149
168
|
|
|
150
|
-
|
|
169
|
+
GitLab: [CodeWriter21](https://gitlab.com/CodeWriter21)
|
|
151
170
|
|
|
152
171
|
Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
153
172
|
|
|
154
173
|
### License
|
|
155
174
|
|
|
156
|
-
](https://gitlab.com/CodeWriter21/log21/-/blob/master/LICENSE.txt)
|
|
157
176
|
|
|
158
177
|
[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
159
178
|
|
|
@@ -161,10 +180,10 @@ Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
|
161
180
|
|
|
162
181
|
In order to support this project you can donate some crypto of your choice 8D
|
|
163
182
|
|
|
164
|
-
[Donate Addresses](https://
|
|
183
|
+
[Donate Addresses](https://gitlab.com/CodeWriter21/log21/-/blob/master/DONATE.md)
|
|
165
184
|
|
|
166
|
-
Or if you can't, give [this project](https://
|
|
167
|
-
|
|
185
|
+
Or if you can't, give [this project](https://gitlab.com/CodeWriter21/log21) a star on
|
|
186
|
+
GitLab :)
|
|
168
187
|
|
|
169
188
|
References
|
|
170
189
|
----------
|
log21-3.3.3/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
log21
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
[](https://gitlab.com/CodeWriter21/log21/-/commits/master)
|
|
6
|
+
[](https://gitlab.com/CodeWriter21/log21)
|
|
7
|
+
|
|
8
|
+
A simple logging package that helps you log colorized messages in Windows console and
|
|
9
|
+
other operating systems.
|
|
10
|
+
|
|
11
|
+
Features
|
|
12
|
+
--------
|
|
13
|
+
|
|
14
|
+
+ Colors : The main reason for this package was to log text in the Windows console with
|
|
15
|
+
the support of ANSI colors.
|
|
16
|
+
+ Argument parsing : log21's argument parser can be used like python's argparse, but it
|
|
17
|
+
also colorizes the output.
|
|
18
|
+
+ Logging : A similar logger to logging. Logger but with colorized output and other
|
|
19
|
+
options such as levelname modifications. It can also decolorize the output if you want
|
|
20
|
+
to log into a file.
|
|
21
|
+
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module?
|
|
22
|
+
log21's pretty printer can do that.
|
|
23
|
+
+ Tree printing : You can pass a dict or list to `log21.tree_print` function, and it
|
|
24
|
+
will print it in a tree-like structure. It's also colorized XD.
|
|
25
|
+
+ ProgressBar : log21's progress bar can be used to show progress of a process in a
|
|
26
|
+
beautiful way.
|
|
27
|
+
+ LoggingWindow : Helps you to log messages and debug your code in a window other than
|
|
28
|
+
the console.
|
|
29
|
+
+ CrashReporter : log21's crash reporter can be used to report crashes in different
|
|
30
|
+
ways. You can use it to log crashes to console or files or use it to receive crash
|
|
31
|
+
reports of your program through email. And you can also define your own crash
|
|
32
|
+
reporter functions and use them instead!
|
|
33
|
+
+ Argumentify : You can use the argumentify feature to decrease the number of lines you
|
|
34
|
+
need to write to parse command-line arguments. It's colored by the way!
|
|
35
|
+
+ Any idea? Feel free to [open an issue](https://gitlab.com/CodeWriter21/log21/-/issues)
|
|
36
|
+
or submit a merge request.
|
|
37
|
+
|
|
38
|
+
[](https://gitlab.com/CodeWriter21/log21/-/issues)
|
|
39
|
+
[](https://gitlab.com/CodeWriter21/log21/-/graphs/master)
|
|
40
|
+
|
|
41
|
+
Installation
|
|
42
|
+
------------
|
|
43
|
+
|
|
44
|
+
Well, this is a python package so the first thing you need is python.
|
|
45
|
+
|
|
46
|
+
If you don't have python installed, please visit [Python.org](https://python.org) and
|
|
47
|
+
install the latest version of python.
|
|
48
|
+
|
|
49
|
+
Then you can install log21 using pip module:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python -m pip install log21 -U
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or you can clone [the repository](https://gitlab.com/CodeWriter21/log21) and run:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or let the pip get it using git:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install git+https://gitlab.com/CodeWriter21/log21.git
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Changelog
|
|
68
|
+
---------
|
|
69
|
+
|
|
70
|
+
### v3.3.2
|
|
71
|
+
|
|
72
|
+
Handle percent signs in arguments' help text.
|
|
73
|
+
|
|
74
|
+
In the older versions, if you had a percent sign in the help text of an argument, it
|
|
75
|
+
would cause an error when you try to show the help. This is because the argparse
|
|
76
|
+
module uses percent signs for string formatting, and it would try to format the help
|
|
77
|
+
text as a string, which would fail if there are any percent signs in it.
|
|
78
|
+
|
|
79
|
+
The workaround for this issue was to escape the percent signs by doubling them, but it
|
|
80
|
+
was not a good solution. Now, in v3.3.2, log21 handles percent signs in arguments' help
|
|
81
|
+
text properly, so you can use percent signs without any issues.
|
|
82
|
+
|
|
83
|
+
#### Example (works before and after v3.3.2)
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import log21
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
90
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
91
|
+
200, the percentage would be 25.00%.
|
|
92
|
+
|
|
93
|
+
:param a: The first number. (a %% b)
|
|
94
|
+
:param b: The second number. (a %% b)
|
|
95
|
+
:return: The percentage of a in b.
|
|
96
|
+
"""
|
|
97
|
+
if b == 0:
|
|
98
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
99
|
+
percentage = (a / b) * 100
|
|
100
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
log21.argumentify(show_percentage)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Example (Works only after v3.3.2)
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import log21
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
114
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
115
|
+
200, the percentage would be 25.00%.
|
|
116
|
+
|
|
117
|
+
:param a: The first number. (a % b)
|
|
118
|
+
:param b: The second number. (a % b)
|
|
119
|
+
:return: The percentage of a in b.
|
|
120
|
+
"""
|
|
121
|
+
if b == 0:
|
|
122
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
123
|
+
percentage = (a / b) * 100
|
|
124
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if __name__ == "__main__":
|
|
128
|
+
log21.argumentify(show_percentage)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
[Full CHANGELOG](https://gitlab.com/CodeWriter21/log21/-/blob/master/CHANGELOG.md)
|
|
132
|
+
|
|
133
|
+
Usage Examples
|
|
134
|
+
---------------
|
|
135
|
+
|
|
136
|
+
See [EXAMPLES.md](https://gitlab.com/CodeWriter21/log21/-/blob/master/EXAMPLES.md)
|
|
137
|
+
|
|
138
|
+
About
|
|
139
|
+
-----
|
|
140
|
+
|
|
141
|
+
Author: CodeWriter21 (Mehrad Pooryoussof)
|
|
142
|
+
|
|
143
|
+
GitLab: [CodeWriter21](https://gitlab.com/CodeWriter21)
|
|
144
|
+
|
|
145
|
+
Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
146
|
+
|
|
147
|
+
### License
|
|
148
|
+
|
|
149
|
+
[](https://gitlab.com/CodeWriter21/log21/-/blob/master/LICENSE.txt)
|
|
150
|
+
|
|
151
|
+
[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
152
|
+
|
|
153
|
+
### Donate
|
|
154
|
+
|
|
155
|
+
In order to support this project you can donate some crypto of your choice 8D
|
|
156
|
+
|
|
157
|
+
[Donate Addresses](https://gitlab.com/CodeWriter21/log21/-/blob/master/DONATE.md)
|
|
158
|
+
|
|
159
|
+
Or if you can't, give [this project](https://gitlab.com/CodeWriter21/log21) a star on
|
|
160
|
+
GitLab :)
|
|
161
|
+
|
|
162
|
+
References
|
|
163
|
+
----------
|
|
164
|
+
|
|
165
|
+
+ ANSI Color Codes (Wikipedia):
|
|
166
|
+
[https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
|
@@ -23,16 +23,17 @@ dependencies = [
|
|
|
23
23
|
"webcolors",
|
|
24
24
|
"docstring-parser"
|
|
25
25
|
]
|
|
26
|
-
version = "3.3.
|
|
26
|
+
version = "3.3.3"
|
|
27
27
|
|
|
28
28
|
[build-system]
|
|
29
29
|
requires = ["uv_build>=0.8.15,<0.9.0"]
|
|
30
30
|
build-backend = "uv_build"
|
|
31
31
|
|
|
32
32
|
[project.urls]
|
|
33
|
-
Homepage = "https://
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
Homepage = "https://gitlab.com/CodeWriter21/log21"
|
|
34
|
+
Repository = "https://gitlab.com/CodeWriter21/log21"
|
|
35
|
+
Donations = "https://gitlab.com/CodeWriter21/log21/-/blob/master/DONATE.md"
|
|
36
|
+
Source = "https://gitlab.com/CodeWriter21/log21"
|
|
36
37
|
|
|
37
38
|
[tool.yapf]
|
|
38
39
|
column_limit = 88
|
|
@@ -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.3'
|
|
37
37
|
__github__ = 'https://GitHub.com/MPCodeWriter21/log21'
|
|
38
38
|
__all__ = [
|
|
39
39
|
'ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter',
|
|
@@ -171,8 +171,10 @@ class ColorizingHelpFormatter(_argparse.HelpFormatter):
|
|
|
171
171
|
# collect the pieces of the action help
|
|
172
172
|
parts = [action_header]
|
|
173
173
|
|
|
174
|
+
percent_pattern = _re.compile(r'([%]{2}|[%])')
|
|
174
175
|
# if there was help for the action, add lines of help text
|
|
175
176
|
if action.help:
|
|
177
|
+
action.help = percent_pattern.sub("%%", action.help)
|
|
176
178
|
help_text = _gc(self.colors['help']) + self._expand_help(action)
|
|
177
179
|
help_lines = self._split_lines(help_text, help_width)
|
|
178
180
|
parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
|
|
@@ -573,9 +575,23 @@ class _ActionsContainer(_argparse._ActionsContainer): # novm
|
|
|
573
575
|
and not isinstance(func_type, (_types.UnionType, tuple))):
|
|
574
576
|
raise ValueError(f'{func_type} is not callable; level={level}')
|
|
575
577
|
|
|
576
|
-
# Handle `UnionType` as a type (e.g. `int|str`)
|
|
578
|
+
# Handle `UnionType` as a type (e.g. `int|str` and `int|None`)
|
|
577
579
|
if hasattr(_types, 'UnionType') and isinstance(func_type, _types.UnionType):
|
|
578
|
-
|
|
580
|
+
# `X | None` is the PEP 604 spelling of `Optional[X]` and must
|
|
581
|
+
# behave identically: mark the action as not required and unwrap
|
|
582
|
+
# to `X`. `types.UnionType` exposes `__args__` just like
|
|
583
|
+
# `typing.Optional`, e.g. `(str | None).__args__ == (str, NoneType)`.
|
|
584
|
+
args = func_type.__args__ # type: ignore
|
|
585
|
+
if (hasattr(_types, 'NoneType') and len(args) == 2
|
|
586
|
+
and args[1] is _types.NoneType):
|
|
587
|
+
action.required = False
|
|
588
|
+
func_type = args[0]
|
|
589
|
+
elif (hasattr(_types, 'NoneType') and len(args) == 2
|
|
590
|
+
and args[0] is _types.NoneType):
|
|
591
|
+
action.required = False
|
|
592
|
+
func_type = args[1]
|
|
593
|
+
else:
|
|
594
|
+
func_type = args
|
|
579
595
|
|
|
580
596
|
# Handle `Literal` as a type (e.g. `Literal[1, 2, 3]`)
|
|
581
597
|
elif (hasattr(_typing, '_LiteralGenericAlias')
|
log21-3.3.1/README.md
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
log21
|
|
2
|
-
=====
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
[](https://www.codefactor.io/repository/github/mpcodewriter21/log21)
|
|
9
|
-
|
|
10
|
-
A simple logging package that helps you log colorized messages in Windows console and
|
|
11
|
-
other operating systems.
|
|
12
|
-
|
|
13
|
-
Features
|
|
14
|
-
--------
|
|
15
|
-
|
|
16
|
-
+ Colors : The main reason for this package was to log text in the Windows console with
|
|
17
|
-
the support of ANSI colors.
|
|
18
|
-
+ Argument parsing : log21's argument parser can be used like python's argparse, but it
|
|
19
|
-
also colorizes the output.
|
|
20
|
-
+ Logging : A similar logger to logging. Logger but with colorized output and other
|
|
21
|
-
options such as levelname modifications. It can also decolorize the output if you want
|
|
22
|
-
to log into a file.
|
|
23
|
-
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module?
|
|
24
|
-
log21's pretty printer can do that.
|
|
25
|
-
+ Tree printing : You can pass a dict or list to `log21.tree_print` function, and it
|
|
26
|
-
will print it in a tree-like structure. It's also colorized XD.
|
|
27
|
-
+ ProgressBar : log21's progress bar can be used to show progress of a process in a
|
|
28
|
-
beautiful way.
|
|
29
|
-
+ LoggingWindow : Helps you to log messages and debug your code in a window other than
|
|
30
|
-
the console.
|
|
31
|
-
+ CrashReporter : log21's crash reporter can be used to report crashes in different
|
|
32
|
-
ways. You can use it to log crashes to console or files or use it to receive crash
|
|
33
|
-
reports of your program through email. And you can also define your own crash
|
|
34
|
-
reporter functions and use them instead!
|
|
35
|
-
+ Argumentify : You can use the argumentify feature to decrease the number of lines you
|
|
36
|
-
need to write to parse command-line arguments. It's colored by the way!
|
|
37
|
-
+ Any idea? Feel free to [open an issue](https://github.com/MPCodeWriter21/log21/issues)
|
|
38
|
-
or submit a pull request.
|
|
39
|
-
|
|
40
|
-

|
|
41
|
-

|
|
42
|
-
|
|
43
|
-
Installation
|
|
44
|
-
------------
|
|
45
|
-
|
|
46
|
-
Well, this is a python package so the first thing you need is python.
|
|
47
|
-
|
|
48
|
-
If you don't have python installed, please visit [Python.org](https://python.org) and
|
|
49
|
-
install the latest version of python.
|
|
50
|
-
|
|
51
|
-
Then you can install log21 using pip module:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
python -m pip install log21 -U
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Or you can clone [the repository](https://github.com/MPCodeWriter21/log21) and run:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pip install .
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Or let the pip get it using git:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
pip install git+https://github.com/MPCodeWriter21/log21
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Changelog
|
|
70
|
-
---------
|
|
71
|
-
|
|
72
|
-
### v3.3.1
|
|
73
|
-
|
|
74
|
-
Get rid of `invalid NoneType value` error message.
|
|
75
|
-
|
|
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.
|
|
80
|
-
|
|
81
|
-
#### Example
|
|
82
|
-
|
|
83
|
-
```python
|
|
84
|
-
import log21
|
|
85
|
-
from log21.helper_types import FileSize
|
|
86
|
-
|
|
87
|
-
|
|
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))
|
|
90
|
-
|
|
91
|
-
if __name__ == "__main__":
|
|
92
|
-
log21.argumentify(main)
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Before v3.3.1:
|
|
96
|
-
|
|
97
|
-
```shell
|
|
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'
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
114
|
-
|
|
115
|
-
Usage Examples
|
|
116
|
-
---------------
|
|
117
|
-
|
|
118
|
-
See [EXAMPLES.md](https://github.com/MPCodeWriter21/log21/blob/master/EXAMPLES.md)
|
|
119
|
-
|
|
120
|
-
About
|
|
121
|
-
-----
|
|
122
|
-
|
|
123
|
-
Author: CodeWriter21 (Mehrad Pooryoussof)
|
|
124
|
-
|
|
125
|
-
GitHub: [MPCodeWriter21](https://github.com/MPCodeWriter21)
|
|
126
|
-
|
|
127
|
-
Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
128
|
-
|
|
129
|
-
### License
|
|
130
|
-
|
|
131
|
-

|
|
132
|
-
|
|
133
|
-
[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
134
|
-
|
|
135
|
-
### Donate
|
|
136
|
-
|
|
137
|
-
In order to support this project you can donate some crypto of your choice 8D
|
|
138
|
-
|
|
139
|
-
[Donate Addresses](https://github.com/MPCodeWriter21/log21/blob/master/DONATE.md)
|
|
140
|
-
|
|
141
|
-
Or if you can't, give [this project](https://github.com/MPCodeWriter21/log21) a star on
|
|
142
|
-
GitHub :)
|
|
143
|
-
|
|
144
|
-
References
|
|
145
|
-
----------
|
|
146
|
-
|
|
147
|
-
+ ANSI Color Codes (Wikipedia):
|
|
148
|
-
[https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
|
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
|