progress-table 3.0.0__py3-none-any.whl
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.
- progress_table/__init__.py +18 -0
- progress_table/common.py +51 -0
- progress_table/progress_table.py +1320 -0
- progress_table/styles.py +567 -0
- progress_table-3.0.0.dist-info/METADATA +25 -0
- progress_table-3.0.0.dist-info/RECORD +8 -0
- progress_table-3.0.0.dist-info/WHEEL +4 -0
- progress_table-3.0.0.dist-info/licenses/LICENSE.txt +7 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright (c) 2022-2025 Szymon Mikler
|
|
2
|
+
# Licensed under the MIT License
|
|
3
|
+
|
|
4
|
+
"""Progress Table provides an easy and pretty way to track your process.
|
|
5
|
+
|
|
6
|
+
Supported features:
|
|
7
|
+
- Styling and coloring
|
|
8
|
+
- Modifying existing cells
|
|
9
|
+
- Progress bars integrated into the table
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__license__ = "MIT"
|
|
13
|
+
__version__ = "3.0.0"
|
|
14
|
+
__author__ = "Szymon Mikler"
|
|
15
|
+
|
|
16
|
+
from progress_table.progress_table import ProgressTable, styles
|
|
17
|
+
|
|
18
|
+
__all__ = ["ProgressTable", "styles"]
|
progress_table/common.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2022-2025 Szymon Mikler
|
|
2
|
+
# Licensed under the MIT License
|
|
3
|
+
|
|
4
|
+
"""Common utilities for progress_table."""
|
|
5
|
+
|
|
6
|
+
from typing import Union
|
|
7
|
+
|
|
8
|
+
from colorama import Back, Fore, Style
|
|
9
|
+
|
|
10
|
+
ALL_COLOR_NAME = [x for x in dir(Fore) if not x.startswith("__")]
|
|
11
|
+
ALL_STYLE_NAME = [x for x in dir(Style) if not x.startswith("__")]
|
|
12
|
+
ALL_COLOR_STYLE_NAME = ALL_COLOR_NAME + ALL_STYLE_NAME
|
|
13
|
+
ALL_COLOR = [getattr(Fore, x) for x in ALL_COLOR_NAME] + [getattr(Back, x) for x in ALL_COLOR_NAME]
|
|
14
|
+
ALL_STYLE = [getattr(Style, x) for x in ALL_STYLE_NAME]
|
|
15
|
+
ALL_COLOR_STYLE = ALL_COLOR + ALL_STYLE
|
|
16
|
+
|
|
17
|
+
COLORAMA_TRANSLATE = {
|
|
18
|
+
"bold": "bright",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
NoneType = type(None)
|
|
22
|
+
ColorFormat = Union[str, tuple, list, NoneType]
|
|
23
|
+
ColorFormatTuple = (str, tuple, list, NoneType)
|
|
24
|
+
CURSOR_UP = "\033[A"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def maybe_convert_to_colorama_str(color: str) -> str:
|
|
28
|
+
"""Convert color from string to colorama string."""
|
|
29
|
+
color = COLORAMA_TRANSLATE.get(color.lower(), color)
|
|
30
|
+
|
|
31
|
+
if isinstance(color, str):
|
|
32
|
+
if hasattr(Fore, color.upper()):
|
|
33
|
+
return getattr(Fore, color.upper())
|
|
34
|
+
if hasattr(Style, color.upper()):
|
|
35
|
+
return getattr(Style, color.upper())
|
|
36
|
+
|
|
37
|
+
assert color in ALL_COLOR_STYLE, f"Color {color!r} incorrect! Available: {' '.join(ALL_COLOR_STYLE_NAME)}"
|
|
38
|
+
return color
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def maybe_convert_to_colorama(color: ColorFormat) -> str:
|
|
42
|
+
"""Fix unintuitive colorama names.
|
|
43
|
+
|
|
44
|
+
Translation layer from user-passed to colorama-compatible names.
|
|
45
|
+
"""
|
|
46
|
+
if color is None or color == "":
|
|
47
|
+
return ""
|
|
48
|
+
if isinstance(color, str):
|
|
49
|
+
color = color.split(" ")
|
|
50
|
+
results = [maybe_convert_to_colorama_str(x) for x in color]
|
|
51
|
+
return "".join(results)
|