progress-table 3.1.1__tar.gz → 3.2.0__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-3.1.1 → progress_table-3.2.0}/PKG-INFO +7 -10
- {progress_table-3.1.1 → progress_table-3.2.0}/README.md +0 -6
- {progress_table-3.1.1 → progress_table-3.2.0}/README_pypi.md +0 -6
- {progress_table-3.1.1 → progress_table-3.2.0}/progress_table/__init__.py +1 -1
- {progress_table-3.1.1 → progress_table-3.2.0}/progress_table/progress_table.py +103 -95
- {progress_table-3.1.1 → progress_table-3.2.0}/pyproject.toml +2 -2
- {progress_table-3.1.1 → progress_table-3.2.0}/.gitignore +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/LICENSE.txt +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/docs/advanced-usage.md +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/docs/integrations.md +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/docs/v3-notice.md +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/examples/brown2d.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/examples/download_v1.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/examples/download_v2.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/examples/tictactoe.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/examples/training.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/progress_table/common.py +0 -0
- {progress_table-3.1.1 → progress_table-3.2.0}/progress_table/styles.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: progress-table
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Display progress as a pretty table in the command line.
|
|
5
5
|
Project-URL: Home, https://github.com/gahaalt/progress-table
|
|
6
6
|
Project-URL: Documentation, https://github.com/sjmikler/progress-table/blob/main/docs
|
|
@@ -18,19 +18,16 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Requires-Python: >=3.7
|
|
20
20
|
Requires-Dist: colorama
|
|
21
|
+
Requires-Dist: wcwidth
|
|
21
22
|
Provides-Extra: dev
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist:
|
|
23
|
+
Requires-Dist: hatch; extra == 'dev'
|
|
24
|
+
Requires-Dist: pyright; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
27
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
25
28
|
Requires-Dist: twine; extra == 'dev'
|
|
26
29
|
Description-Content-Type: text/markdown
|
|
27
30
|
|
|
28
|
-
> Version 2.x.x introduces new features and new interactive modes.
|
|
29
|
-
>
|
|
30
|
-
> Version 3.x.x improves compatibility and stability.
|
|
31
|
-
>
|
|
32
|
-
> New features allow for previously impossible applications, see examples below.
|
|
33
|
-
|
|
34
31
|
# Progress Table
|
|
35
32
|
|
|
36
33
|
[](https://pypi.org/project/progress-table)
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
> Version 2.x.x introduces new features and new interactive modes.
|
|
2
|
-
>
|
|
3
|
-
> Version 3.x.x improves compatibility and stability.
|
|
4
|
-
>
|
|
5
|
-
> New features allow for previously impossible applications, see examples below.
|
|
6
|
-
|
|
7
1
|
# Progress Table
|
|
8
2
|
|
|
9
3
|
[](https://pypi.org/project/progress-table)
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
> Version 2.x.x introduces new features and new interactive modes.
|
|
2
|
-
>
|
|
3
|
-
> Version 3.x.x improves compatibility and stability.
|
|
4
|
-
>
|
|
5
|
-
> New features allow for previously impossible applications, see examples below.
|
|
6
|
-
|
|
7
1
|
# Progress Table
|
|
8
2
|
|
|
9
3
|
[](https://pypi.org/project/progress-table)
|
|
@@ -17,6 +17,7 @@ from dataclasses import dataclass
|
|
|
17
17
|
from threading import Thread
|
|
18
18
|
from typing import Any, TextIO
|
|
19
19
|
|
|
20
|
+
import wcwidth
|
|
20
21
|
from colorama import Style
|
|
21
22
|
|
|
22
23
|
from progress_table import styles
|
|
@@ -129,34 +130,34 @@ class ProgressTable:
|
|
|
129
130
|
DEFAULT_ROW_COLOR = None
|
|
130
131
|
|
|
131
132
|
def __init__(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
133
|
+
self,
|
|
134
|
+
*cols: str,
|
|
135
|
+
columns: Iterable[str] = (),
|
|
136
|
+
interactive: int = int(os.environ.get("PTABLE_INTERACTIVE", "2")),
|
|
137
|
+
refresh_rate: int = 20,
|
|
138
|
+
num_decimal_places: int = 4,
|
|
139
|
+
default_column_width: int | None = None,
|
|
140
|
+
default_column_color: ColorFormat = None,
|
|
141
|
+
default_column_alignment: str | None = None,
|
|
142
|
+
default_column_aggregate: str | None = None,
|
|
143
|
+
default_header_color: ColorFormat = None,
|
|
144
|
+
default_row_color: ColorFormat = None,
|
|
145
|
+
pbar_show_throughput: bool = True,
|
|
146
|
+
pbar_show_progress: bool = False,
|
|
147
|
+
pbar_show_percents: bool = False,
|
|
148
|
+
pbar_show_eta: bool = False,
|
|
149
|
+
pbar_embedded: bool = True,
|
|
150
|
+
pbar_style: str | styles.PbarStyleBase = "square",
|
|
151
|
+
pbar_style_embed: str | styles.PbarStyleBase = "cdots",
|
|
152
|
+
print_header_on_top: bool = True,
|
|
153
|
+
print_header_every_n_rows: int = 30,
|
|
154
|
+
custom_cell_format: Callable[[Any], str] | None = None,
|
|
155
|
+
table_style: str | styles.TableStyleBase = "round",
|
|
156
|
+
file: TextIO | list[TextIO] | tuple[TextIO] | None = None,
|
|
157
|
+
# DEPRECATED ARGUMENTS
|
|
158
|
+
custom_format: None = None,
|
|
159
|
+
embedded_progress_bar: None = None,
|
|
160
|
+
print_row_on_update: None = None,
|
|
160
161
|
) -> None:
|
|
161
162
|
"""Progress Table instance.
|
|
162
163
|
|
|
@@ -305,13 +306,13 @@ class ProgressTable:
|
|
|
305
306
|
####################
|
|
306
307
|
|
|
307
308
|
def add_column(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
self,
|
|
310
|
+
name: str,
|
|
311
|
+
*,
|
|
312
|
+
width: int | None = None,
|
|
313
|
+
color: ColorFormat = None,
|
|
314
|
+
alignment: str | None = None,
|
|
315
|
+
aggregate: None | str | Callable = None,
|
|
315
316
|
) -> None:
|
|
316
317
|
"""Add column to the table.
|
|
317
318
|
|
|
@@ -391,14 +392,14 @@ class ProgressTable:
|
|
|
391
392
|
self._set_all_display_rows_as_pending()
|
|
392
393
|
|
|
393
394
|
def update(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
395
|
+
self,
|
|
396
|
+
name: str,
|
|
397
|
+
value: Any,
|
|
398
|
+
*,
|
|
399
|
+
row: int = -1,
|
|
400
|
+
weight: float = 1.0,
|
|
401
|
+
cell_color: ColorFormat = None,
|
|
402
|
+
**column_kwds,
|
|
402
403
|
) -> None:
|
|
403
404
|
"""Update value in the current row. More powerful than __setitem__.
|
|
404
405
|
|
|
@@ -490,17 +491,17 @@ class ProgressTable:
|
|
|
490
491
|
return self._at_indexer
|
|
491
492
|
|
|
492
493
|
def next_row(
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
494
|
+
self,
|
|
495
|
+
color: ColorFormat | dict[str, ColorFormat] = None,
|
|
496
|
+
split: bool | None = None,
|
|
497
|
+
header: bool | None = None,
|
|
497
498
|
) -> None:
|
|
498
499
|
"""End the current row."""
|
|
499
500
|
# Force header if it wasn't printed for a long enough time
|
|
500
501
|
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
header is None
|
|
503
|
+
and len(self._data_rows) - self._previous_header_row_number >= self._print_header_every_n_rows
|
|
504
|
+
and self._print_header_every_n_rows > 0
|
|
504
505
|
):
|
|
505
506
|
header = True
|
|
506
507
|
header = header or False
|
|
@@ -833,31 +834,38 @@ class ProgressTable:
|
|
|
833
834
|
return {col: self.column_colors[col] + color_colorama[col] for col in color}
|
|
834
835
|
|
|
835
836
|
def _apply_cell_formatting(self, value: Any, column_name: str, color: str) -> str:
|
|
836
|
-
str_value = self.custom_cell_format(value)
|
|
837
837
|
width = self.column_widths[column_name]
|
|
838
|
+
str_value = self.custom_cell_format(value)
|
|
838
839
|
alignment = self.column_alignments[column_name]
|
|
839
840
|
|
|
841
|
+
real_width = 0
|
|
842
|
+
clipped = False
|
|
843
|
+
num_characters = len(str_value)
|
|
844
|
+
for idx, letter in enumerate(str_value):
|
|
845
|
+
ch_width = wcwidth.wcwidth(letter)
|
|
846
|
+
if real_width + ch_width > width:
|
|
847
|
+
num_characters = idx
|
|
848
|
+
clipped = True
|
|
849
|
+
break
|
|
850
|
+
real_width += ch_width
|
|
851
|
+
|
|
852
|
+
str_value = str_value[:num_characters]
|
|
853
|
+
num_characters += width - real_width
|
|
854
|
+
|
|
840
855
|
if alignment == "center":
|
|
841
|
-
str_value = str_value.center(
|
|
856
|
+
str_value = str_value.center(num_characters)
|
|
842
857
|
elif alignment == "left":
|
|
843
|
-
str_value = str_value.ljust(
|
|
858
|
+
str_value = str_value.ljust(num_characters)
|
|
844
859
|
elif alignment == "right":
|
|
845
|
-
str_value = str_value.rjust(
|
|
860
|
+
str_value = str_value.rjust(num_characters)
|
|
846
861
|
else:
|
|
847
862
|
allowed_alignments = ["center", "left", "right"]
|
|
848
863
|
msg = f"Alignment '{alignment}' not in {allowed_alignments}!"
|
|
849
864
|
raise KeyError(msg)
|
|
850
865
|
|
|
851
|
-
clipped = len(str_value) > width
|
|
852
|
-
str_value = "".join(
|
|
853
|
-
[
|
|
854
|
-
" ", # space at the beginning of the row
|
|
855
|
-
str_value[:width].center(width),
|
|
856
|
-
self.table_style.cell_overflow if clipped else " ",
|
|
857
|
-
],
|
|
858
|
-
)
|
|
859
866
|
reset = Style.RESET_ALL if color else ""
|
|
860
|
-
|
|
867
|
+
maybe_overflow = self.table_style.cell_overflow if clipped else ' '
|
|
868
|
+
return f"{color} {str_value}{maybe_overflow}{reset}"
|
|
861
869
|
|
|
862
870
|
def _get_outer_inner_width(self) -> int:
|
|
863
871
|
return sum(self.column_widths.values()) + 3 * len(self.column_widths) + 1
|
|
@@ -952,21 +960,21 @@ class ProgressTable:
|
|
|
952
960
|
##################
|
|
953
961
|
|
|
954
962
|
def pbar(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
963
|
+
self,
|
|
964
|
+
iterable: Iterable | int,
|
|
965
|
+
*range_args,
|
|
966
|
+
position=None,
|
|
967
|
+
static=False,
|
|
968
|
+
total=None,
|
|
969
|
+
description="",
|
|
970
|
+
show_throughput: bool | None = None,
|
|
971
|
+
show_progress: bool | None = None,
|
|
972
|
+
show_percents: bool | None = None,
|
|
973
|
+
show_eta: bool | None = None,
|
|
974
|
+
style=None,
|
|
975
|
+
style_embed=None,
|
|
976
|
+
color=None,
|
|
977
|
+
color_empty=None,
|
|
970
978
|
) -> TableProgressBar:
|
|
971
979
|
"""Create iterable progress bar object.
|
|
972
980
|
|
|
@@ -1033,22 +1041,22 @@ class ProgressTable:
|
|
|
1033
1041
|
|
|
1034
1042
|
class TableProgressBar:
|
|
1035
1043
|
def __init__(
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1044
|
+
self,
|
|
1045
|
+
iterable,
|
|
1046
|
+
*,
|
|
1047
|
+
table,
|
|
1048
|
+
total,
|
|
1049
|
+
style,
|
|
1050
|
+
style_embed,
|
|
1051
|
+
color,
|
|
1052
|
+
color_empty,
|
|
1053
|
+
position,
|
|
1054
|
+
static,
|
|
1055
|
+
description,
|
|
1056
|
+
show_throughput: bool,
|
|
1057
|
+
show_progress: bool,
|
|
1058
|
+
show_percents: bool,
|
|
1059
|
+
show_eta: bool,
|
|
1052
1060
|
) -> None:
|
|
1053
1061
|
self.iterable: Iterable | None = iterable
|
|
1054
1062
|
|
|
@@ -1163,7 +1171,7 @@ class TableProgressBar:
|
|
|
1163
1171
|
num_empty = inner_width - num_filled
|
|
1164
1172
|
|
|
1165
1173
|
if embed_str is not None:
|
|
1166
|
-
row_str = embed_str[1 + len(infobar)
|
|
1174
|
+
row_str = embed_str[1 + len(infobar):]
|
|
1167
1175
|
|
|
1168
1176
|
filled_part = row_str[:num_filled]
|
|
1169
1177
|
if len(filled_part) > 0 and filled_part[-1] == " ":
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
name = "progress-table"
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = "Display progress as a pretty table in the command line."
|
|
9
|
-
dependencies = ["colorama"]
|
|
9
|
+
dependencies = ["colorama", "wcwidth"]
|
|
10
10
|
license = { text = "MIT" }
|
|
11
11
|
requires-python = ">=3.7"
|
|
12
12
|
authors = [
|
|
@@ -30,7 +30,7 @@ Home = "https://github.com/gahaalt/progress-table"
|
|
|
30
30
|
Documentation = "https://github.com/sjmikler/progress-table/blob/main/docs"
|
|
31
31
|
|
|
32
32
|
[project.optional-dependencies]
|
|
33
|
-
dev = ["
|
|
33
|
+
dev = ["ruff", "pyright", "pytest", "pytest-cov", "hatch", "twine"]
|
|
34
34
|
|
|
35
35
|
[tool.hatch.version]
|
|
36
36
|
path = "progress_table/__init__.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
|