Skip to content

Commit

Permalink
Added no_color parameter to ProgressBar.
Browse files Browse the repository at this point in the history
  • Loading branch information
MPCodeWriter21 committed Apr 19, 2023
1 parent 22f1b84 commit 78c43c8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES-LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Help this project by [Donation](DONATE.md)
Changes log
-----------

### 2.4.5

Added `no_color` parameter to ProgressBar.

### 2.4.4

Some bug fixes.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ python setup.py install
Changes
-------

### 2.4.4
### 2.4.5

Some bug fixes.
Added `no_color` parameter to ProgressBar.

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

Expand Down
9 changes: 7 additions & 2 deletions log21/ProgressBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ProgressBar:

def __init__(self, *args, width: int = None, show_percentage: bool = True, prefix: str = '|', suffix: str = '|',
fill: str = '█', empty: str = ' ', format_: str = None, style: str = '%',
new_line_when_complete: bool = True, colors: dict = None, logger: '_log21.Logger' = _logger,
additional_variables: _Dict[str, _Any] = None):
new_line_when_complete: bool = True, colors: dict = None, no_color: bool = False,
logger: '_log21.Logger' = _logger, additional_variables: _Dict[str, _Any] = None):
"""
:param args: Prevents the use of positional arguments
:param width: The width of the progress bar
Expand All @@ -55,6 +55,7 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
:param style: The style that is used to format the progress bar
:param new_line_when_complete: Whether to print a new line when the progress is complete or failed
:param colors: The colors of the progress bar
:param no_color: If True, removes the colors of the progress bar
:param logger: The logger to use
:param additional_variables: Additional variables to use in the format and their default values
"""
Expand Down Expand Up @@ -83,6 +84,8 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
raise ValueError('`empty` must be a single character')
if style not in ['%', '{']:
raise ValueError('`style` must be either `%` or `{`')
if colors and no_color:
raise PermissionError('You cannot use `no_color` and `colors` parameters together!')
if additional_variables:
if not isinstance(additional_variables, dict):
raise TypeError('`additional_variables` must be a dictionary')
Expand Down Expand Up @@ -126,6 +129,8 @@ def __init__(self, *args, width: int = None, show_percentage: bool = True, prefi
if colors:
for key, value in colors.items():
self.colors[key] = value
if no_color:
self.colors = {name: '' for name in self.colors}
self.logger = logger
self.additional_variables = additional_variables
self.i = 0
Expand Down
2 changes: 1 addition & 1 deletion log21/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color

__version__ = "2.4.4"
__version__ = "2.4.5"
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = file.read()

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

setup(
name='log21',
Expand All @@ -27,8 +27,9 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows"
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X"
]
)

0 comments on commit 78c43c8

Please sign in to comment.