diff --git a/CHANGES-LOG.md b/CHANGES-LOG.md index 887aac0..7b82688 100644 --- a/CHANGES-LOG.md +++ b/CHANGES-LOG.md @@ -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. diff --git a/README.md b/README.md index ae34571..02ead46 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/log21/ProgressBar.py b/log21/ProgressBar.py index 2a16265..fc5b5f9 100644 --- a/log21/ProgressBar.py +++ b/log21/ProgressBar.py @@ -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 @@ -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 """ @@ -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') @@ -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 diff --git a/log21/__init__.py b/log21/__init__.py index 67861bd..71aab41 100644 --- a/log21/__init__.py +++ b/log21/__init__.py @@ -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', diff --git a/setup.py b/setup.py index 136d0ae..54ef6a2 100644 --- a/setup.py +++ b/setup.py @@ -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', @@ -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" ] )