flexablelib 3.5.2__tar.gz → 3.5.3__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.
- {flexablelib-3.5.2 → flexablelib-3.5.3}/CHANGELOG.md +22 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/PKG-INFO +9 -9
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/colors.py +6 -4
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/table.py +38 -2
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib.egg-info/PKG-INFO +9 -9
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib.egg-info/SOURCES.txt +1 -0
- flexablelib-3.5.3/flexablelib.egg-info/requires.txt +35 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/package.json +1 -1
- flexablelib-3.5.3/tests/test_v353_fixes.py +237 -0
- flexablelib-3.5.2/flexablelib.egg-info/requires.txt +0 -35
- {flexablelib-3.5.2 → flexablelib-3.5.3}/.coveragerc +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/LICENSE +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/MANIFEST.in +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/README.md +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/admin.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/dashboard.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/keys.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/video/demo.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/video/render.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/video/scenes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/examples/video/thumbnail.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/__init__.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_frames.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_images.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_legacy/__init__.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_legacy/screen.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_legacy/widgets.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_speedups.c +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/_width_tables.h +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/box_topology.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/cells.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/columns.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/fast.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/identifiers.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/layout.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/merges.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/options.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/py.typed +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/readers.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/screen.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/style_compositions.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/table_strings.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/text_width.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/utils.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/widgets.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib/writers.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/pytest.ini +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/setup.cfg +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/setup.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/style_examples.md +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/conftest.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/helpers.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_align_indicators.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_box_topology.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_cells.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_columns.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_excel.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_issues.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_merge_fill.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_merges.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_public_api_edges.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_readme_examples.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_stress_matrix.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_style_line_widths.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_styles.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_text_width.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_upstream_issues.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v2021_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v210_rows_copy.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v2110_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v211_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v213_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v214_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v215_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v216_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v217_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v218_features.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v219_coverage.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v219_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v220_exports.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v221_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v222_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v223_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v224_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v230_none.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v231_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v232_merge_ansi.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v300_style_names.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v310_layout.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v320_tui.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v330_components.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v330_frames.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v330_layout.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v330_tui.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v331_formats.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v331_panel_width.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v331_readers_bom.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v331_readers_edges.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v331_tabs.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v340_accessibility.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v340_core.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v340_input.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v350_images.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v350_images_core.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/test_v352_fixes.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tests/wincon_child.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/bench_frames.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/bench_images.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/benchmark.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/gen_ascii_table.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/generate_width_tables.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/image_demo.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/pty_check.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/readme_gallery.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/stress_matrix.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/style_examples.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/text_to_png.py +0 -0
- {flexablelib-3.5.2 → flexablelib-3.5.3}/tools/wheel_check.py +0 -0
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.5.3] - 2026-11-12
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Index labels with a `row_filter` (or `sort_by`) and hidden empty rows**
|
|
9
|
+
(`show_empty_rows=False`): the visible rows are numbered 0, 1, 2 as
|
|
10
|
+
without a filter, instead of 0, 2, 4 (the hidden empty rows used to take
|
|
11
|
+
a number). `to_records`, `to_csv`, `paginate` and `stream` agree.
|
|
12
|
+
- **`stream()` index column** is as wide as in `compose()` when rows are
|
|
13
|
+
hidden by `row_filter` or `show_empty_rows=False`: it was sized for every
|
|
14
|
+
row, so the streamed table came out one column wider.
|
|
15
|
+
- **Contrast checks** (`parse_color`, `contrast_ratio`, `Theme.contrast()`)
|
|
16
|
+
understand every colour the core draws: `colour:N`, hex without `#`
|
|
17
|
+
(`ff8800`), and `greyNN` as the xterm grey really shown. A theme using
|
|
18
|
+
`colour:N` reported no ratio, or 1:1 for `black on colour:226`.
|
|
19
|
+
- **Colour tokens with non-ASCII digits** (`'²'`, `'٣'`) raise
|
|
20
|
+
`ColourError` like any unknown colour, instead of a bare `ValueError` or
|
|
21
|
+
being read as a palette index.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Hiding empty rows no longer re-scans every row once per row while
|
|
25
|
+
numbering the index (quadratic in the row count).
|
|
26
|
+
|
|
5
27
|
## [3.5.2] - 2026-11-12
|
|
6
28
|
|
|
7
29
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.3
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.5.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.5.3; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.5.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.5.3; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -63,7 +63,7 @@ COLOURS = {
|
|
|
63
63
|
|
|
64
64
|
_HEX_RE = re.compile(r'^#?([0-9a-fA-F]{6})$')
|
|
65
65
|
# Rich / X11-style percentage greys: 'grey23', 'gray70', 'grey100'.
|
|
66
|
-
_GREY_RE = re.compile(r'^gr[ae]y(
|
|
66
|
+
_GREY_RE = re.compile(r'^gr[ae]y([0-9]{1,3})$')
|
|
67
67
|
|
|
68
68
|
# The xterm 256-colour grey levels: black (16), the 24-step ramp
|
|
69
69
|
# (232..255, level 8 + 10*i) and white (231).
|
|
@@ -76,7 +76,9 @@ def _grey_index(percent: int) -> int:
|
|
|
76
76
|
raise ColourError(f'grey percentage out of range: {percent}')
|
|
77
77
|
target = percent * 255 / 100
|
|
78
78
|
return min(_GREY_LEVELS, key=lambda level: abs(level[0] - target))[1]
|
|
79
|
-
|
|
79
|
+
# ASCII digits only: '²'.isdigit() is True but int('²') fails.
|
|
80
|
+
_DIGITS_RE = re.compile(r'^[0-9]+$')
|
|
81
|
+
_INDEX_RE = re.compile(r'^(?:color|colour):([0-9]{1,3})$')
|
|
80
82
|
|
|
81
83
|
|
|
82
84
|
class ColourError(ValueError):
|
|
@@ -110,7 +112,7 @@ def _colour_codes(token: str, background: bool = False) -> list:
|
|
|
110
112
|
raise ColourError(f'256-colour index out of range: {index}')
|
|
111
113
|
return [48 if background else 38, 5, index]
|
|
112
114
|
|
|
113
|
-
if
|
|
115
|
+
if _DIGITS_RE.match(token):
|
|
114
116
|
index = int(token)
|
|
115
117
|
if not 0 <= index <= 255:
|
|
116
118
|
raise ColourError(f'256-colour index out of range: {index}')
|
|
@@ -320,7 +322,7 @@ def _token_hex(token: str, named: dict) -> Optional[str]:
|
|
|
320
322
|
index_match = _INDEX_RE.match(token)
|
|
321
323
|
if index_match:
|
|
322
324
|
return _xterm_hex(int(index_match.group(1)))
|
|
323
|
-
if
|
|
325
|
+
if _DIGITS_RE.match(token):
|
|
324
326
|
return _xterm_hex(int(token))
|
|
325
327
|
return None
|
|
326
328
|
|
|
@@ -4046,6 +4046,12 @@ class Table(object):
|
|
|
4046
4046
|
# One level of copying is enough: the pipeline replaces whole cells,
|
|
4047
4047
|
# it never mutates one in place.
|
|
4048
4048
|
rows_with_i = [list(row) for row in self.__rows_with_i]
|
|
4049
|
+
# Measured once: the property walks every row, and asking it per row
|
|
4050
|
+
# made hiding empty rows quadratic in the row count.
|
|
4051
|
+
empty_rows = (
|
|
4052
|
+
frozenset() if self.__show_empty_rows
|
|
4053
|
+
else frozenset(self.__empty_row_indexes)
|
|
4054
|
+
)
|
|
4049
4055
|
for row_i, row in enumerate(rows_with_i):
|
|
4050
4056
|
if self.__show_empty_rows:
|
|
4051
4057
|
rows_with_i[row_i][0] = row[0](
|
|
@@ -4056,7 +4062,7 @@ class Table(object):
|
|
|
4056
4062
|
rows_with_i[row_i][0] = row[0](
|
|
4057
4063
|
self.__i_start,
|
|
4058
4064
|
self.__i_step,
|
|
4059
|
-
row_i not in
|
|
4065
|
+
row_i not in empty_rows
|
|
4060
4066
|
)
|
|
4061
4067
|
# For adding the missing value where the ValuePlacer
|
|
4062
4068
|
# is used (in the rows with index).
|
|
@@ -4085,12 +4091,15 @@ class Table(object):
|
|
|
4085
4091
|
rows = [rows[i] for i in order]
|
|
4086
4092
|
rows_with_i = [rows_with_i[i] for i in order]
|
|
4087
4093
|
# Index was consumed in stored order; renumber visible rows so
|
|
4088
|
-
# the column stays contiguous after a filter.
|
|
4094
|
+
# the column stays contiguous after a filter. Empty rows that
|
|
4095
|
+
# show_empty_rows=False hides take no number, as without a
|
|
4096
|
+
# filter -- counting them left gaps (0, 2, 4).
|
|
4089
4097
|
self.__index_counter.reset_count()
|
|
4090
4098
|
for row_i, row in enumerate(rows_with_i):
|
|
4091
4099
|
rows_with_i[row_i][0] = self.__index_counter(
|
|
4092
4100
|
self.__i_start,
|
|
4093
4101
|
self.__i_step,
|
|
4102
|
+
self.__show_empty_rows or order[row_i] not in empty_stored,
|
|
4094
4103
|
)
|
|
4095
4104
|
|
|
4096
4105
|
if self.__roman_index and rows_with_i:
|
|
@@ -5599,6 +5608,8 @@ class Table(object):
|
|
|
5599
5608
|
total = work.__real_row_count + len(rows)
|
|
5600
5609
|
except TypeError:
|
|
5601
5610
|
total = None
|
|
5611
|
+
if total and isinstance(rows, (list, tuple)):
|
|
5612
|
+
total = self.__stream_shown_rows(rows, total)
|
|
5602
5613
|
if total:
|
|
5603
5614
|
labels = [work.index_start + work.index_step * k
|
|
5604
5615
|
for k in (0, total - 1)]
|
|
@@ -5648,6 +5659,31 @@ class Table(object):
|
|
|
5648
5659
|
for row in streamed:
|
|
5649
5660
|
self.add_row(row)
|
|
5650
5661
|
|
|
5662
|
+
def __stream_shown_rows(self, rows, total):
|
|
5663
|
+
"""
|
|
5664
|
+
How many of the existing and streamed ``rows`` ``compose()`` would
|
|
5665
|
+
show: ``row_filter`` and hidden empty rows leave out lines, and the
|
|
5666
|
+
index column is sized for the labels that are really drawn. Reserving
|
|
5667
|
+
a label for every row made the index column wider than in
|
|
5668
|
+
``compose()`` (``9`` rows shown but ``10`` reserved, say).
|
|
5669
|
+
"""
|
|
5670
|
+
try:
|
|
5671
|
+
probe = self.__display_clone(include_rows=True)
|
|
5672
|
+
for row in rows:
|
|
5673
|
+
probe.add_row(list(row))
|
|
5674
|
+
headers = list(probe.headers)
|
|
5675
|
+
stored = [probe.__stored_row(row_i, headers)
|
|
5676
|
+
for row_i in range(probe.__real_row_count)]
|
|
5677
|
+
order = probe.__display_row_order(stored)
|
|
5678
|
+
hidden = (set() if probe.__show_empty_rows
|
|
5679
|
+
else set(probe.__empty_row_indexes))
|
|
5680
|
+
shown = len([row_i for row_i in order if row_i not in hidden])
|
|
5681
|
+
except Exception:
|
|
5682
|
+
# A row the stream itself will reject: keep the plain count and
|
|
5683
|
+
# let add_row() report it where it always has.
|
|
5684
|
+
return total
|
|
5685
|
+
return max(1, shown)
|
|
5686
|
+
|
|
5651
5687
|
def __stream_closing_lines(self, widths):
|
|
5652
5688
|
"""
|
|
5653
5689
|
``(n, lines)``: the trailing lines a one-row and a two-row table
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.3
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
|
|
|
46
46
|
Provides-Extra: html
|
|
47
47
|
Requires-Dist: lxml>=4.0; extra == "html"
|
|
48
48
|
Provides-Extra: tui
|
|
49
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.5.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.5.3; extra == "speed"
|
|
54
54
|
Provides-Extra: images
|
|
55
55
|
Requires-Dist: Pillow>=8; extra == "images"
|
|
56
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
57
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
56
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "images"
|
|
57
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "images"
|
|
58
58
|
Provides-Extra: svg
|
|
59
59
|
Requires-Dist: cairosvg>=2.5; extra == "svg"
|
|
60
60
|
Provides-Extra: all
|
|
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
|
|
|
62
62
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
63
63
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
64
64
|
Requires-Dist: Pillow>=8; extra == "all"
|
|
65
|
-
Requires-Dist: flexablelib-tui==3.5.
|
|
66
|
-
Requires-Dist: flexablelib-components==3.5.
|
|
67
|
-
Requires-Dist: flexablelib-speedups==3.5.
|
|
65
|
+
Requires-Dist: flexablelib-tui==3.5.3; extra == "all"
|
|
66
|
+
Requires-Dist: flexablelib-components==3.5.3; extra == "all"
|
|
67
|
+
Requires-Dist: flexablelib-speedups==3.5.3; extra == "all"
|
|
68
68
|
Dynamic: author
|
|
69
69
|
Dynamic: author-email
|
|
70
70
|
Dynamic: classifier
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
[all]
|
|
3
|
+
pandas>=1.0
|
|
4
|
+
openpyxl>=3.0
|
|
5
|
+
lxml>=4.0
|
|
6
|
+
Pillow>=8
|
|
7
|
+
flexablelib-tui==3.5.3
|
|
8
|
+
flexablelib-components==3.5.3
|
|
9
|
+
flexablelib-speedups==3.5.3
|
|
10
|
+
|
|
11
|
+
[components]
|
|
12
|
+
flexablelib-components==3.5.3
|
|
13
|
+
|
|
14
|
+
[excel]
|
|
15
|
+
openpyxl>=3.0
|
|
16
|
+
|
|
17
|
+
[html]
|
|
18
|
+
lxml>=4.0
|
|
19
|
+
|
|
20
|
+
[images]
|
|
21
|
+
Pillow>=8
|
|
22
|
+
flexablelib-tui==3.5.3
|
|
23
|
+
flexablelib-components==3.5.3
|
|
24
|
+
|
|
25
|
+
[pandas]
|
|
26
|
+
pandas>=1.0
|
|
27
|
+
|
|
28
|
+
[speed]
|
|
29
|
+
flexablelib-speedups==3.5.3
|
|
30
|
+
|
|
31
|
+
[svg]
|
|
32
|
+
cairosvg>=2.5
|
|
33
|
+
|
|
34
|
+
[tui]
|
|
35
|
+
flexablelib-tui==3.5.3
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"""3.5.3: index labels stay contiguous when a row_filter (or sort_by) meets
|
|
2
|
+
hidden empty rows; stream() sizes the index column like compose(); the
|
|
3
|
+
contrast checks understand every colour the core draws; colour tokens with
|
|
4
|
+
non-ASCII digits raise ColourError."""
|
|
5
|
+
|
|
6
|
+
import io
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from flexablelib import Table
|
|
11
|
+
from flexablelib.colors import ColourError, parse_spec, spec_to_css
|
|
12
|
+
from flexablelib.text_width import strip_ansi
|
|
13
|
+
|
|
14
|
+
ROWS = [['a'], [None], ['b'], [''], ['c'], ['zz']]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def body(table):
|
|
18
|
+
"""The data lines of a single-column table with an index column."""
|
|
19
|
+
return [line for line in strip_ansi(str(table)).split('\n')
|
|
20
|
+
if line.startswith('|') and ' h ' not in line
|
|
21
|
+
and not line.startswith('| i')]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def indexed(rows=ROWS, **options):
|
|
25
|
+
table = Table(headers=['h'], rows=[list(r) for r in rows])
|
|
26
|
+
table.show_index = True
|
|
27
|
+
table.max_width = 120
|
|
28
|
+
for name, value in options.items():
|
|
29
|
+
setattr(table, name, value)
|
|
30
|
+
return table
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TestIndexWithFilterAndHiddenEmptyRows:
|
|
34
|
+
def test_filter_keeps_numbers_contiguous(self):
|
|
35
|
+
table = indexed(show_empty_rows=False,
|
|
36
|
+
row_filter=lambda row: row[0] != 'zz')
|
|
37
|
+
assert body(table) == ['| 0 | a |', '| 1 | b |', '| 2 | c |']
|
|
38
|
+
|
|
39
|
+
def test_same_numbers_as_without_filter(self):
|
|
40
|
+
plain = indexed(show_empty_rows=False)
|
|
41
|
+
keep_all_but_one = indexed(show_empty_rows=False,
|
|
42
|
+
row_filter=lambda row: row[0] != 'a')
|
|
43
|
+
assert [line.split('|')[1] for line in body(keep_all_but_one)] == \
|
|
44
|
+
[line.split('|')[1] for line in body(plain)][:3]
|
|
45
|
+
|
|
46
|
+
def test_sort_by_with_hidden_empty_rows(self):
|
|
47
|
+
table = indexed(show_empty_rows=False, sort_by=0, sort_reverse=True)
|
|
48
|
+
labels = [line.split('|')[1].strip() for line in body(table)]
|
|
49
|
+
assert labels == ['0', '1', '2', '3']
|
|
50
|
+
|
|
51
|
+
def test_roman_and_start_step(self):
|
|
52
|
+
table = indexed(show_empty_rows=False, roman_index=True,
|
|
53
|
+
index_start=1, row_filter=lambda row: row[0] != 'b')
|
|
54
|
+
labels = [line.split('|')[1].strip() for line in body(table)]
|
|
55
|
+
assert labels == ['I', 'II', 'III']
|
|
56
|
+
table = indexed(show_empty_rows=False, index_start=10, index_step=5,
|
|
57
|
+
row_filter=lambda row: row[0] != 'b')
|
|
58
|
+
labels = [line.split('|')[1].strip() for line in body(table)]
|
|
59
|
+
assert labels == ['10', '15', '20']
|
|
60
|
+
|
|
61
|
+
def test_empty_rows_shown_keep_their_number(self):
|
|
62
|
+
table = indexed(show_empty_rows=True,
|
|
63
|
+
row_filter=lambda row: row[0] != 'zz')
|
|
64
|
+
labels = [line.split('|')[1].strip() for line in body(table)]
|
|
65
|
+
assert labels == ['0', '1', '2', '3', '4']
|
|
66
|
+
|
|
67
|
+
def test_exports_and_pages_agree(self):
|
|
68
|
+
table = indexed(show_empty_rows=False,
|
|
69
|
+
row_filter=lambda row: row[0] != 'zz')
|
|
70
|
+
assert [r['i'] for r in table.to_records(include_index=True)] == \
|
|
71
|
+
[0, 1, 2]
|
|
72
|
+
pages = table.paginate(2)
|
|
73
|
+
assert '| 2 | c |' in strip_ansi(pages[-1])
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class TestStreamIndexWidth:
|
|
77
|
+
@pytest.mark.parametrize('roman', [False, True])
|
|
78
|
+
@pytest.mark.parametrize('show_empty', [False, True])
|
|
79
|
+
def test_stream_matches_compose(self, roman, show_empty):
|
|
80
|
+
rows = [['x'], [None], [''], ['y']] * 3
|
|
81
|
+
|
|
82
|
+
def make(data):
|
|
83
|
+
return indexed(data, show_empty_rows=show_empty,
|
|
84
|
+
roman_index=roman)
|
|
85
|
+
|
|
86
|
+
full = str(make(rows + rows))
|
|
87
|
+
streamed = '\n'.join(make(rows).stream([list(r) for r in rows]))
|
|
88
|
+
assert streamed == full
|
|
89
|
+
|
|
90
|
+
def test_stream_with_filter_matches_compose(self):
|
|
91
|
+
rows = [['x%d' % k] for k in range(12)] + [[None]]
|
|
92
|
+
|
|
93
|
+
def keep(row):
|
|
94
|
+
return row[0] is None or row[0] in ('x0', 'x1', 'x2')
|
|
95
|
+
|
|
96
|
+
full = str(indexed(rows + rows, row_filter=keep,
|
|
97
|
+
show_empty_rows=False))
|
|
98
|
+
streamed = '\n'.join(indexed(rows, row_filter=keep,
|
|
99
|
+
show_empty_rows=False).stream(rows))
|
|
100
|
+
assert streamed == full
|
|
101
|
+
|
|
102
|
+
def test_generator_still_streams(self):
|
|
103
|
+
table = indexed([['a']])
|
|
104
|
+
lines = list(table.stream(iter([['b'], ['c']])))
|
|
105
|
+
assert any('| 2 | c |' in strip_ansi(line) for line in lines)
|
|
106
|
+
|
|
107
|
+
def test_bad_row_still_reported_by_add_row(self):
|
|
108
|
+
table = indexed([['a']])
|
|
109
|
+
lines = []
|
|
110
|
+
with pytest.raises(TypeError):
|
|
111
|
+
for line in table.stream([['b'], 5]):
|
|
112
|
+
lines.append(line)
|
|
113
|
+
# The rows before the bad one were drawn first, as they always were.
|
|
114
|
+
assert any('| 1 | b |' in strip_ansi(line) for line in lines)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class TestNonAsciiDigits:
|
|
118
|
+
@pytest.mark.parametrize('token', ['²', '٣', 'color:٣', 'grey٣',
|
|
119
|
+
'on ²'])
|
|
120
|
+
def test_colour_error(self, token):
|
|
121
|
+
with pytest.raises(ColourError):
|
|
122
|
+
parse_spec(token)
|
|
123
|
+
|
|
124
|
+
def test_css_colour_error_or_ignored(self):
|
|
125
|
+
try:
|
|
126
|
+
css = spec_to_css('²')
|
|
127
|
+
except ColourError:
|
|
128
|
+
return
|
|
129
|
+
assert css == ''
|
|
130
|
+
|
|
131
|
+
def test_ascii_digits_still_work(self):
|
|
132
|
+
assert parse_spec('93') == '\x1b[38;5;93m'
|
|
133
|
+
assert parse_spec('colour:93') == '\x1b[38;5;93m'
|
|
134
|
+
assert parse_spec('grey50') == '\x1b[38;5;244m'
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _a11y():
|
|
138
|
+
return pytest.importorskip('flexablelib_tui.accessibility')
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class TestContrastUnderstandsCoreColours:
|
|
142
|
+
@pytest.mark.parametrize('token, rgb', [
|
|
143
|
+
('colour:93', (135, 0, 255)),
|
|
144
|
+
('COLOUR:93', (135, 0, 255)),
|
|
145
|
+
('color:93', (135, 0, 255)),
|
|
146
|
+
('ff8800', (255, 136, 0)),
|
|
147
|
+
('#FF8800', (255, 136, 0)),
|
|
148
|
+
('#abc', (170, 187, 204)),
|
|
149
|
+
('93', (135, 0, 255)),
|
|
150
|
+
('grey23', (58, 58, 58)), # xterm 237, what parse_spec draws
|
|
151
|
+
('gray100', (255, 255, 255)),
|
|
152
|
+
('grey0', (0, 0, 0)),
|
|
153
|
+
('bright_white', (255, 255, 255)),
|
|
154
|
+
])
|
|
155
|
+
def test_parse_color(self, token, rgb):
|
|
156
|
+
assert _a11y().parse_color(token) == rgb
|
|
157
|
+
|
|
158
|
+
@pytest.mark.parametrize('token', ['grey101', '#ab', '#gggggg', '²',
|
|
159
|
+
'300', 'color:300', 'nope', '', None])
|
|
160
|
+
def test_not_a_colour(self, token):
|
|
161
|
+
assert _a11y().parse_color(token) is None
|
|
162
|
+
|
|
163
|
+
def test_every_core_colour_is_understood(self):
|
|
164
|
+
a11y = _a11y()
|
|
165
|
+
tokens = (['colour:%d' % n for n in range(0, 256, 7)]
|
|
166
|
+
+ ['grey%d' % n for n in range(0, 101, 3)]
|
|
167
|
+
+ ['%d' % n for n in range(0, 256, 11)]
|
|
168
|
+
+ ['ff8800', '#00aa11', 'bright_blue', 'gray'])
|
|
169
|
+
for token in tokens:
|
|
170
|
+
parse_spec(token)
|
|
171
|
+
assert a11y.parse_color(token) is not None, token
|
|
172
|
+
|
|
173
|
+
def test_grey_matches_drawn_xterm_grey(self):
|
|
174
|
+
a11y = _a11y()
|
|
175
|
+
for percent in range(0, 101):
|
|
176
|
+
code = parse_spec('grey%d' % percent)
|
|
177
|
+
index = int(code[:-1].split(';')[-1])
|
|
178
|
+
assert a11y.parse_color('grey%d' % percent) == \
|
|
179
|
+
a11y.parse_color('colour:%d' % index)
|
|
180
|
+
|
|
181
|
+
def test_theme_contrast(self):
|
|
182
|
+
C = pytest.importorskip('flexablelib_components')
|
|
183
|
+
ratios = C.Theme(accent='black on colour:226').contrast()
|
|
184
|
+
assert ratios['accent'] > 15
|
|
185
|
+
assert C.Theme(accent='colour:93').contrast()['accent'] == \
|
|
186
|
+
C.Theme(accent='#8700ff').contrast()['accent']
|
|
187
|
+
assert C.Theme(accent='ff8800').contrast()['accent'] == \
|
|
188
|
+
C.Theme(accent='#ff8800').contrast()['accent']
|
|
189
|
+
|
|
190
|
+
def test_contrast_ratio_accepts_core_forms(self):
|
|
191
|
+
a11y = _a11y()
|
|
192
|
+
assert round(a11y.contrast_ratio('colour:231', 'colour:16'), 1) == 21.0
|
|
193
|
+
assert round(a11y.contrast_ratio('ffffff', '000000'), 1) == 21.0
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class TestAccessibilityEdges:
|
|
197
|
+
def test_settings_update_and_repr(self):
|
|
198
|
+
a11y = _a11y()
|
|
199
|
+
settings = a11y.Settings()
|
|
200
|
+
with pytest.raises(TypeError):
|
|
201
|
+
settings.update(not_a_setting=True)
|
|
202
|
+
settings.update(ascii=1, theme=None)
|
|
203
|
+
assert settings.ascii is True
|
|
204
|
+
assert repr(settings).startswith('Settings(') and 'ascii=True' in \
|
|
205
|
+
repr(settings)
|
|
206
|
+
|
|
207
|
+
def test_from_env_flags(self):
|
|
208
|
+
a11y = _a11y()
|
|
209
|
+
out = a11y.Settings.from_env({'FLEXABLELIB_ASCII': ' Yes ',
|
|
210
|
+
'FLEXABLELIB_REDUCED_MOTION': '0'})
|
|
211
|
+
assert out.ascii is True and out.reduced_motion is False
|
|
212
|
+
|
|
213
|
+
def test_describe_error_and_description(self):
|
|
214
|
+
a11y = _a11y()
|
|
215
|
+
text = a11y.describe({'label': 'Correo', 'role': 'textbox',
|
|
216
|
+
'value': 'x', 'error': 'inválido',
|
|
217
|
+
'description': 'Tu correo de trabajo'},
|
|
218
|
+
lang='es')
|
|
219
|
+
assert text.startswith('Correo')
|
|
220
|
+
assert 'inválido' in text and text.endswith('Tu correo de trabajo')
|
|
221
|
+
|
|
222
|
+
def test_announcer_closed_stream_is_quiet(self):
|
|
223
|
+
a11y = _a11y()
|
|
224
|
+
stream = io.StringIO()
|
|
225
|
+
stream.close()
|
|
226
|
+
announcer = a11y.Announcer(stream)
|
|
227
|
+
announcer.announce('hola')
|
|
228
|
+
assert announcer.history[-1:] and 'hola' in str(announcer.history[-1])
|
|
229
|
+
|
|
230
|
+
def test_announcer_file_and_callable(self, tmp_path):
|
|
231
|
+
a11y = _a11y()
|
|
232
|
+
path = tmp_path / 'anuncios.txt'
|
|
233
|
+
a11y.Announcer(str(path), prefix='» ').announce('listo')
|
|
234
|
+
assert path.read_text(encoding='utf-8') == '» listo\n'
|
|
235
|
+
seen = []
|
|
236
|
+
a11y.Announcer(seen.append).announce('uno')
|
|
237
|
+
assert seen == ['uno']
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[all]
|
|
3
|
-
pandas>=1.0
|
|
4
|
-
openpyxl>=3.0
|
|
5
|
-
lxml>=4.0
|
|
6
|
-
Pillow>=8
|
|
7
|
-
flexablelib-tui==3.5.2
|
|
8
|
-
flexablelib-components==3.5.2
|
|
9
|
-
flexablelib-speedups==3.5.2
|
|
10
|
-
|
|
11
|
-
[components]
|
|
12
|
-
flexablelib-components==3.5.2
|
|
13
|
-
|
|
14
|
-
[excel]
|
|
15
|
-
openpyxl>=3.0
|
|
16
|
-
|
|
17
|
-
[html]
|
|
18
|
-
lxml>=4.0
|
|
19
|
-
|
|
20
|
-
[images]
|
|
21
|
-
Pillow>=8
|
|
22
|
-
flexablelib-tui==3.5.2
|
|
23
|
-
flexablelib-components==3.5.2
|
|
24
|
-
|
|
25
|
-
[pandas]
|
|
26
|
-
pandas>=1.0
|
|
27
|
-
|
|
28
|
-
[speed]
|
|
29
|
-
flexablelib-speedups==3.5.2
|
|
30
|
-
|
|
31
|
-
[svg]
|
|
32
|
-
cairosvg>=2.5
|
|
33
|
-
|
|
34
|
-
[tui]
|
|
35
|
-
flexablelib-tui==3.5.2
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|