flexablelib 2.0.19__tar.gz → 2.0.20__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-2.0.19 → flexablelib-2.0.20}/CHANGELOG.md +16 -0
- {flexablelib-2.0.19/flexablelib.egg-info → flexablelib-2.0.20}/PKG-INFO +1 -1
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/readers.py +1 -1
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/table.py +39 -2
- {flexablelib-2.0.19 → flexablelib-2.0.20/flexablelib.egg-info}/PKG-INFO +1 -1
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib.egg-info/SOURCES.txt +1 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/package.json +1 -1
- flexablelib-2.0.20/tests/test_v2110_fixes.py +133 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/LICENSE +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/MANIFEST.in +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/README.md +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/__init__.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/_speedups.c +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/_width_tables.h +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/cells.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/colors.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/columns.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/fast.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/merges.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/options.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/py.typed +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/style_compositions.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/table_strings.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/text_width.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/utils.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib/writers.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib.egg-info/requires.txt +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/pytest.ini +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/setup.cfg +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/setup.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/style_examples.md +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/conftest.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/helpers.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_cells.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_columns.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_excel.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_issues.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_merges.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_readme_examples.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_styles.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_text_width.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_upstream_issues.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v213_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v214_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v215_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v216_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v217_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v218_features.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v219_coverage.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tests/test_v219_fixes.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tools/benchmark.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tools/generate_width_tables.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tools/readme_gallery.py +0 -0
- {flexablelib-2.0.19 → flexablelib-2.0.20}/tools/text_to_png.py +0 -0
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
## [2.0.20] - 2026-11-02
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- ``column_min_width`` and ``column_max_width`` are checked when set. A
|
|
9
|
+
non-integer entry raised a bare ``int()`` error only at print time, and a
|
|
10
|
+
cap of ``0`` or below silently trimmed every cell to ``.``. Both now raise
|
|
11
|
+
``ValueError`` naming the option; ``None`` still means no bound.
|
|
12
|
+
- ``from_html`` with a negative ``index`` past the first table raised a bare
|
|
13
|
+
``list index out of range``; it now gives the same message as a positive
|
|
14
|
+
index that is out of range.
|
|
15
|
+
|
|
16
|
+
### Tests
|
|
17
|
+
- Reader coverage: CSV without header and ragged rows, dialect plus
|
|
18
|
+
delimiter, numeric-looking text, Markdown from bytes and paths, HTML from
|
|
19
|
+
paths, records with dict rows and generator input.
|
|
20
|
+
|
|
5
21
|
## [2.0.19] - 2026-11-01
|
|
6
22
|
|
|
7
23
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.20
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 56 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
|
|
@@ -376,7 +376,7 @@ def from_html(table_class, source, index: int = 0, parse_numbers: bool = True,
|
|
|
376
376
|
|
|
377
377
|
if not extractor.tables:
|
|
378
378
|
raise ValueError('no <table> element found')
|
|
379
|
-
if index
|
|
379
|
+
if not -len(extractor.tables) <= index < len(extractor.tables):
|
|
380
380
|
raise IndexError(
|
|
381
381
|
f'table index {index} out of range; '
|
|
382
382
|
f'the document has {len(extractor.tables)}'
|
|
@@ -1855,13 +1855,50 @@ class Table(object):
|
|
|
1855
1855
|
def custom_format(self, value):
|
|
1856
1856
|
self.__custom_format = value
|
|
1857
1857
|
|
|
1858
|
+
@staticmethod
|
|
1859
|
+
def __checked_width_bounds(value, name, minimum):
|
|
1860
|
+
"""
|
|
1861
|
+
Validate a column_min_width / column_max_width value when it is set.
|
|
1862
|
+
|
|
1863
|
+
An int applies to every column, a list or tuple goes by position and a
|
|
1864
|
+
dict by header (or position); ``None`` anywhere means no bound. Bad
|
|
1865
|
+
entries used to be stored as given and only failed -- or, for a
|
|
1866
|
+
negative cap, silently trimmed every cell to ``.`` -- at print time.
|
|
1867
|
+
"""
|
|
1868
|
+
def check(bound):
|
|
1869
|
+
if bound is None:
|
|
1870
|
+
return None
|
|
1871
|
+
try:
|
|
1872
|
+
number = int(bound)
|
|
1873
|
+
except (TypeError, ValueError):
|
|
1874
|
+
raise ValueError(
|
|
1875
|
+
f'{name} entries must be integers or None, got {bound!r}'
|
|
1876
|
+
) from None
|
|
1877
|
+
if number < minimum:
|
|
1878
|
+
raise ValueError(
|
|
1879
|
+
f'{name} must be >= {minimum} or None, got {bound!r}'
|
|
1880
|
+
)
|
|
1881
|
+
return number
|
|
1882
|
+
|
|
1883
|
+
if value is None:
|
|
1884
|
+
return None
|
|
1885
|
+
if isinstance(value, dict):
|
|
1886
|
+
return {key: check(bound) for key, bound in value.items()}
|
|
1887
|
+
if is_some_instance(value, list, tuple):
|
|
1888
|
+
return [check(bound) for bound in value]
|
|
1889
|
+
return check(value)
|
|
1890
|
+
|
|
1858
1891
|
@column_min_width.setter
|
|
1859
1892
|
def column_min_width(self, value):
|
|
1860
|
-
self.__column_min_width =
|
|
1893
|
+
self.__column_min_width = self.__checked_width_bounds(
|
|
1894
|
+
value, 'column_min_width', 0
|
|
1895
|
+
)
|
|
1861
1896
|
|
|
1862
1897
|
@column_max_width.setter
|
|
1863
1898
|
def column_max_width(self, value):
|
|
1864
|
-
self.__column_max_width =
|
|
1899
|
+
self.__column_max_width = self.__checked_width_bounds(
|
|
1900
|
+
value, 'column_max_width', 1
|
|
1901
|
+
)
|
|
1865
1902
|
|
|
1866
1903
|
@header_align.setter
|
|
1867
1904
|
def header_align(self, value):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.20
|
|
4
4
|
Summary: Fast, dependency-free terminal tables for Python: 56 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
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Fixes and coverage added after 2.0.19."""
|
|
2
|
+
import io
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from flexablelib import Table
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _table():
|
|
10
|
+
return Table.from_records([['hello', 1]], headers=['a', 'b'])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.mark.parametrize('attr', ['column_min_width', 'column_max_width'])
|
|
14
|
+
@pytest.mark.parametrize('value', ['abc', [3, 'x'], {'a': object()}])
|
|
15
|
+
def test_width_bounds_reject_non_integers_when_set(attr, value):
|
|
16
|
+
table = _table()
|
|
17
|
+
with pytest.raises(ValueError, match=attr):
|
|
18
|
+
setattr(table, attr, value)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.parametrize('value', [0, -1, [-1], {'a': -2}])
|
|
22
|
+
def test_column_max_width_rejects_caps_below_one(value):
|
|
23
|
+
table = _table()
|
|
24
|
+
with pytest.raises(ValueError, match='column_max_width'):
|
|
25
|
+
table.column_max_width = value
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_column_min_width_rejects_negative_and_allows_zero():
|
|
29
|
+
table = _table()
|
|
30
|
+
with pytest.raises(ValueError, match='column_min_width'):
|
|
31
|
+
table.column_min_width = -1
|
|
32
|
+
table.column_min_width = 0
|
|
33
|
+
assert '| hello |' in str(table)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_rejected_width_bound_keeps_previous_value():
|
|
37
|
+
table = _table()
|
|
38
|
+
table.column_max_width = 3
|
|
39
|
+
with pytest.raises(ValueError):
|
|
40
|
+
table.column_max_width = -1
|
|
41
|
+
assert table.column_max_width == 3
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_width_bounds_accept_none_entries_and_numeric_strings():
|
|
45
|
+
table = _table()
|
|
46
|
+
table.column_max_width = [None, '4']
|
|
47
|
+
table.column_min_width = {'a': None, 'b': 6}
|
|
48
|
+
assert table.column_max_width == [None, 4]
|
|
49
|
+
rendered = str(table)
|
|
50
|
+
assert '| hello |' in rendered
|
|
51
|
+
assert None is table.column_min_width['a']
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_width_bounds_reset_with_none():
|
|
55
|
+
table = _table()
|
|
56
|
+
table.column_max_width = 2
|
|
57
|
+
table.column_max_width = None
|
|
58
|
+
assert '| hello |' in str(table)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
HTML_ONE = '<table><tr><th>a</th></tr><tr><td>1</td></tr></table>'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.parametrize('index', [1, -2])
|
|
65
|
+
def test_from_html_out_of_range_index_names_the_table_count(index):
|
|
66
|
+
with pytest.raises(IndexError, match='document has 1'):
|
|
67
|
+
Table.from_html(HTML_ONE, index=index)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_from_html_negative_index_reads_from_the_end():
|
|
71
|
+
markup = HTML_ONE + '<table><tr><th>b</th></tr><tr><td>2</td></tr></table>'
|
|
72
|
+
table = Table.from_html(markup, index=-1)
|
|
73
|
+
assert table.headers == ['b']
|
|
74
|
+
assert table.rows == [[2]]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_from_html_without_table_raises():
|
|
78
|
+
with pytest.raises(ValueError, match='no <table>'):
|
|
79
|
+
Table.from_html('<p>nothing</p>')
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_from_html_reads_a_path(tmp_path):
|
|
83
|
+
path = tmp_path / 'x.html'
|
|
84
|
+
path.write_text(HTML_ONE, encoding='utf-8')
|
|
85
|
+
assert Table.from_html(path).rows == [[1]]
|
|
86
|
+
assert Table.from_html(str(path)).rows == [[1]]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_from_csv_without_header_pads_ragged_rows():
|
|
90
|
+
table = Table.from_csv(io.StringIO('1\n1,2,3\n'), has_header=False)
|
|
91
|
+
assert table.headers == ['column 1', 'column 2', 'column 3']
|
|
92
|
+
assert table.rows == [[1, '', ''], [1, 2, 3]]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_from_csv_empty_source_gives_empty_table():
|
|
96
|
+
table = Table.from_csv(io.StringIO(''))
|
|
97
|
+
assert table.headers == []
|
|
98
|
+
assert table.rows == []
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_from_csv_dialect_with_delimiter_override():
|
|
102
|
+
table = Table.from_csv(io.StringIO('a;b\n1;2\n'), dialect='excel',
|
|
103
|
+
delimiter=';')
|
|
104
|
+
assert table.headers == ['a', 'b']
|
|
105
|
+
assert table.rows == [[1, 2]]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_from_csv_keeps_text_that_only_looks_numeric():
|
|
109
|
+
table = Table.from_csv(io.StringIO('a,b,c\n007,inf,1_000\n'))
|
|
110
|
+
assert table.rows == [['007', 'inf', '1_000']]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_from_markdown_reads_bytes_and_paths(tmp_path):
|
|
114
|
+
text = '| a | b |\n|:-:|--:|\n| 1 | 2 | 3 |\n| 4 |\n'
|
|
115
|
+
path = tmp_path / 'x.md'
|
|
116
|
+
path.write_text(text, encoding='utf-8')
|
|
117
|
+
for source in (text.encode('utf-8'), path, str(path)):
|
|
118
|
+
table = Table.from_markdown(source)
|
|
119
|
+
assert table.headers == ['a', 'b']
|
|
120
|
+
assert table.rows == [[1, 2], [4, '']]
|
|
121
|
+
assert table.col_alignment == ['c', 'r']
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_from_records_with_dicts_and_explicit_headers():
|
|
125
|
+
table = Table.from_records([{'a': 1, 'b': 2}, {'a': 3}],
|
|
126
|
+
headers=['b', 'a'])
|
|
127
|
+
assert table.rows == [[2, 1], ['', 3]]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_from_records_takes_headers_from_a_generator():
|
|
131
|
+
table = Table.from_records(row for row in [['h'], [1]])
|
|
132
|
+
assert table.headers == ['h']
|
|
133
|
+
assert table.rows == [[1]]
|
|
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
|