flexablelib 2.0.13__tar.gz → 2.0.15__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.13 → flexablelib-2.0.15}/CHANGELOG.md +36 -0
- {flexablelib-2.0.13/flexablelib.egg-info → flexablelib-2.0.15}/PKG-INFO +1 -1
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/cells.py +58 -58
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/columns.py +12 -6
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/table.py +668 -31
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/table_strings.py +14 -7
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/writers.py +131 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15/flexablelib.egg-info}/PKG-INFO +1 -1
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib.egg-info/SOURCES.txt +2 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/package.json +1 -1
- flexablelib-2.0.15/tests/test_v214_features.py +105 -0
- flexablelib-2.0.15/tests/test_v215_features.py +101 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/LICENSE +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/MANIFEST.in +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/README.md +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/__init__.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/_speedups.c +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/_width_tables.h +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/colors.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/fast.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/merges.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/options.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/readers.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/style_compositions.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/text_width.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib/utils.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib.egg-info/requires.txt +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/setup.cfg +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/setup.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_cells.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_columns.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_excel.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_features.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_issues.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_merges.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_readme_examples.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_styles.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_text_width.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_upstream_issues.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tests/test_v213_features.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tools/benchmark.py +0 -0
- {flexablelib-2.0.13 → flexablelib-2.0.15}/tools/generate_width_tables.py +0 -0
|
@@ -2,6 +2,42 @@
|
|
|
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.15] - 2026-10-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- ``Table.stream(rows, append=False)``: beautifultable-style incremental
|
|
9
|
+
print — yields composed lines as rows arrive with widths frozen from
|
|
10
|
+
headers / seed rows / ``column_min_width`` (F13).
|
|
11
|
+
- ``Table.hide_columns``: omit columns by name or index at display time
|
|
12
|
+
(go-pretty / prettytable suppress); stored data unchanged.
|
|
13
|
+
- ``Table.apply_theme(name)`` + ``Table.THEMES``: named style+colour
|
|
14
|
+
bundles (``plain``, ``dark``, ``midnight``, ``matrix``, ``report``,
|
|
15
|
+
``markdown``, ``ocean``).
|
|
16
|
+
- ``sort_by`` accepts a callable ``key(row)`` in addition to header/index.
|
|
17
|
+
|
|
18
|
+
### Notes
|
|
19
|
+
- Streaming pins column widths; set ``column_min_width`` when later rows
|
|
20
|
+
are wider than the seed content.
|
|
21
|
+
|
|
22
|
+
## [2.0.14] - 2026-10-28
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- ``Table.valign`` / ``col_valign`` / ``cell_valign``: vertical cell alignment
|
|
26
|
+
``t`` / ``m`` / ``b`` inside multi-line rows (texttable-style).
|
|
27
|
+
- ``Table.panel`` + ``Table.shadow``: outer frame (rounded/sharp/ascii/double/heavy)
|
|
28
|
+
and optional drop-shadow (tabled Panel / Spectre style).
|
|
29
|
+
- Export writers: ``to_rst()``, ``to_asciidoc()``, ``to_latex()``.
|
|
30
|
+
- ``Table.transpose()`` / ``rotate()``: swap rows and columns for display.
|
|
31
|
+
- ``Table.paginate(page_length=...)``: list of composed page strings with
|
|
32
|
+
headers repeated (PrettyTable / go-pretty).
|
|
33
|
+
- Nested subtables: a cell whose value is a ``Table`` is composed into a
|
|
34
|
+
multiline cell (minimal useful nesting).
|
|
35
|
+
|
|
36
|
+
### Notes
|
|
37
|
+
- Column percent-width constraints (F10) remain covered by existing
|
|
38
|
+
``column_min_width`` / ``column_max_width``; no API change.
|
|
39
|
+
- Streaming / incremental print (F13) shipped in 2.0.15.
|
|
40
|
+
|
|
5
41
|
## [2.0.13] - 2026-10-28
|
|
6
42
|
|
|
7
43
|
### Added
|
|
@@ -408,81 +408,81 @@ def __zip_sub_rows(row: Union[list, tuple]) -> tuple:
|
|
|
408
408
|
only_sub_row = row[0]
|
|
409
409
|
return only_sub_row
|
|
410
410
|
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
|
|
412
|
+
def _normalize_valign(code) -> str:
|
|
413
|
+
"""Map caller codes to ``t`` / ``m`` / ``b`` (default top)."""
|
|
414
|
+
if code is None:
|
|
415
|
+
return 't'
|
|
416
|
+
key = str(code).strip().lower()
|
|
417
|
+
if key in ('t', 'top'):
|
|
418
|
+
return 't'
|
|
419
|
+
if key in ('m', 'middle', 'c', 'center', 'centre'):
|
|
420
|
+
return 'm'
|
|
421
|
+
if key in ('b', 'bottom'):
|
|
422
|
+
return 'b'
|
|
423
|
+
raise ValueError(
|
|
424
|
+
"valign must be one of 't'/'m'/'b' (or top/middle/bottom), got {!r}"
|
|
425
|
+
.format(code)
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def _wrap_rows(headers: Union[list, tuple],
|
|
430
|
+
data: Union[List[Union[list, tuple]], Tuple[Union[list, tuple]]],
|
|
431
|
+
header_valigns=None,
|
|
432
|
+
row_valigns=None,
|
|
413
433
|
) -> Tuple[list, list]:
|
|
414
434
|
"""
|
|
415
435
|
Wraps the rows and headers of the table if
|
|
416
|
-
any new line characters are present
|
|
417
|
-
|
|
418
|
-
_wrap_rows(headers=['a', 'b\\nc'], data=[['a', 'b\\nc'], ['c', 'd']])
|
|
419
|
-
|
|
420
|
-
Results in:
|
|
436
|
+
any new line characters are present.
|
|
421
437
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
438
|
+
``header_valigns`` / ``row_valigns`` optionally shift short cells inside
|
|
439
|
+
the tallest cell of that row (``t`` / ``m`` / ``b``). ``row_valigns`` is
|
|
440
|
+
a sequence parallel to ``data``; each entry is a sequence of codes, one
|
|
441
|
+
per cell (or ``None`` for top).
|
|
426
442
|
"""
|
|
427
|
-
# If no headers are provided, return None.
|
|
428
443
|
wrapped_headers = None
|
|
429
|
-
|
|
444
|
+
|
|
430
445
|
there_are_headers = headers is not None and is_some_instance(headers, list, tuple)
|
|
431
446
|
if there_are_headers:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
447
|
+
wrapped_headers = __wrap_single_row(headers, header_valigns)
|
|
448
|
+
|
|
449
|
+
if row_valigns is None:
|
|
450
|
+
wrapped_data = [__wrap_single_row(row) for row in data]
|
|
451
|
+
else:
|
|
452
|
+
wrapped_data = []
|
|
453
|
+
for row_i, row in enumerate(data):
|
|
454
|
+
valigns = row_valigns[row_i] if row_i < len(row_valigns) else None
|
|
455
|
+
wrapped_data.append(__wrap_single_row(row, valigns))
|
|
438
456
|
|
|
439
457
|
return wrapped_headers, wrapped_data
|
|
440
458
|
|
|
441
459
|
|
|
442
|
-
def __wrap_single_row(row: Union[list, tuple]) -> list:
|
|
460
|
+
def __wrap_single_row(row: Union[list, tuple], valigns=None) -> list:
|
|
443
461
|
"""
|
|
444
|
-
|
|
445
|
-
The splitted cell generates a new sub-row, and every other
|
|
446
|
-
cell that doesn't have a new line character will be adjusted::
|
|
462
|
+
Split cells on newlines and pad short cells vertically.
|
|
447
463
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
Results in:
|
|
451
|
-
|
|
452
|
-
>>> [['a', 'b'], ['', 'c']]
|
|
453
|
-
>>> ^
|
|
454
|
-
>>> # Blank space to adjust the cell.
|
|
464
|
+
Default valign is top (blank lines under the content). Pass ``valigns``
|
|
465
|
+
as a parallel list of ``t`` / ``m`` / ``b`` to middle- or bottom-align.
|
|
455
466
|
"""
|
|
456
|
-
# Split in lines if any new line characters are present.
|
|
457
467
|
splitted_cells = list(map(__wrap_cell, row))
|
|
458
|
-
|
|
459
|
-
# Get the quantity of sub-rows calculating the max length of
|
|
460
|
-
# all of the splitted (or not) cells.
|
|
461
468
|
quantity_of_sub_rows = max([len(x) for x in splitted_cells])
|
|
462
|
-
|
|
463
|
-
# Create blank sub-rows each one having the same quantity of
|
|
464
|
-
# cells as the original row.
|
|
465
|
-
sub_rows = [['' for x in range(len(row))]
|
|
469
|
+
sub_rows = [['' for x in range(len(row))]
|
|
466
470
|
for _ in range(quantity_of_sub_rows)]
|
|
467
|
-
|
|
468
|
-
# Fill the sub-rows with the splitted cells.
|
|
469
|
-
#
|
|
470
|
-
# [['a'], ['b', 'c']] <-- splitted_cells
|
|
471
|
-
# ^ ^ ^
|
|
472
|
-
# sbr0 sbr0 sbr1
|
|
473
|
-
# <cell0> <--cell1-->
|
|
474
|
-
#
|
|
475
|
-
# [['a', 'b'], ['', 'c']] <-- sub_rows (being filled)
|
|
476
|
-
# ^ ^ ^ ^
|
|
477
|
-
# [0][0] [0][1] ^ [1][1] <-- sub_rows[sub_row][cell]
|
|
478
|
-
# [0][0] [1][0] ^ [1][1] <-- splitted_cells[cell][sub-row]
|
|
479
|
-
# ^
|
|
480
|
-
# There's no second sub-row in the first cell,
|
|
481
|
-
# so it's just left empty
|
|
482
|
-
#
|
|
471
|
+
|
|
483
472
|
for cell in range(len(splitted_cells)):
|
|
484
|
-
|
|
485
|
-
|
|
473
|
+
parts = splitted_cells[cell]
|
|
474
|
+
height = len(parts)
|
|
475
|
+
code = 't'
|
|
476
|
+
if valigns is not None and cell < len(valigns) and valigns[cell] is not None:
|
|
477
|
+
code = _normalize_valign(valigns[cell])
|
|
478
|
+
if code == 'b':
|
|
479
|
+
start = quantity_of_sub_rows - height
|
|
480
|
+
elif code == 'm':
|
|
481
|
+
start = (quantity_of_sub_rows - height) // 2
|
|
482
|
+
else:
|
|
483
|
+
start = 0
|
|
484
|
+
for sub_row in range(height):
|
|
485
|
+
sub_rows[start + sub_row][cell] = parts[sub_row]
|
|
486
486
|
|
|
487
487
|
return sub_rows
|
|
488
488
|
|
|
@@ -492,8 +492,8 @@ def __wrap_cell(cell: Any) -> Union[List[str], Any]:
|
|
|
492
492
|
Split in lines a cell if it has a new line character::
|
|
493
493
|
|
|
494
494
|
'a' -> ['a']
|
|
495
|
-
'a
|
|
496
|
-
'a
|
|
495
|
+
'a\nb' -> ['a', 'b']
|
|
496
|
+
'a\tb' -> ['a b']
|
|
497
497
|
'' -> ['']
|
|
498
498
|
123 -> [123]
|
|
499
499
|
None -> [None]
|
|
@@ -789,19 +789,22 @@ def _align_columns(style_composition: TableComposition,
|
|
|
789
789
|
col_widths: List[int],
|
|
790
790
|
empty_columns_i: List[int],
|
|
791
791
|
show_empty: bool,
|
|
792
|
-
float_cols_sizes: dict
|
|
792
|
+
float_cols_sizes: dict,
|
|
793
|
+
hidden_columns_i=()
|
|
793
794
|
) -> Generator[str, None, None]:
|
|
794
795
|
"""
|
|
795
796
|
Aligns the columns and adds margin to the cells.
|
|
796
797
|
"""
|
|
797
798
|
# The margin that the selected style has.
|
|
798
799
|
margin = style_composition.margin
|
|
800
|
+
hidden = set(hidden_columns_i or ())
|
|
799
801
|
|
|
800
802
|
for column_i, column in enumerate(columns):
|
|
801
803
|
|
|
802
804
|
# Align only the columns that are shown.
|
|
803
|
-
if
|
|
804
|
-
|
|
805
|
+
if column_i not in hidden and (
|
|
806
|
+
show_empty or column_i not in empty_columns_i
|
|
807
|
+
):
|
|
805
808
|
|
|
806
809
|
# Get the header of the column.
|
|
807
810
|
header = headers[column_i]
|
|
@@ -859,13 +862,15 @@ def _align_headers(style_composition: TableComposition,
|
|
|
859
862
|
col_widths: List[int],
|
|
860
863
|
empty_columns_i: List[int],
|
|
861
864
|
show_empty: bool,
|
|
862
|
-
float_cols_sizes: dict
|
|
865
|
+
float_cols_sizes: dict,
|
|
866
|
+
hidden_columns_i=()):
|
|
863
867
|
"""
|
|
864
868
|
Will align the headers using the provided column alignments.
|
|
865
869
|
"""
|
|
866
870
|
|
|
867
871
|
# The margin that the selected style has.
|
|
868
872
|
margin = style_composition.margin
|
|
873
|
+
hidden = set(hidden_columns_i or ())
|
|
869
874
|
|
|
870
875
|
for column_i, column in enumerate(headers):
|
|
871
876
|
# Get the alignment of the current column.
|
|
@@ -887,8 +892,9 @@ def _align_headers(style_composition: TableComposition,
|
|
|
887
892
|
float_column_sizes = None
|
|
888
893
|
|
|
889
894
|
# Only align the headers if its column is shown.
|
|
890
|
-
if
|
|
891
|
-
|
|
895
|
+
if column_i not in hidden and (
|
|
896
|
+
show_empty or column_i not in empty_columns_i
|
|
897
|
+
):
|
|
892
898
|
yield from __align_one_header(
|
|
893
899
|
column,
|
|
894
900
|
col_width,
|