progress-table 3.1.2__tar.gz → 3.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-3.1.2 → progress_table-3.2.1}/PKG-INFO +2 -1
- {progress_table-3.1.2 → progress_table-3.2.1}/progress_table/__init__.py +1 -1
- {progress_table-3.1.2 → progress_table-3.2.1}/progress_table/progress_table.py +21 -13
- {progress_table-3.1.2 → progress_table-3.2.1}/pyproject.toml +1 -1
- {progress_table-3.1.2 → progress_table-3.2.1}/.gitignore +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/LICENSE.txt +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/README.md +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/README_pypi.md +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/docs/advanced-usage.md +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/docs/integrations.md +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/docs/v3-notice.md +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/examples/brown2d.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/examples/download_v1.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/examples/download_v2.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/examples/tictactoe.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/examples/training.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/progress_table/common.py +0 -0
- {progress_table-3.1.2 → progress_table-3.2.1}/progress_table/styles.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: progress-table
|
|
3
|
-
Version: 3.1
|
|
3
|
+
Version: 3.2.1
|
|
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,6 +18,7 @@ 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
23
|
Requires-Dist: hatch; extra == 'dev'
|
|
23
24
|
Requires-Dist: pyright; extra == 'dev'
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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 = [
|
|
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
|