log21 3.3.1__tar.gz → 3.3.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-3.3.1 → log21-3.3.2}/PKG-INFO +43 -23
- {log21-3.3.1 → log21-3.3.2}/README.md +42 -22
- {log21-3.3.1 → log21-3.3.2}/pyproject.toml +1 -1
- {log21-3.3.1 → log21-3.3.2}/src/log21/__init__.py +1 -1
- {log21-3.3.1 → log21-3.3.2}/src/log21/argparse.py +2 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/_argparse.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/_module_helper.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/argumentify.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/colors.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/crash_reporter/__init__.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/crash_reporter/formatters.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/crash_reporter/reporters.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/file_handler.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/formatters.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/helper_types.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/levels.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/logger.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/logging_window.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/manager.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/pprint.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/progress_bar.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/src/log21/stream_handler.py +0 -0
- {log21-3.3.1 → log21-3.3.2}/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.2
|
|
4
4
|
Summary: A simple logging package
|
|
5
5
|
Keywords: python,log,colorize,color,logging,Python3,CodeWriter21
|
|
6
6
|
Author: CodeWriter21(Mehrad Pooryoussof)
|
|
@@ -94,45 +94,65 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
94
94
|
Changelog
|
|
95
95
|
---------
|
|
96
96
|
|
|
97
|
-
### v3.3.
|
|
97
|
+
### v3.3.2
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Handle percent signs in arguments' help text.
|
|
100
100
|
|
|
101
|
-
In the
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
In the older versions, if you had a percent sign in the help text of an argument, it
|
|
102
|
+
would cause an error when you try to show the help. This is because the argparse
|
|
103
|
+
module uses percent signs for string formatting, and it would try to format the help
|
|
104
|
+
text as a string, which would fail if there are any percent signs in it.
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
The workaround for this issue was to escape the percent signs by doubling them, but it
|
|
107
|
+
was not a good solution. Now, in v3.3.2, log21 handles percent signs in arguments' help
|
|
108
|
+
text properly, so you can use percent signs without any issues.
|
|
109
|
+
|
|
110
|
+
#### Example (works before and after v3.3.2)
|
|
107
111
|
|
|
108
112
|
```python
|
|
109
113
|
import log21
|
|
110
|
-
from log21.helper_types import FileSize
|
|
111
114
|
|
|
112
115
|
|
|
113
|
-
def
|
|
114
|
-
|
|
116
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
117
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
118
|
+
200, the percentage would be 25.00%.
|
|
119
|
+
|
|
120
|
+
:param a: The first number. (a %% b)
|
|
121
|
+
:param b: The second number. (a %% b)
|
|
122
|
+
:return: The percentage of a in b.
|
|
123
|
+
"""
|
|
124
|
+
if b == 0:
|
|
125
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
126
|
+
percentage = (a / b) * 100
|
|
127
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
128
|
+
|
|
115
129
|
|
|
116
130
|
if __name__ == "__main__":
|
|
117
|
-
log21.argumentify(
|
|
131
|
+
log21.argumentify(show_percentage)
|
|
118
132
|
```
|
|
119
133
|
|
|
120
|
-
|
|
134
|
+
#### Example (Works only after v3.3.2)
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
import log21
|
|
121
138
|
|
|
122
|
-
```shell
|
|
123
|
-
$ python test.py -m Hello
|
|
124
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
125
139
|
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
141
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
142
|
+
200, the percentage would be 25.00%.
|
|
128
143
|
|
|
129
|
-
|
|
144
|
+
:param a: The first number. (a % b)
|
|
145
|
+
:param b: The second number. (a % b)
|
|
146
|
+
:return: The percentage of a in b.
|
|
147
|
+
"""
|
|
148
|
+
if b == 0:
|
|
149
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
150
|
+
percentage = (a / b) * 100
|
|
151
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
130
152
|
|
|
131
|
-
```shell
|
|
132
|
-
$ python test.py -m Hello
|
|
133
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
134
153
|
|
|
135
|
-
|
|
154
|
+
if __name__ == "__main__":
|
|
155
|
+
log21.argumentify(show_percentage)
|
|
136
156
|
```
|
|
137
157
|
|
|
138
158
|
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
@@ -69,45 +69,65 @@ pip install git+https://github.com/MPCodeWriter21/log21
|
|
|
69
69
|
Changelog
|
|
70
70
|
---------
|
|
71
71
|
|
|
72
|
-
### v3.3.
|
|
72
|
+
### v3.3.2
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Handle percent signs in arguments' help text.
|
|
75
75
|
|
|
76
|
-
In the
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
In the older versions, if you had a percent sign in the help text of an argument, it
|
|
77
|
+
would cause an error when you try to show the help. This is because the argparse
|
|
78
|
+
module uses percent signs for string formatting, and it would try to format the help
|
|
79
|
+
text as a string, which would fail if there are any percent signs in it.
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
The workaround for this issue was to escape the percent signs by doubling them, but it
|
|
82
|
+
was not a good solution. Now, in v3.3.2, log21 handles percent signs in arguments' help
|
|
83
|
+
text properly, so you can use percent signs without any issues.
|
|
84
|
+
|
|
85
|
+
#### Example (works before and after v3.3.2)
|
|
82
86
|
|
|
83
87
|
```python
|
|
84
88
|
import log21
|
|
85
|
-
from log21.helper_types import FileSize
|
|
86
89
|
|
|
87
90
|
|
|
88
|
-
def
|
|
89
|
-
|
|
91
|
+
def show_percentage(a: float, b: float, /) -> None:
|
|
92
|
+
"""Takes two numbers and returns the percentage of a in b. E.g. if a is 50 and b is
|
|
93
|
+
200, the percentage would be 25.00%.
|
|
94
|
+
|
|
95
|
+
:param a: The first number. (a %% b)
|
|
96
|
+
:param b: The second number. (a %% b)
|
|
97
|
+
:return: The percentage of a in b.
|
|
98
|
+
"""
|
|
99
|
+
if b == 0:
|
|
100
|
+
raise log21.ArgumentError("b cannot be zero.")
|
|
101
|
+
percentage = (a / b) * 100
|
|
102
|
+
print(f"{a} is {percentage:.2f}% of {b}.")
|
|
103
|
+
|
|
90
104
|
|
|
91
105
|
if __name__ == "__main__":
|
|
92
|
-
log21.argumentify(
|
|
106
|
+
log21.argumentify(show_percentage)
|
|
93
107
|
```
|
|
94
108
|
|
|
95
|
-
|
|
109
|
+
#### Example (Works only after v3.3.2)
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import log21
|
|
96
113
|
|
|
97
|
-
```shell
|
|
98
|
-
$ python test.py -m Hello
|
|
99
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
100
114
|
|
|
101
|
-
|
|
102
|
-
|
|
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%.
|
|
103
118
|
|
|
104
|
-
|
|
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}.")
|
|
105
127
|
|
|
106
|
-
```shell
|
|
107
|
-
$ python test.py -m Hello
|
|
108
|
-
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]
|
|
109
128
|
|
|
110
|
-
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
log21.argumentify(show_percentage)
|
|
111
131
|
```
|
|
112
132
|
|
|
113
133
|
[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.2'
|
|
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]))
|
|
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
|