progress-table 2.1.0__tar.gz → 2.2.1__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.
- {progress-table-2.1.0 → progress-table-2.2.1}/PKG-INFO +1 -1
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/__init__.py +1 -1
- progress-table-2.2.1/progress_table/v1/common.py +47 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v1/progress_table.py +62 -77
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v1/styles.py +91 -43
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/PKG-INFO +1 -1
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/SOURCES.txt +1 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/LICENSE.txt +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/README.md +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v0/__init__.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v0/progress_table.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v0/symbols.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table/v1/__init__.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/PKG-INFO.sync-conflict-20240314-015933-NXTV2IO +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/dependency_links.txt +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/requires.txt +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/progress_table.egg-info/top_level.txt +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/pyproject.toml +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/setup.cfg +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/setup.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/tests/test_docs_automated.py +0 -0
- {progress-table-2.1.0 → progress-table-2.2.1}/tests/test_examples_automated.py +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright (c) 2022-2024 Szymon Mikler
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Union
|
|
6
|
+
|
|
7
|
+
from colorama import Back, Fore, Style
|
|
8
|
+
|
|
9
|
+
ALL_COLOR_NAME = [x for x in dir(Fore) if not x.startswith("__")]
|
|
10
|
+
ALL_STYLE_NAME = [x for x in dir(Style) if not x.startswith("__")]
|
|
11
|
+
ALL_COLOR_STYLE_NAME = ALL_COLOR_NAME + ALL_STYLE_NAME
|
|
12
|
+
ALL_COLOR = [getattr(Fore, x) for x in ALL_COLOR_NAME] + [getattr(Back, x) for x in ALL_COLOR_NAME]
|
|
13
|
+
ALL_STYLE = [getattr(Style, x) for x in ALL_STYLE_NAME]
|
|
14
|
+
ALL_COLOR_STYLE = ALL_COLOR + ALL_STYLE
|
|
15
|
+
|
|
16
|
+
COLORAMA_TRANSLATE = {
|
|
17
|
+
"bold": "bright",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
NoneType = type(None)
|
|
21
|
+
ColorFormat = Union[str, tuple, list, NoneType]
|
|
22
|
+
ColorFormatTuple = (str, tuple, list, NoneType)
|
|
23
|
+
|
|
24
|
+
CURSOR_UP = "\033[A"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def maybe_convert_to_colorama_str(color: str) -> str:
|
|
28
|
+
# Translation layer to fix unintuitive colorama names
|
|
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
|
+
if color is None or color == "":
|
|
43
|
+
return ""
|
|
44
|
+
if isinstance(color, str):
|
|
45
|
+
color = color.split(" ")
|
|
46
|
+
results = [maybe_convert_to_colorama_str(x) for x in color]
|
|
47
|
+
return "".join(results)
|
|
@@ -12,30 +12,13 @@ import sys
|
|
|
12
12
|
import time
|
|
13
13
|
from dataclasses import dataclass
|
|
14
14
|
from threading import Thread
|
|
15
|
-
from typing import Any, Callable, Iterable, Sized, Type
|
|
15
|
+
from typing import Any, Callable, Iterable, Sized, Type
|
|
16
16
|
|
|
17
|
-
from colorama import
|
|
17
|
+
from colorama import Style
|
|
18
18
|
|
|
19
|
-
from . import styles
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ALL_STYLE_NAME = [x for x in dir(Style) if not x.startswith("__")]
|
|
23
|
-
ALL_COLOR_STYLE_NAME = ALL_COLOR_NAME + ALL_STYLE_NAME
|
|
24
|
-
|
|
25
|
-
ALL_COLOR = [getattr(Fore, x) for x in ALL_COLOR_NAME] + [getattr(Back, x) for x in ALL_COLOR_NAME]
|
|
26
|
-
ALL_STYLE = [getattr(Style, x) for x in ALL_STYLE_NAME]
|
|
27
|
-
ALL_COLOR_STYLE = ALL_COLOR + ALL_STYLE
|
|
28
|
-
|
|
29
|
-
COLORAMA_TRANSLATE = {
|
|
30
|
-
"bold": "bright",
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
NoneType = type(None)
|
|
34
|
-
ColorFormat = Union[str, tuple, list, NoneType]
|
|
35
|
-
ColorFormatTuple = (str, tuple, list, NoneType)
|
|
36
|
-
|
|
37
|
-
EPS = 1e-9
|
|
38
|
-
CURSOR_UP = "\033[A"
|
|
19
|
+
from progress_table.v1 import styles
|
|
20
|
+
from progress_table.v1.common import CURSOR_UP, ColorFormat, ColorFormatTuple, maybe_convert_to_colorama
|
|
21
|
+
from progress_table.v1.styles import parse_pbar_style
|
|
39
22
|
|
|
40
23
|
# Flags that indicate if the warning was already triggered
|
|
41
24
|
WARNED_PBAR_HIDDEN = False
|
|
@@ -91,29 +74,6 @@ def get_aggregate_fn(aggregate: None | str | Callable):
|
|
|
91
74
|
raise ValueError(f"Unknown aggregate type: {type(aggregate)}")
|
|
92
75
|
|
|
93
76
|
|
|
94
|
-
def maybe_convert_to_colorama_str(color: str) -> str:
|
|
95
|
-
# Translation layer to fix unintuitive colorama names
|
|
96
|
-
color = COLORAMA_TRANSLATE.get(color.lower(), color)
|
|
97
|
-
|
|
98
|
-
if isinstance(color, str):
|
|
99
|
-
if hasattr(Fore, color.upper()):
|
|
100
|
-
return getattr(Fore, color.upper())
|
|
101
|
-
if hasattr(Style, color.upper()):
|
|
102
|
-
return getattr(Style, color.upper())
|
|
103
|
-
|
|
104
|
-
assert color in ALL_COLOR_STYLE, f"Color {color!r} incorrect! Available: {' '.join(ALL_COLOR_STYLE_NAME)}"
|
|
105
|
-
return color
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def maybe_convert_to_colorama(color: ColorFormat) -> str:
|
|
109
|
-
if color is None or color == "":
|
|
110
|
-
return ""
|
|
111
|
-
if isinstance(color, str):
|
|
112
|
-
color = color.split(" ")
|
|
113
|
-
results = [maybe_convert_to_colorama_str(x) for x in color]
|
|
114
|
-
return "".join(results)
|
|
115
|
-
|
|
116
|
-
|
|
117
77
|
def get_default_format_func(decimal_places):
|
|
118
78
|
def fmt(x) -> str:
|
|
119
79
|
if isinstance(x, int):
|
|
@@ -158,14 +118,12 @@ class ProgressTableV1:
|
|
|
158
118
|
pbar_show_percents: bool = False,
|
|
159
119
|
pbar_show_eta: bool = False,
|
|
160
120
|
pbar_embedded: bool = True,
|
|
161
|
-
|
|
162
|
-
|
|
121
|
+
pbar_style: str | Type[styles.PbarStyleBase] = "square",
|
|
122
|
+
pbar_style_embed: str | Type[styles.PbarStyleBase] = "embed",
|
|
163
123
|
print_header_on_top: bool = True,
|
|
164
124
|
print_header_every_n_rows: int = 30,
|
|
165
125
|
custom_cell_format: Callable[[Any], str] | None = None,
|
|
166
126
|
table_style: str | Type[styles.TableStyleBase] = "round",
|
|
167
|
-
pbar_style: str | Type[styles.PbarStyleBase] = "normal",
|
|
168
|
-
pbar_style_embed: str | Type[styles.PbarStyleBase] = "embed",
|
|
169
127
|
file=None,
|
|
170
128
|
# Deprecated arguments
|
|
171
129
|
custom_format: None = None,
|
|
@@ -217,8 +175,6 @@ class ProgressTableV1:
|
|
|
217
175
|
Embedded version is more subtle, but does not prevent the current row from being displayed.
|
|
218
176
|
If False, the progress bar covers the current row, preventing the user from seeing values
|
|
219
177
|
that are being updated until the progress bar finishes. The default is True.
|
|
220
|
-
pbar_color_filled: Default color of the filled part of the progress bars.
|
|
221
|
-
pbar_color_empty: Default color of the empty part of the progress bars.
|
|
222
178
|
print_header_every_n_rows: 30 by default. When table has a lot of rows, it can be useful to remind what the header is.
|
|
223
179
|
If True, hedaer will be displayed periodically after the selected number of rows. 0 to supress.
|
|
224
180
|
custom_cell_format: A function that defines how to get str value to display from a cell content.
|
|
@@ -238,15 +194,14 @@ class ProgressTableV1:
|
|
|
238
194
|
if print_row_on_update is not None:
|
|
239
195
|
logging.warning("Argument `print_row_on_update` is deprecated. Specify `interactive` instead!")
|
|
240
196
|
|
|
241
|
-
self.table_style = styles.
|
|
242
|
-
|
|
243
|
-
self.
|
|
197
|
+
self.table_style = styles.parse_table_style(table_style)
|
|
198
|
+
|
|
199
|
+
self.pbar_style = styles.parse_pbar_style(pbar_style)
|
|
200
|
+
self.pbar_style_embed = styles.parse_pbar_style(pbar_style_embed)
|
|
244
201
|
|
|
245
202
|
assert isinstance(default_row_color, ColorFormatTuple), "Row color has to be a color format!" # type: ignore
|
|
246
203
|
assert isinstance(default_column_color, ColorFormatTuple), "Column color has to be a color format!" # type: ignore
|
|
247
204
|
assert isinstance(default_header_color, ColorFormatTuple), "Header color has to be a color format!" # type: ignore
|
|
248
|
-
assert isinstance(pbar_color_filled, ColorFormatTuple)
|
|
249
|
-
assert isinstance(pbar_color_empty, ColorFormatTuple)
|
|
250
205
|
|
|
251
206
|
# Default values for column and
|
|
252
207
|
self.column_width = default_column_width
|
|
@@ -290,8 +245,6 @@ class ProgressTableV1:
|
|
|
290
245
|
self.pbar_show_percents: bool = pbar_show_percents
|
|
291
246
|
self.pbar_show_eta: bool = pbar_show_eta
|
|
292
247
|
self.pbar_embedded: bool = pbar_embedded
|
|
293
|
-
self.pbar_color_filled = pbar_color_filled
|
|
294
|
-
self.pbar_color_empty = pbar_color_empty
|
|
295
248
|
|
|
296
249
|
self.refresh_rate: int = refresh_rate
|
|
297
250
|
|
|
@@ -813,8 +766,6 @@ class ProgressTableV1:
|
|
|
813
766
|
*range_args,
|
|
814
767
|
position=None,
|
|
815
768
|
static=False,
|
|
816
|
-
color_filled="",
|
|
817
|
-
color_empty="",
|
|
818
769
|
total=None,
|
|
819
770
|
refresh_rate=None,
|
|
820
771
|
description="",
|
|
@@ -822,6 +773,10 @@ class ProgressTableV1:
|
|
|
822
773
|
show_progress=None,
|
|
823
774
|
show_percents=None,
|
|
824
775
|
show_eta=None,
|
|
776
|
+
style=None,
|
|
777
|
+
style_embed=None,
|
|
778
|
+
color=None,
|
|
779
|
+
color_empty=None,
|
|
825
780
|
):
|
|
826
781
|
"""Create iterable progress bar object.
|
|
827
782
|
|
|
@@ -831,8 +786,6 @@ class ProgressTableV1:
|
|
|
831
786
|
position: Level of the progress bar. If not provided, it will be set automatically.
|
|
832
787
|
static: If True, the progress bar will stick to the row with index given by position.
|
|
833
788
|
If False, the position will be interpreted as the offset from the last row.
|
|
834
|
-
color_filled: Color of the filled part of the progress bar.
|
|
835
|
-
color_empty: Color of the empty part of the progress bar.
|
|
836
789
|
total: Total number of iterations. If not provided, it will be calculated from the length of the iterable.
|
|
837
790
|
refresh_rate: The maximal number of times per second the progress bar will be refreshed.
|
|
838
791
|
description: Custom description of the progress bar that will be shown as prefix.
|
|
@@ -840,6 +793,10 @@ class ProgressTableV1:
|
|
|
840
793
|
show_progress: If True, the progress will be displayed.
|
|
841
794
|
show_percents: If True, the percentage of the progress will be displayed.
|
|
842
795
|
show_eta: If True, the estimated time of finishing will be displayed.
|
|
796
|
+
style: Style of the progress bar. If None, the default style will be used.
|
|
797
|
+
style_embed: Style of the embedded progress bar. If None, the default style will be used.
|
|
798
|
+
color: Color of the progress bar. This overrides the default color.
|
|
799
|
+
color_empty: Color of the empty progress bar. This overrides the default color.
|
|
843
800
|
"""
|
|
844
801
|
if isinstance(iterable, int):
|
|
845
802
|
iterable = range(iterable, *range_args)
|
|
@@ -857,14 +814,19 @@ class ProgressTableV1:
|
|
|
857
814
|
|
|
858
815
|
total = total if total is not None else (len(iterable) if isinstance(iterable, Sized) else 0)
|
|
859
816
|
|
|
817
|
+
style = parse_pbar_style(style) if style else self.pbar_style
|
|
818
|
+
style_embed = parse_pbar_style(style_embed) if style_embed else self.pbar_style_embed
|
|
819
|
+
|
|
860
820
|
pbar = TableProgressBar(
|
|
861
821
|
iterable=iterable,
|
|
862
822
|
table=self,
|
|
863
823
|
total=total,
|
|
824
|
+
style=style,
|
|
825
|
+
style_embed=style_embed,
|
|
826
|
+
color=color,
|
|
827
|
+
color_empty=color_empty,
|
|
864
828
|
position=position,
|
|
865
829
|
static=static,
|
|
866
|
-
color_filled=color_filled or self.pbar_color_filled,
|
|
867
|
-
color_empty=color_empty or self.pbar_color_empty,
|
|
868
830
|
description=description,
|
|
869
831
|
show_throughput=show_throughput if show_throughput is not None else self.pbar_show_throughput,
|
|
870
832
|
show_progress=show_progress if show_progress is not None else self.pbar_show_progress,
|
|
@@ -886,7 +848,9 @@ class TableProgressBar:
|
|
|
886
848
|
*,
|
|
887
849
|
table,
|
|
888
850
|
total,
|
|
889
|
-
|
|
851
|
+
style,
|
|
852
|
+
style_embed,
|
|
853
|
+
color,
|
|
890
854
|
color_empty,
|
|
891
855
|
position,
|
|
892
856
|
static,
|
|
@@ -903,11 +867,21 @@ class TableProgressBar:
|
|
|
903
867
|
self._creation_time: float = time.perf_counter()
|
|
904
868
|
self._last_refresh_time: float = -float("inf")
|
|
905
869
|
|
|
870
|
+
self.style = style
|
|
871
|
+
self.style_embed = style_embed
|
|
872
|
+
|
|
873
|
+
# Modyfing styles
|
|
874
|
+
if color:
|
|
875
|
+
color = maybe_convert_to_colorama(color)
|
|
876
|
+
self.style.color = color
|
|
877
|
+
self.style_embed.color = color
|
|
878
|
+
if color_empty:
|
|
879
|
+
color_empty = maybe_convert_to_colorama(color_empty)
|
|
880
|
+
self.style.color_empty = color_empty
|
|
881
|
+
self.style_embed.color_empty = color_empty
|
|
882
|
+
|
|
906
883
|
self.position: int = position
|
|
907
884
|
self.static: bool = static
|
|
908
|
-
|
|
909
|
-
self.color_filled: str = maybe_convert_to_colorama(color_filled)
|
|
910
|
-
self.color_empty: str = maybe_convert_to_colorama(color_empty)
|
|
911
885
|
self.table: ProgressTableV1 = table
|
|
912
886
|
self.description: str = description
|
|
913
887
|
self.show_throughput: bool = show_throughput
|
|
@@ -993,6 +967,7 @@ class TableProgressBar:
|
|
|
993
967
|
total = tot_width
|
|
994
968
|
|
|
995
969
|
num_filled = math.ceil(step / total * tot_width)
|
|
970
|
+
frac_missing = step / total * tot_width - num_filled
|
|
996
971
|
num_empty = tot_width - num_filled
|
|
997
972
|
|
|
998
973
|
if embed_str is not None:
|
|
@@ -1001,25 +976,35 @@ class TableProgressBar:
|
|
|
1001
976
|
|
|
1002
977
|
filled_part = row_str[:num_filled]
|
|
1003
978
|
if len(filled_part) > 0 and filled_part[-1] == " ":
|
|
1004
|
-
|
|
1005
|
-
|
|
979
|
+
head = self.style_embed.head
|
|
980
|
+
if isinstance(head, (tuple, list)):
|
|
981
|
+
head = head[round(frac_missing * len(head))]
|
|
982
|
+
filled_part = filled_part[:-1] + head
|
|
983
|
+
filled_part = filled_part.replace(" ", self.style_embed.filled)
|
|
1006
984
|
empty_part = row_str[num_filled:-1]
|
|
985
|
+
color_filled = self.style_embed.color
|
|
986
|
+
color_empty = self.style_embed.color_empty
|
|
1007
987
|
else:
|
|
1008
|
-
filled_part = self.
|
|
988
|
+
filled_part = self.style.filled * num_filled
|
|
1009
989
|
if len(filled_part) > 0:
|
|
1010
|
-
|
|
1011
|
-
|
|
990
|
+
head = self.style.head
|
|
991
|
+
if isinstance(head, (tuple, list)):
|
|
992
|
+
head = head[round(frac_missing * len(head))]
|
|
993
|
+
filled_part = filled_part[:-1] + head
|
|
994
|
+
empty_part = self.style.empty * num_empty
|
|
995
|
+
color_filled = self.style.color
|
|
996
|
+
color_empty = self.style.color_empty
|
|
1012
997
|
|
|
1013
998
|
pbar_body = "".join(
|
|
1014
999
|
[
|
|
1015
1000
|
self.table.table_style.vertical,
|
|
1016
1001
|
infobar,
|
|
1017
|
-
|
|
1002
|
+
color_filled,
|
|
1018
1003
|
filled_part,
|
|
1019
|
-
Style.RESET_ALL if
|
|
1020
|
-
|
|
1004
|
+
Style.RESET_ALL if color_filled else "",
|
|
1005
|
+
color_empty,
|
|
1021
1006
|
empty_part,
|
|
1022
|
-
Style.RESET_ALL if
|
|
1007
|
+
Style.RESET_ALL if color_empty else "",
|
|
1023
1008
|
self.table.table_style.vertical,
|
|
1024
1009
|
]
|
|
1025
1010
|
)
|
|
@@ -1,28 +1,63 @@
|
|
|
1
1
|
# Copyright (c) 2022-2024 Szymon Mikler
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
from typing import Tuple, Union
|
|
6
|
+
|
|
7
|
+
from progress_table.v1.common import ALL_COLOR_NAME, maybe_convert_to_colorama
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def contains_word(short, long):
|
|
11
|
+
return any([short == word.strip(" ") for word in long.split(" ")])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_colors_from_description(description):
|
|
15
|
+
color = ""
|
|
16
|
+
color_empty = ""
|
|
17
|
+
for word in description.split():
|
|
18
|
+
for color_name in ALL_COLOR_NAME:
|
|
19
|
+
if color_name.lower() == word.lower():
|
|
20
|
+
if not color:
|
|
21
|
+
color = color_name
|
|
22
|
+
else:
|
|
23
|
+
color_empty = color_name
|
|
24
|
+
description = description.replace(word, "")
|
|
25
|
+
return color, color_empty, description
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def parse_pbar_style(description):
|
|
29
|
+
if isinstance(description, str):
|
|
7
30
|
for obj in available_pbar_styles():
|
|
8
|
-
if obj.name
|
|
9
|
-
|
|
31
|
+
if contains_word(obj.name, description):
|
|
32
|
+
description = description.replace(obj.name, "")
|
|
33
|
+
color, color_empty, description = parse_colors_from_description(description)
|
|
34
|
+
is_alt = "alt" in description
|
|
35
|
+
is_clean = "clean" in description
|
|
36
|
+
description = description.replace("alt", "").replace("clean", "").strip(" ")
|
|
37
|
+
if description.strip(" "):
|
|
38
|
+
raise ValueError(f"Name '{description}' is not recognized as a part of progress bar style")
|
|
39
|
+
|
|
40
|
+
return obj(alt=is_alt, clean=is_clean, color=color, color_empty=color_empty)
|
|
41
|
+
|
|
10
42
|
available_names = ", ".join([obj.name for obj in available_pbar_styles()])
|
|
11
|
-
raise ValueError(f"Progress bar style '{
|
|
43
|
+
raise ValueError(f"Progress bar style '{description}' not found. Available: {available_names}")
|
|
12
44
|
else:
|
|
13
|
-
return
|
|
45
|
+
return description
|
|
14
46
|
|
|
15
47
|
|
|
16
|
-
def
|
|
17
|
-
if isinstance(
|
|
18
|
-
table_style_name = table_style_name.lower()
|
|
48
|
+
def parse_table_style(description):
|
|
49
|
+
if isinstance(description, str):
|
|
19
50
|
for obj in available_table_styles():
|
|
20
|
-
if obj.name
|
|
21
|
-
|
|
51
|
+
if contains_word(obj.name, description):
|
|
52
|
+
description = description.replace(obj.name, "").strip(" ")
|
|
53
|
+
if description:
|
|
54
|
+
raise ValueError(f"Name '{description}' is not recognized as a part of table style")
|
|
55
|
+
|
|
56
|
+
return obj()
|
|
22
57
|
available_names = ", ".join([obj.name for obj in available_table_styles()])
|
|
23
|
-
raise ValueError(f"Table style '{
|
|
58
|
+
raise ValueError(f"Table style '{description}' not found. Available: {available_names}")
|
|
24
59
|
else:
|
|
25
|
-
return
|
|
60
|
+
return description
|
|
26
61
|
|
|
27
62
|
|
|
28
63
|
def available_table_styles():
|
|
@@ -42,16 +77,42 @@ class PbarStyleBase:
|
|
|
42
77
|
name: str
|
|
43
78
|
filled: str
|
|
44
79
|
empty: str
|
|
45
|
-
head: str
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
head: Union[str, Tuple[str, ...]]
|
|
81
|
+
color: str = ""
|
|
82
|
+
color_empty: str = ""
|
|
83
|
+
|
|
84
|
+
def __init__(self, alt=False, clean=False, color=None, color_empty=None):
|
|
85
|
+
if color is not None:
|
|
86
|
+
self.color = maybe_convert_to_colorama(color)
|
|
87
|
+
if color_empty is not None:
|
|
88
|
+
self.color_empty = maybe_convert_to_colorama(color_empty)
|
|
89
|
+
if alt:
|
|
90
|
+
self.empty = self.filled
|
|
91
|
+
if clean:
|
|
92
|
+
self.empty = " "
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class PbarStyleSquare(PbarStyleBase):
|
|
96
|
+
name = "square"
|
|
50
97
|
filled = "■"
|
|
51
98
|
empty = "□"
|
|
52
99
|
head = "◩"
|
|
53
100
|
|
|
54
101
|
|
|
102
|
+
class PbarStyleFull(PbarStyleBase):
|
|
103
|
+
name = "full"
|
|
104
|
+
filled = "█"
|
|
105
|
+
empty = " "
|
|
106
|
+
head = ("▏", "▎", "▍", "▌", "▋", "▊", "▉")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class PbarStyleDots(PbarStyleBase):
|
|
110
|
+
name = "dots"
|
|
111
|
+
filled = "⣿"
|
|
112
|
+
empty = "⣀"
|
|
113
|
+
head = ("⣄", "⣤", "⣦", "⣶", "⣷")
|
|
114
|
+
|
|
115
|
+
|
|
55
116
|
class PbarStyleShort(PbarStyleBase):
|
|
56
117
|
name = "short"
|
|
57
118
|
filled = "▬"
|
|
@@ -59,13 +120,6 @@ class PbarStyleShort(PbarStyleBase):
|
|
|
59
120
|
head = "▬"
|
|
60
121
|
|
|
61
122
|
|
|
62
|
-
class PbarStyleNormalClean(PbarStyleBase):
|
|
63
|
-
name = "normal clean"
|
|
64
|
-
filled = "■"
|
|
65
|
-
empty = " "
|
|
66
|
-
head = "◩"
|
|
67
|
-
|
|
68
|
-
|
|
69
123
|
class PbarStyleCircle(PbarStyleBase):
|
|
70
124
|
name = "circle"
|
|
71
125
|
filled = "●"
|
|
@@ -73,13 +127,6 @@ class PbarStyleCircle(PbarStyleBase):
|
|
|
73
127
|
head = "◉"
|
|
74
128
|
|
|
75
129
|
|
|
76
|
-
class PbarStyleCircleClean(PbarStyleBase):
|
|
77
|
-
name = "circle clean"
|
|
78
|
-
filled = "●"
|
|
79
|
-
empty = " "
|
|
80
|
-
head = "◉"
|
|
81
|
-
|
|
82
|
-
|
|
83
130
|
class PbarStyleAngled(PbarStyleBase):
|
|
84
131
|
name = "angled"
|
|
85
132
|
filled = "▰"
|
|
@@ -87,13 +134,6 @@ class PbarStyleAngled(PbarStyleBase):
|
|
|
87
134
|
head = "▰"
|
|
88
135
|
|
|
89
136
|
|
|
90
|
-
class PbarStyleAngledClean(PbarStyleBase):
|
|
91
|
-
name = "angled clean"
|
|
92
|
-
filled = "▰"
|
|
93
|
-
empty = " "
|
|
94
|
-
head = "▰"
|
|
95
|
-
|
|
96
|
-
|
|
97
137
|
class PbarStyleEmbed(PbarStyleBase):
|
|
98
138
|
name = "embed"
|
|
99
139
|
filled = "ꞏ"
|
|
@@ -107,6 +147,14 @@ class PbarStyleRich(PbarStyleBase):
|
|
|
107
147
|
empty = " "
|
|
108
148
|
head = "━"
|
|
109
149
|
|
|
150
|
+
def __init__(self, *args, **kwds):
|
|
151
|
+
"""Similar to the default progress bar from rich"""
|
|
152
|
+
super().__init__(*args, **kwds)
|
|
153
|
+
if not self.color and not self.color_empty:
|
|
154
|
+
self.color = maybe_convert_to_colorama("red")
|
|
155
|
+
self.color_empty = maybe_convert_to_colorama("black")
|
|
156
|
+
self.empty = self.filled
|
|
157
|
+
|
|
110
158
|
|
|
111
159
|
class PbarStyleNone(PbarStyleBase):
|
|
112
160
|
name = "hidden"
|
|
@@ -136,8 +184,8 @@ class TableStyleBase:
|
|
|
136
184
|
no_down: str
|
|
137
185
|
|
|
138
186
|
|
|
139
|
-
class
|
|
140
|
-
name = "
|
|
187
|
+
class TableStyleModern(TableStyleBase):
|
|
188
|
+
name = "modern"
|
|
141
189
|
cell_overflow = "…"
|
|
142
190
|
horizontal = "─"
|
|
143
191
|
vertical = "│"
|
|
@@ -233,7 +281,7 @@ class TableStyleAscii(TableStyleBase):
|
|
|
233
281
|
|
|
234
282
|
|
|
235
283
|
class TableStyleAsciiBare(TableStyleBase):
|
|
236
|
-
name = "
|
|
284
|
+
name = "asciib"
|
|
237
285
|
cell_overflow = "_"
|
|
238
286
|
horizontal = "-"
|
|
239
287
|
vertical = " "
|
|
@@ -14,6 +14,7 @@ progress_table/v0/__init__.py
|
|
|
14
14
|
progress_table/v0/progress_table.py
|
|
15
15
|
progress_table/v0/symbols.py
|
|
16
16
|
progress_table/v1/__init__.py
|
|
17
|
+
progress_table/v1/common.py
|
|
17
18
|
progress_table/v1/progress_table.py
|
|
18
19
|
progress_table/v1/styles.py
|
|
19
20
|
tests/test_docs_automated.py
|
|
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
|