Skip to content

Commit 78c43c8

Browse files
Added no_color parameter to ProgressBar.
1 parent 22f1b84 commit 78c43c8

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

CHANGES-LOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Help this project by [Donation](DONATE.md)
66
Changes log
77
-----------
88

9+
### 2.4.5
10+
11+
Added `no_color` parameter to ProgressBar.
12+
913
### 2.4.4
1014

1115
Some bug fixes.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ python setup.py install
5353
Changes
5454
-------
5555

56-
### 2.4.4
56+
### 2.4.5
5757

58-
Some bug fixes.
58+
Added `no_color` parameter to ProgressBar.
5959

6060
[Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
6161

log21/ProgressBar.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class ProgressBar:
4141

4242
def __init__(self, *args, width: int = None, show_percentage: bool = True, prefix: str = '|', suffix: str = '|',
4343
fill: str = '█', empty: str = ' ', format_: str = None, style: str = '%',
44-
new_line_when_complete: bool = True, colors: dict = None, logger: '_log21.Logger' = _logger,
45-
additional_variables: _Dict[str, _Any] = None):
44+
new_line_when_complete: bool = True, colors: dict = None, no_color: bool = False,
45+
logger: '_log21.Logger' = _logger, additional_variables: _Dict[str, _Any] = None):
4646
"""
4747
:param args: Prevents the use of positional arguments
4848
:param width: The width of the progress bar
@@ -55,6 +55,7 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
5555
:param style: The style that is used to format the progress bar
5656
:param new_line_when_complete: Whether to print a new line when the progress is complete or failed
5757
:param colors: The colors of the progress bar
58+
:param no_color: If True, removes the colors of the progress bar
5859
:param logger: The logger to use
5960
:param additional_variables: Additional variables to use in the format and their default values
6061
"""
@@ -83,6 +84,8 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
8384
raise ValueError('`empty` must be a single character')
8485
if style not in ['%', '{']:
8586
raise ValueError('`style` must be either `%` or `{`')
87+
if colors and no_color:
88+
raise PermissionError('You cannot use `no_color` and `colors` parameters together!')
8689
if additional_variables:
8790
if not isinstance(additional_variables, dict):
8891
raise TypeError('`additional_variables` must be a dictionary')
@@ -126,6 +129,8 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
126129
if colors:
127130
for key, value in colors.items():
128131
self.colors[key] = value
132+
if no_color:
133+
self.colors = {name: '' for name in self.colors}
129134
self.logger = logger
130135
self.additional_variables = additional_variables
131136
self.i = 0

log21/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
2323
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color
2424

25-
__version__ = "2.4.4"
25+
__version__ = "2.4.5"
2626
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
2727
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
2828
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
long_description = file.read()
88

99
DESCRIPTION = 'A simple logging package that helps you log colorized messages in Windows console.'
10-
VERSION = '2.4.4'
10+
VERSION = '2.4.5'
1111

1212
setup(
1313
name='log21',
@@ -27,8 +27,9 @@
2727
"Programming Language :: Python :: 3",
2828
"Programming Language :: Python :: 3.7",
2929
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
3031
"Operating System :: Unix",
31-
"Operating System :: MacOS :: MacOS X",
32-
"Operating System :: Microsoft :: Windows"
32+
"Operating System :: Microsoft :: Windows",
33+
"Operating System :: MacOS :: MacOS X"
3334
]
3435
)

0 commit comments

Comments
 (0)