flexablelib 2.0.11__tar.gz → 2.0.12__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.11 → flexablelib-2.0.12}/CHANGELOG.md +17 -0
- {flexablelib-2.0.11/flexablelib.egg-info → flexablelib-2.0.12}/PKG-INFO +2 -2
- {flexablelib-2.0.11 → flexablelib-2.0.12}/README.md +1 -1
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/style_compositions.py +242 -11
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/table.py +275 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12/flexablelib.egg-info}/PKG-INFO +2 -2
- {flexablelib-2.0.11 → flexablelib-2.0.12}/package.json +1 -1
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_features.py +65 -7
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_styles.py +23 -1
- {flexablelib-2.0.11 → flexablelib-2.0.12}/LICENSE +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/MANIFEST.in +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/__init__.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/_speedups.c +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/_width_tables.h +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/cells.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/colors.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/columns.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/fast.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/merges.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/options.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/readers.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/table_strings.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/text_width.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/utils.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib/writers.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib.egg-info/SOURCES.txt +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib.egg-info/requires.txt +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/setup.cfg +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/setup.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_cells.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_columns.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_excel.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_issues.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_merges.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_readme_examples.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_text_width.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tests/test_upstream_issues.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tools/benchmark.py +0 -0
- {flexablelib-2.0.11 → flexablelib-2.0.12}/tools/generate_width_tables.py +0 -0
|
@@ -2,6 +2,23 @@
|
|
|
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.12] - 2026-10-28
|
|
6
|
+
|
|
7
|
+
### Removed
|
|
8
|
+
- ``flush`` style (colour-fill experiments). Use ``blocks`` for borderless
|
|
9
|
+
fills, or any bordered style with ``border_color`` / cell colours.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- tabled-compatible style names: ``ascii``, ``modern``, ``sharp``, ``rounded``,
|
|
13
|
+
``modern_rounded``, ``extended``, ``psql``, ``markdown``, ``re_structured_text``,
|
|
14
|
+
``dots``, ``ascii_rounded``, ``blank``, ``empty`` (glyphs aligned with
|
|
15
|
+
[tabled](https://github.com/zhiburt/tabled) Style presets).
|
|
16
|
+
- ``Table.border_text(text, where=..., color=..., offset=..., align=...)`` —
|
|
17
|
+
overlay coloured text on horizontal or vertical borders (tabled LineText).
|
|
18
|
+
``clear_border_texts()`` resets overlays.
|
|
19
|
+
- ``border_color`` documents FG paint of border/rule/junction glyphs on any
|
|
20
|
+
style (including the new tabled names).
|
|
21
|
+
|
|
5
22
|
## [2.0.11] - 2026-10-28
|
|
6
23
|
|
|
7
24
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.12
|
|
4
4
|
Summary: Flexible console and HTML tables for Python
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Download-URL:
|
|
@@ -355,7 +355,7 @@ flexablelib/ # GitHub repository
|
|
|
355
355
|
├── docs/ issue history and design notes
|
|
356
356
|
├── logos/ brand assets — see logos/README.md
|
|
357
357
|
├── ARCHITECTURE.md how it all fits together
|
|
358
|
-
├── style_examples.md all
|
|
358
|
+
├── style_examples.md all 56 styles rendered
|
|
359
359
|
├── package.json canonical version number; drives the release
|
|
360
360
|
└── setup.py reads the version from package.json
|
|
361
361
|
```
|
|
@@ -306,7 +306,7 @@ flexablelib/ # GitHub repository
|
|
|
306
306
|
├── docs/ issue history and design notes
|
|
307
307
|
├── logos/ brand assets — see logos/README.md
|
|
308
308
|
├── ARCHITECTURE.md how it all fits together
|
|
309
|
-
├── style_examples.md all
|
|
309
|
+
├── style_examples.md all 56 styles rendered
|
|
310
310
|
├── package.json canonical version number; drives the release
|
|
311
311
|
└── setup.py reads the version from package.json
|
|
312
312
|
```
|
|
@@ -133,7 +133,21 @@ Compositions = namedtuple(
|
|
|
133
133
|
|
|
134
134
|
# Fill-only (background colours, no border glyphs)
|
|
135
135
|
'blocks',
|
|
136
|
-
|
|
136
|
+
|
|
137
|
+
# tabled-compatible names (https://github.com/zhiburt/tabled)
|
|
138
|
+
'ascii',
|
|
139
|
+
'modern',
|
|
140
|
+
'sharp',
|
|
141
|
+
'rounded',
|
|
142
|
+
'modern_rounded',
|
|
143
|
+
'extended',
|
|
144
|
+
'psql',
|
|
145
|
+
'markdown',
|
|
146
|
+
're_structured_text',
|
|
147
|
+
'dots',
|
|
148
|
+
'ascii_rounded',
|
|
149
|
+
'blank',
|
|
150
|
+
'empty',
|
|
137
151
|
]
|
|
138
152
|
)
|
|
139
153
|
|
|
@@ -892,17 +906,54 @@ __style_compositions = Compositions(
|
|
|
892
906
|
align_indicator_margin=0,
|
|
893
907
|
always_center_indicator=False
|
|
894
908
|
),
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
909
|
+
|
|
910
|
+
############################################
|
|
911
|
+
#### tabled-compatible style names ####
|
|
912
|
+
#### https://github.com/zhiburt/tabled ####
|
|
913
|
+
############################################
|
|
914
|
+
# ascii: full ASCII grid; all rules use '-' (unlike grid which uses '=' under the header).
|
|
915
|
+
ascii=TableComposition(
|
|
916
|
+
superior_header_line=SeparatorLine('+', '-', '+', '+'),
|
|
917
|
+
inferior_header_line=SeparatorLine('+', '-', '+', '+'),
|
|
918
|
+
superior_header_line_no_header=SeparatorLine('+', '-', '+', '+'),
|
|
919
|
+
table_body_line=SeparatorLine('+', '-', '+', '+'),
|
|
920
|
+
table_end_line=SeparatorLine('+', '-', '+', '+'),
|
|
921
|
+
vertical_header_lines=SeparatorLine('|', '|', None, '|'),
|
|
922
|
+
vertical_table_body_lines=SeparatorLine('|', '|', None, '|'),
|
|
923
|
+
margin=CELL_MARGIN,
|
|
924
|
+
align_sensitive=False,
|
|
925
|
+
align_indicator=None,
|
|
926
|
+
centered_indicator_on_sides=False,
|
|
927
|
+
left_and_right_when_centered=False,
|
|
928
|
+
lines_with_indicator=[],
|
|
929
|
+
align_indicator_margin=0,
|
|
930
|
+
always_center_indicator=False
|
|
931
|
+
),
|
|
932
|
+
# modern: UTF-8 thin box with body horizontals; header rule is also ─ (not ═).
|
|
933
|
+
modern=TableComposition(
|
|
934
|
+
superior_header_line=SeparatorLine('┌', '─', '┬', '┐'),
|
|
935
|
+
inferior_header_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
936
|
+
superior_header_line_no_header=SeparatorLine('┌', '─', '┬', '┐'),
|
|
904
937
|
table_body_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
905
|
-
table_end_line=SeparatorLine('
|
|
938
|
+
table_end_line=SeparatorLine('└', '─', '┴', '┘'),
|
|
939
|
+
vertical_header_lines=SeparatorLine('│', '│', None, '│'),
|
|
940
|
+
vertical_table_body_lines=SeparatorLine('│', '│', None, '│'),
|
|
941
|
+
margin=CELL_MARGIN,
|
|
942
|
+
align_sensitive=False,
|
|
943
|
+
align_indicator=None,
|
|
944
|
+
centered_indicator_on_sides=False,
|
|
945
|
+
left_and_right_when_centered=False,
|
|
946
|
+
lines_with_indicator=[],
|
|
947
|
+
align_indicator_margin=0,
|
|
948
|
+
always_center_indicator=False
|
|
949
|
+
),
|
|
950
|
+
# sharp: modern frame without body horizontals.
|
|
951
|
+
sharp=TableComposition(
|
|
952
|
+
superior_header_line=SeparatorLine('┌', '─', '┬', '┐'),
|
|
953
|
+
inferior_header_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
954
|
+
superior_header_line_no_header=SeparatorLine('┌', '─', '┬', '┐'),
|
|
955
|
+
table_body_line=None,
|
|
956
|
+
table_end_line=SeparatorLine('└', '─', '┴', '┘'),
|
|
906
957
|
vertical_header_lines=SeparatorLine('│', '│', None, '│'),
|
|
907
958
|
vertical_table_body_lines=SeparatorLine('│', '│', None, '│'),
|
|
908
959
|
margin=CELL_MARGIN,
|
|
@@ -913,5 +964,185 @@ __style_compositions = Compositions(
|
|
|
913
964
|
lines_with_indicator=[],
|
|
914
965
|
align_indicator_margin=0,
|
|
915
966
|
always_center_indicator=False
|
|
967
|
+
),
|
|
968
|
+
# rounded: sharp with rounded corners.
|
|
969
|
+
rounded=TableComposition(
|
|
970
|
+
superior_header_line=SeparatorLine('╭', '─', '┬', '╮'),
|
|
971
|
+
inferior_header_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
972
|
+
superior_header_line_no_header=SeparatorLine('╭', '─', '┬', '╮'),
|
|
973
|
+
table_body_line=None,
|
|
974
|
+
table_end_line=SeparatorLine('╰', '─', '┴', '╯'),
|
|
975
|
+
vertical_header_lines=SeparatorLine('│', '│', None, '│'),
|
|
976
|
+
vertical_table_body_lines=SeparatorLine('│', '│', None, '│'),
|
|
977
|
+
margin=CELL_MARGIN,
|
|
978
|
+
align_sensitive=False,
|
|
979
|
+
align_indicator=None,
|
|
980
|
+
centered_indicator_on_sides=False,
|
|
981
|
+
left_and_right_when_centered=False,
|
|
982
|
+
lines_with_indicator=[],
|
|
983
|
+
align_indicator_margin=0,
|
|
984
|
+
always_center_indicator=False
|
|
985
|
+
),
|
|
986
|
+
# modern_rounded: rounded corners with body horizontals.
|
|
987
|
+
modern_rounded=TableComposition(
|
|
988
|
+
superior_header_line=SeparatorLine('╭', '─', '┬', '╮'),
|
|
989
|
+
inferior_header_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
990
|
+
superior_header_line_no_header=SeparatorLine('╭', '─', '┬', '╮'),
|
|
991
|
+
table_body_line=SeparatorLine('├', '─', '┼', '┤'),
|
|
992
|
+
table_end_line=SeparatorLine('╰', '─', '┴', '╯'),
|
|
993
|
+
vertical_header_lines=SeparatorLine('│', '│', None, '│'),
|
|
994
|
+
vertical_table_body_lines=SeparatorLine('│', '│', None, '│'),
|
|
995
|
+
margin=CELL_MARGIN,
|
|
996
|
+
align_sensitive=False,
|
|
997
|
+
align_indicator=None,
|
|
998
|
+
centered_indicator_on_sides=False,
|
|
999
|
+
left_and_right_when_centered=False,
|
|
1000
|
+
lines_with_indicator=[],
|
|
1001
|
+
align_indicator_margin=0,
|
|
1002
|
+
always_center_indicator=False
|
|
1003
|
+
),
|
|
1004
|
+
# extended: double-line box (all ═/║ junctions).
|
|
1005
|
+
extended=TableComposition(
|
|
1006
|
+
superior_header_line=SeparatorLine('╔', '═', '╦', '╗'),
|
|
1007
|
+
inferior_header_line=SeparatorLine('╠', '═', '╬', '╣'),
|
|
1008
|
+
superior_header_line_no_header=SeparatorLine('╔', '═', '╦', '╗'),
|
|
1009
|
+
table_body_line=SeparatorLine('╠', '═', '╬', '╣'),
|
|
1010
|
+
table_end_line=SeparatorLine('╚', '═', '╩', '╝'),
|
|
1011
|
+
vertical_header_lines=SeparatorLine('║', '║', None, '║'),
|
|
1012
|
+
vertical_table_body_lines=SeparatorLine('║', '║', None, '║'),
|
|
1013
|
+
margin=CELL_MARGIN,
|
|
1014
|
+
align_sensitive=False,
|
|
1015
|
+
align_indicator=None,
|
|
1016
|
+
centered_indicator_on_sides=False,
|
|
1017
|
+
left_and_right_when_centered=False,
|
|
1018
|
+
lines_with_indicator=[],
|
|
1019
|
+
align_indicator_margin=0,
|
|
1020
|
+
always_center_indicator=False
|
|
1021
|
+
),
|
|
1022
|
+
# psql: PostgreSQL-like; header rule only, no outer frame.
|
|
1023
|
+
psql=TableComposition(
|
|
1024
|
+
superior_header_line=None,
|
|
1025
|
+
inferior_header_line=SeparatorLine(None, '-', '+', None),
|
|
1026
|
+
superior_header_line_no_header=None,
|
|
1027
|
+
table_body_line=None,
|
|
1028
|
+
table_end_line=None,
|
|
1029
|
+
vertical_header_lines=SeparatorLine(None, '|', None, None),
|
|
1030
|
+
vertical_table_body_lines=SeparatorLine(None, '|', None, None),
|
|
1031
|
+
margin=CELL_MARGIN,
|
|
1032
|
+
align_sensitive=False,
|
|
1033
|
+
align_indicator=None,
|
|
1034
|
+
centered_indicator_on_sides=False,
|
|
1035
|
+
left_and_right_when_centered=False,
|
|
1036
|
+
lines_with_indicator=[],
|
|
1037
|
+
align_indicator_margin=0,
|
|
1038
|
+
always_center_indicator=False
|
|
1039
|
+
),
|
|
1040
|
+
# markdown: GitHub-flavoured markdown pipe table.
|
|
1041
|
+
markdown=TableComposition(
|
|
1042
|
+
superior_header_line=None,
|
|
1043
|
+
inferior_header_line=SeparatorLine('|', '-', '|', '|'),
|
|
1044
|
+
superior_header_line_no_header=SeparatorLine('|', '-', '|', '|'),
|
|
1045
|
+
table_body_line=None,
|
|
1046
|
+
table_end_line=None,
|
|
1047
|
+
vertical_header_lines=SeparatorLine('|', '|', None, '|'),
|
|
1048
|
+
vertical_table_body_lines=SeparatorLine('|', '|', None, '|'),
|
|
1049
|
+
margin=CELL_MARGIN,
|
|
1050
|
+
align_sensitive=False,
|
|
1051
|
+
align_indicator=None,
|
|
1052
|
+
centered_indicator_on_sides=False,
|
|
1053
|
+
left_and_right_when_centered=False,
|
|
1054
|
+
lines_with_indicator=[],
|
|
1055
|
+
align_indicator_margin=0,
|
|
1056
|
+
always_center_indicator=False
|
|
1057
|
+
),
|
|
1058
|
+
# re_structured_text: RST simple table (== rules, space gutters).
|
|
1059
|
+
re_structured_text=TableComposition(
|
|
1060
|
+
superior_header_line=SeparatorLine(None, '=', ' ', None),
|
|
1061
|
+
inferior_header_line=SeparatorLine(None, '=', ' ', None),
|
|
1062
|
+
superior_header_line_no_header=SeparatorLine(None, '=', ' ', None),
|
|
1063
|
+
table_body_line=None,
|
|
1064
|
+
table_end_line=SeparatorLine(None, '=', ' ', None),
|
|
1065
|
+
vertical_header_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
|
|
1066
|
+
vertical_table_body_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
|
|
1067
|
+
margin=CELL_MARGIN,
|
|
1068
|
+
align_sensitive=False,
|
|
1069
|
+
align_indicator=None,
|
|
1070
|
+
centered_indicator_on_sides=False,
|
|
1071
|
+
left_and_right_when_centered=False,
|
|
1072
|
+
lines_with_indicator=[],
|
|
1073
|
+
align_indicator_margin=0,
|
|
1074
|
+
always_center_indicator=False
|
|
1075
|
+
),
|
|
1076
|
+
# dots: '.' frame / horizontals and ':' verticals (tabled Style::dots).
|
|
1077
|
+
dots=TableComposition(
|
|
1078
|
+
superior_header_line=SeparatorLine('.', '.', '.', '.'),
|
|
1079
|
+
inferior_header_line=SeparatorLine(':', '.', ':', ':'),
|
|
1080
|
+
superior_header_line_no_header=SeparatorLine('.', '.', '.', '.'),
|
|
1081
|
+
table_body_line=SeparatorLine(':', '.', ':', ':'),
|
|
1082
|
+
table_end_line=SeparatorLine(':', '.', ':', ':'),
|
|
1083
|
+
vertical_header_lines=SeparatorLine(':', ':', None, ':'),
|
|
1084
|
+
vertical_table_body_lines=SeparatorLine(':', ':', None, ':'),
|
|
1085
|
+
margin=CELL_MARGIN,
|
|
1086
|
+
align_sensitive=False,
|
|
1087
|
+
align_indicator=None,
|
|
1088
|
+
centered_indicator_on_sides=False,
|
|
1089
|
+
left_and_right_when_centered=False,
|
|
1090
|
+
lines_with_indicator=[],
|
|
1091
|
+
align_indicator_margin=0,
|
|
1092
|
+
always_center_indicator=False
|
|
1093
|
+
),
|
|
1094
|
+
# ascii_rounded: '.' / "'" corners, no header or body horizontals.
|
|
1095
|
+
ascii_rounded=TableComposition(
|
|
1096
|
+
superior_header_line=SeparatorLine('.', '-', '-', '.'),
|
|
1097
|
+
inferior_header_line=None,
|
|
1098
|
+
superior_header_line_no_header=SeparatorLine('.', '-', '-', '.'),
|
|
1099
|
+
table_body_line=None,
|
|
1100
|
+
table_end_line=SeparatorLine("'", '-', '-', "'"),
|
|
1101
|
+
vertical_header_lines=SeparatorLine('|', '|', None, '|'),
|
|
1102
|
+
vertical_table_body_lines=SeparatorLine('|', '|', None, '|'),
|
|
1103
|
+
margin=CELL_MARGIN,
|
|
1104
|
+
align_sensitive=False,
|
|
1105
|
+
align_indicator=None,
|
|
1106
|
+
centered_indicator_on_sides=False,
|
|
1107
|
+
left_and_right_when_centered=False,
|
|
1108
|
+
lines_with_indicator=[],
|
|
1109
|
+
align_indicator_margin=0,
|
|
1110
|
+
always_center_indicator=False
|
|
1111
|
+
),
|
|
1112
|
+
# blank: no rules; columns separated by a space (with cell margin).
|
|
1113
|
+
blank=TableComposition(
|
|
1114
|
+
superior_header_line=None,
|
|
1115
|
+
inferior_header_line=None,
|
|
1116
|
+
superior_header_line_no_header=None,
|
|
1117
|
+
table_body_line=None,
|
|
1118
|
+
table_end_line=None,
|
|
1119
|
+
vertical_header_lines=SeparatorLine(None, ' ', None, None),
|
|
1120
|
+
vertical_table_body_lines=SeparatorLine(None, ' ', None, None),
|
|
1121
|
+
margin=CELL_MARGIN,
|
|
1122
|
+
align_sensitive=False,
|
|
1123
|
+
align_indicator=None,
|
|
1124
|
+
centered_indicator_on_sides=False,
|
|
1125
|
+
left_and_right_when_centered=False,
|
|
1126
|
+
lines_with_indicator=[],
|
|
1127
|
+
align_indicator_margin=0,
|
|
1128
|
+
always_center_indicator=False
|
|
1129
|
+
),
|
|
1130
|
+
# empty: no chrome and no margin (tabled Style::empty base).
|
|
1131
|
+
empty=TableComposition(
|
|
1132
|
+
superior_header_line=None,
|
|
1133
|
+
inferior_header_line=None,
|
|
1134
|
+
superior_header_line_no_header=None,
|
|
1135
|
+
table_body_line=None,
|
|
1136
|
+
table_end_line=None,
|
|
1137
|
+
vertical_header_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
|
|
1138
|
+
vertical_table_body_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
|
|
1139
|
+
margin=0,
|
|
1140
|
+
align_sensitive=False,
|
|
1141
|
+
align_indicator=None,
|
|
1142
|
+
centered_indicator_on_sides=False,
|
|
1143
|
+
left_and_right_when_centered=False,
|
|
1144
|
+
lines_with_indicator=[],
|
|
1145
|
+
align_indicator_margin=0,
|
|
1146
|
+
always_center_indicator=False
|
|
916
1147
|
)
|
|
917
1148
|
)
|
|
@@ -26,6 +26,7 @@ from .columns import (
|
|
|
26
26
|
ALIGNMENTS_PER_TYPE as type_alignments
|
|
27
27
|
)
|
|
28
28
|
from .fast import truncate_to_width, visible_width, wrap_to_width
|
|
29
|
+
from .text_width import strip_ansi
|
|
29
30
|
from .table_strings import (
|
|
30
31
|
_get_separators,
|
|
31
32
|
_get_data_rows,
|
|
@@ -827,6 +828,8 @@ class Table(object):
|
|
|
827
828
|
# cell. None everywhere means no colour and no cost.
|
|
828
829
|
self.__header_color = None
|
|
829
830
|
self.__border_color = None
|
|
831
|
+
# LineText-style overlays (tabled): text drawn onto border runs.
|
|
832
|
+
self.__border_texts = []
|
|
830
833
|
self.__column_colors = {}
|
|
831
834
|
self.__row_colors = {}
|
|
832
835
|
self.__color_rule = None
|
|
@@ -2068,6 +2071,69 @@ class Table(object):
|
|
|
2068
2071
|
def border_color(self, value):
|
|
2069
2072
|
self.__border_color = value
|
|
2070
2073
|
|
|
2074
|
+
def border_text(self, text, where='top', color=None, offset=1, align='left'):
|
|
2075
|
+
"""
|
|
2076
|
+
Overlay ``text`` on a border line (inspired by tabled ``LineText``).
|
|
2077
|
+
|
|
2078
|
+
``where`` selects the target rule or vertical::
|
|
2079
|
+
|
|
2080
|
+
'top' / 'superior_header' – top frame
|
|
2081
|
+
'header' / 'header_rule' – rule under the header
|
|
2082
|
+
'body' / 'body_rule' – inter-row body rules
|
|
2083
|
+
'bottom' / 'end' – bottom frame
|
|
2084
|
+
'left' / 'right' – vertical outer borders
|
|
2085
|
+
|
|
2086
|
+
``offset`` is the visible column (horizontal) or row (vertical) where
|
|
2087
|
+
the text starts; junctions outside the span are preserved when the
|
|
2088
|
+
text does not overwrite them. ``color`` paints the text foreground
|
|
2089
|
+
(``border_color`` still paints the remaining chrome). ``align`` is
|
|
2090
|
+
``left``, ``center``, or ``right`` within the writable span when
|
|
2091
|
+
``offset`` is None.
|
|
2092
|
+
|
|
2093
|
+
Multiple calls accumulate; use ``clear_border_texts()`` to reset.
|
|
2094
|
+
"""
|
|
2095
|
+
where_key = str(where).strip().lower()
|
|
2096
|
+
aliases = {
|
|
2097
|
+
'top': 'top',
|
|
2098
|
+
'superior': 'top',
|
|
2099
|
+
'superior_header': 'top',
|
|
2100
|
+
'header': 'header',
|
|
2101
|
+
'header_rule': 'header',
|
|
2102
|
+
'inferior_header': 'header',
|
|
2103
|
+
'body': 'body',
|
|
2104
|
+
'body_rule': 'body',
|
|
2105
|
+
'table_body': 'body',
|
|
2106
|
+
'bottom': 'bottom',
|
|
2107
|
+
'end': 'bottom',
|
|
2108
|
+
'table_end': 'bottom',
|
|
2109
|
+
'left': 'left',
|
|
2110
|
+
'right': 'right',
|
|
2111
|
+
}
|
|
2112
|
+
if where_key not in aliases:
|
|
2113
|
+
raise ValueError(
|
|
2114
|
+
f"Unknown border_text where={where!r}; "
|
|
2115
|
+
f"expected one of {sorted(set(aliases.values()))}"
|
|
2116
|
+
)
|
|
2117
|
+
align_key = (align or 'left').lower()
|
|
2118
|
+
if align_key not in ('left', 'center', 'right', 'l', 'c', 'r'):
|
|
2119
|
+
raise ValueError(f"Unknown border_text align={align!r}")
|
|
2120
|
+
align_key = {'l': 'left', 'c': 'center', 'r': 'right'}.get(
|
|
2121
|
+
align_key, align_key
|
|
2122
|
+
)
|
|
2123
|
+
self.__border_texts.append({
|
|
2124
|
+
'text': '' if text is None else str(text),
|
|
2125
|
+
'where': aliases[where_key],
|
|
2126
|
+
'color': color,
|
|
2127
|
+
'offset': offset,
|
|
2128
|
+
'align': align_key,
|
|
2129
|
+
})
|
|
2130
|
+
return self
|
|
2131
|
+
|
|
2132
|
+
def clear_border_texts(self):
|
|
2133
|
+
"""Remove every overlay registered with ``border_text``."""
|
|
2134
|
+
self.__border_texts = []
|
|
2135
|
+
return self
|
|
2136
|
+
|
|
2071
2137
|
@property
|
|
2072
2138
|
def column_colors(self) -> dict:
|
|
2073
2139
|
"""
|
|
@@ -3880,6 +3946,11 @@ class Table(object):
|
|
|
3880
3946
|
for line in separators
|
|
3881
3947
|
])
|
|
3882
3948
|
|
|
3949
|
+
if self.__border_texts:
|
|
3950
|
+
separators, gap_separator = self.__apply_horizontal_border_texts(
|
|
3951
|
+
separators, gap_separator
|
|
3952
|
+
)
|
|
3953
|
+
|
|
3883
3954
|
# Table string is formed
|
|
3884
3955
|
no_header_superior = separators.superior_header_line_no_header
|
|
3885
3956
|
body_line = ''.join(['\n', separators.table_body_line]) if (
|
|
@@ -3931,6 +4002,9 @@ class Table(object):
|
|
|
3931
4002
|
column_widths_list, table_with_i
|
|
3932
4003
|
)
|
|
3933
4004
|
|
|
4005
|
+
if self.__border_texts:
|
|
4006
|
+
table_string = self.__apply_vertical_border_texts(table_string)
|
|
4007
|
+
|
|
3934
4008
|
return self.__apply_table_align(table_string)
|
|
3935
4009
|
|
|
3936
4010
|
def __join_body_rows(self, body_rows, body_line, separator_line,
|
|
@@ -4105,6 +4179,207 @@ class Table(object):
|
|
|
4105
4179
|
)
|
|
4106
4180
|
return specs
|
|
4107
4181
|
|
|
4182
|
+
def __overlay_line_text(self, line, text, offset=1, color=None,
|
|
4183
|
+
align='left', chrome_color=None):
|
|
4184
|
+
"""
|
|
4185
|
+
Replace a span of ``line`` with ``text`` (tabled LineText spirit).
|
|
4186
|
+
|
|
4187
|
+
Works on ANSI-coloured lines by stripping for geometry, then rebuilding
|
|
4188
|
+
``prefix + colored_text + suffix``. Truncates text that does not fit.
|
|
4189
|
+
``offset`` None means place by ``align`` inside the full line width.
|
|
4190
|
+
``chrome_color`` (defaults to ``border_color``) repaints the non-text
|
|
4191
|
+
segments so overlays do not strip an existing border foreground.
|
|
4192
|
+
"""
|
|
4193
|
+
if line is None:
|
|
4194
|
+
return None
|
|
4195
|
+
plain = strip_ansi(line)
|
|
4196
|
+
if not plain:
|
|
4197
|
+
return line
|
|
4198
|
+
raw = '' if text is None else str(text)
|
|
4199
|
+
# Drop ANSI from the overlay itself; we recolour via ``color``.
|
|
4200
|
+
raw = strip_ansi(raw)
|
|
4201
|
+
chars = list(plain)
|
|
4202
|
+
width = len(chars)
|
|
4203
|
+
text_chars = list(raw)
|
|
4204
|
+
tw = len(text_chars)
|
|
4205
|
+
if offset is None:
|
|
4206
|
+
if align == 'center':
|
|
4207
|
+
start = max(0, (width - tw) // 2)
|
|
4208
|
+
elif align == 'right':
|
|
4209
|
+
start = max(0, width - tw)
|
|
4210
|
+
else:
|
|
4211
|
+
start = 0
|
|
4212
|
+
else:
|
|
4213
|
+
start = max(0, int(offset))
|
|
4214
|
+
if start >= width:
|
|
4215
|
+
return line
|
|
4216
|
+
available = width - start
|
|
4217
|
+
if tw > available:
|
|
4218
|
+
text_chars = text_chars[:available]
|
|
4219
|
+
tw = len(text_chars)
|
|
4220
|
+
for i, ch in enumerate(text_chars):
|
|
4221
|
+
chars[start + i] = ch
|
|
4222
|
+
new_plain = ''.join(chars)
|
|
4223
|
+
chrome = chrome_color if chrome_color is not None else self.__border_color
|
|
4224
|
+
prefix = new_plain[:start]
|
|
4225
|
+
mid = new_plain[start:start + tw]
|
|
4226
|
+
suffix = new_plain[start + tw:]
|
|
4227
|
+
if color or chrome:
|
|
4228
|
+
left = colorize(prefix, chrome) if chrome and prefix else prefix
|
|
4229
|
+
centre = colorize(mid, color or chrome) if (color or chrome) and mid else mid
|
|
4230
|
+
right = colorize(suffix, chrome) if chrome and suffix else suffix
|
|
4231
|
+
return left + centre + right
|
|
4232
|
+
return new_plain
|
|
4233
|
+
|
|
4234
|
+
def __horizontal_border_specs(self, where):
|
|
4235
|
+
return [spec for spec in self.__border_texts if spec['where'] == where]
|
|
4236
|
+
|
|
4237
|
+
def __apply_horizontal_border_texts(self, separators, gap_separator):
|
|
4238
|
+
"""Overlay registered horizontal ``border_text`` entries onto rules."""
|
|
4239
|
+
def paint_field(line, where):
|
|
4240
|
+
if line is None:
|
|
4241
|
+
return None
|
|
4242
|
+
out = line
|
|
4243
|
+
for spec in self.__horizontal_border_specs(where):
|
|
4244
|
+
out = self.__overlay_line_text(
|
|
4245
|
+
out, spec['text'], spec['offset'],
|
|
4246
|
+
spec['color'], spec['align'],
|
|
4247
|
+
)
|
|
4248
|
+
return out
|
|
4249
|
+
|
|
4250
|
+
painted = HorizontalComposition(
|
|
4251
|
+
paint_field(separators.superior_header_line, 'top'),
|
|
4252
|
+
paint_field(separators.inferior_header_line, 'header'),
|
|
4253
|
+
paint_field(separators.superior_header_line_no_header, 'top'),
|
|
4254
|
+
paint_field(separators.table_body_line, 'body'),
|
|
4255
|
+
paint_field(separators.table_end_line, 'bottom'),
|
|
4256
|
+
)
|
|
4257
|
+
|
|
4258
|
+
body_specs = self.__horizontal_border_specs('body')
|
|
4259
|
+
if gap_separator is None or not body_specs:
|
|
4260
|
+
return painted, gap_separator
|
|
4261
|
+
|
|
4262
|
+
def wrapped(after_row, _inner=gap_separator, _specs=body_specs):
|
|
4263
|
+
line = _inner(after_row)
|
|
4264
|
+
for spec in _specs:
|
|
4265
|
+
line = self.__overlay_line_text(
|
|
4266
|
+
line, spec['text'], spec['offset'],
|
|
4267
|
+
spec['color'], spec['align'],
|
|
4268
|
+
)
|
|
4269
|
+
return line
|
|
4270
|
+
|
|
4271
|
+
return painted, wrapped
|
|
4272
|
+
|
|
4273
|
+
def __apply_vertical_border_texts(self, table_string):
|
|
4274
|
+
"""
|
|
4275
|
+
Overlay left/right ``border_text`` onto outer vertical glyphs.
|
|
4276
|
+
|
|
4277
|
+
Writes one character of the text per successive physical line,
|
|
4278
|
+
starting at ``offset`` (0 = first line of the rendered table).
|
|
4279
|
+
"""
|
|
4280
|
+
if not table_string:
|
|
4281
|
+
return table_string
|
|
4282
|
+
left_specs = [s for s in self.__border_texts if s['where'] == 'left']
|
|
4283
|
+
right_specs = [s for s in self.__border_texts if s['where'] == 'right']
|
|
4284
|
+
if not left_specs and not right_specs:
|
|
4285
|
+
return table_string
|
|
4286
|
+
|
|
4287
|
+
lines = table_string.split('\n')
|
|
4288
|
+
n = len(lines)
|
|
4289
|
+
|
|
4290
|
+
for spec in left_specs:
|
|
4291
|
+
text = strip_ansi(spec['text'])
|
|
4292
|
+
if not text:
|
|
4293
|
+
continue
|
|
4294
|
+
offset = 0 if spec['offset'] is None else int(spec['offset'])
|
|
4295
|
+
for i, ch in enumerate(text):
|
|
4296
|
+
row = offset + i
|
|
4297
|
+
if row < 0 or row >= n:
|
|
4298
|
+
break
|
|
4299
|
+
lines[row] = self.__replace_first_visible(
|
|
4300
|
+
lines[row], ch, spec['color']
|
|
4301
|
+
)
|
|
4302
|
+
|
|
4303
|
+
for spec in right_specs:
|
|
4304
|
+
text = strip_ansi(spec['text'])
|
|
4305
|
+
if not text:
|
|
4306
|
+
continue
|
|
4307
|
+
offset = 0 if spec['offset'] is None else int(spec['offset'])
|
|
4308
|
+
for i, ch in enumerate(text):
|
|
4309
|
+
row = offset + i
|
|
4310
|
+
if row < 0 or row >= n:
|
|
4311
|
+
break
|
|
4312
|
+
lines[row] = self.__replace_last_visible(
|
|
4313
|
+
lines[row], ch, spec['color']
|
|
4314
|
+
)
|
|
4315
|
+
|
|
4316
|
+
return '\n'.join(lines)
|
|
4317
|
+
|
|
4318
|
+
@staticmethod
|
|
4319
|
+
def __replace_first_visible(line, ch, color):
|
|
4320
|
+
"""Replace the first visible character of ``line`` with ``ch``."""
|
|
4321
|
+
plain = strip_ansi(line)
|
|
4322
|
+
if not plain:
|
|
4323
|
+
return line
|
|
4324
|
+
# Rebuild: find first non-ANSI char span by walking with strip.
|
|
4325
|
+
# Simpler path: compose new_plain then, if colouring, colourize ch.
|
|
4326
|
+
new_plain = ch + plain[1:]
|
|
4327
|
+
if color is None and line == plain:
|
|
4328
|
+
return new_plain
|
|
4329
|
+
# When the line carries ANSI, keep suffix after first visible char.
|
|
4330
|
+
# Locate end of first visible character in the ANSI string.
|
|
4331
|
+
from .text_width import has_ansi
|
|
4332
|
+
if not has_ansi(line):
|
|
4333
|
+
return colorize(ch, color) + plain[1:] if color else new_plain
|
|
4334
|
+
# Walk CSI sequences; first real char is the border glyph.
|
|
4335
|
+
import re
|
|
4336
|
+
sgr = re.compile(r'\x1b\[[0-9;]*m')
|
|
4337
|
+
pos = 0
|
|
4338
|
+
while pos < len(line):
|
|
4339
|
+
m = sgr.match(line, pos)
|
|
4340
|
+
if m:
|
|
4341
|
+
pos = m.end()
|
|
4342
|
+
continue
|
|
4343
|
+
# replace this one character
|
|
4344
|
+
head = line[:pos]
|
|
4345
|
+
# skip one unicode char
|
|
4346
|
+
tail_start = pos + 1
|
|
4347
|
+
# If original char was the start of a combining sequence, still +1
|
|
4348
|
+
# is fine for box-drawing / ascii borders.
|
|
4349
|
+
tail = line[tail_start:]
|
|
4350
|
+
painted = colorize(ch, color) if color else ch
|
|
4351
|
+
return head + painted + tail
|
|
4352
|
+
return line
|
|
4353
|
+
|
|
4354
|
+
@staticmethod
|
|
4355
|
+
def __replace_last_visible(line, ch, color):
|
|
4356
|
+
"""Replace the last visible character of ``line`` with ``ch``."""
|
|
4357
|
+
plain = strip_ansi(line)
|
|
4358
|
+
if not plain:
|
|
4359
|
+
return line
|
|
4360
|
+
from .text_width import has_ansi
|
|
4361
|
+
if not has_ansi(line):
|
|
4362
|
+
body = plain[:-1] + ch
|
|
4363
|
+
if color:
|
|
4364
|
+
return plain[:-1] + colorize(ch, color)
|
|
4365
|
+
return body
|
|
4366
|
+
import re
|
|
4367
|
+
sgr = re.compile(r'\x1b\[[0-9;]*m')
|
|
4368
|
+
# Find index of last visible character.
|
|
4369
|
+
last = None
|
|
4370
|
+
pos = 0
|
|
4371
|
+
while pos < len(line):
|
|
4372
|
+
m = sgr.match(line, pos)
|
|
4373
|
+
if m:
|
|
4374
|
+
pos = m.end()
|
|
4375
|
+
continue
|
|
4376
|
+
last = pos
|
|
4377
|
+
pos += 1
|
|
4378
|
+
if last is None:
|
|
4379
|
+
return line
|
|
4380
|
+
painted = colorize(ch, color) if color else ch
|
|
4381
|
+
return line[:last] + painted + line[last + 1:]
|
|
4382
|
+
|
|
4108
4383
|
def __colour_horizontal_rules(self, separators, column_widths,
|
|
4109
4384
|
column_titles, body_row_count):
|
|
4110
4385
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.12
|
|
4
4
|
Summary: Flexible console and HTML tables for Python
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Download-URL:
|
|
@@ -355,7 +355,7 @@ flexablelib/ # GitHub repository
|
|
|
355
355
|
├── docs/ issue history and design notes
|
|
356
356
|
├── logos/ brand assets — see logos/README.md
|
|
357
357
|
├── ARCHITECTURE.md how it all fits together
|
|
358
|
-
├── style_examples.md all
|
|
358
|
+
├── style_examples.md all 56 styles rendered
|
|
359
359
|
├── package.json canonical version number; drives the release
|
|
360
360
|
└── setup.py reads the version from package.json
|
|
361
361
|
```
|
|
@@ -275,7 +275,7 @@ def test_html_export_preserves_merged_cells():
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
def test_merged_region_color_fills_ansi():
|
|
278
|
-
table = Table(style_name='
|
|
278
|
+
table = Table(style_name='pretty_grid')
|
|
279
279
|
table.use_colors = True
|
|
280
280
|
table.add_column('A', ['alpha-0', 'alpha-1', 'alpha-2'])
|
|
281
281
|
table.add_column('B', ['bravo-0', 'bravo-1', 'bravo-2'])
|
|
@@ -289,7 +289,7 @@ def test_merged_region_color_fills_ansi():
|
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
def test_merged_region_inherits_column_color():
|
|
292
|
-
table = Table(style_name='
|
|
292
|
+
table = Table(style_name='pretty_grid')
|
|
293
293
|
table.use_colors = True
|
|
294
294
|
# Wide unmerged content so the merge span can hold the label.
|
|
295
295
|
table.add_column('A', ['alpha-0', 'alpha-1'])
|
|
@@ -301,12 +301,10 @@ def test_merged_region_inherits_column_color():
|
|
|
301
301
|
assert 'INHERIT' in rendered
|
|
302
302
|
|
|
303
303
|
|
|
304
|
-
def test_flush_style_is_catalogued():
|
|
305
|
-
assert 'flush' in Table().possible_styles
|
|
306
304
|
|
|
307
305
|
|
|
308
306
|
def test_html_and_excel_carry_merge_fill(tmp_path):
|
|
309
|
-
table = Table(style_name='
|
|
307
|
+
table = Table(style_name='pretty_grid')
|
|
310
308
|
table.use_colors = True
|
|
311
309
|
table.add_column('A', ['a0', 'a1'])
|
|
312
310
|
table.add_column('B', ['b0', 'b1'])
|
|
@@ -319,10 +317,10 @@ def test_html_and_excel_carry_merge_fill(tmp_path):
|
|
|
319
317
|
ws = openpyxl.load_workbook(path).active
|
|
320
318
|
assert ws['A2'].fill.fgColor.rgb.endswith('0891B2') or '0891B2' in str(ws['A2'].fill.fgColor.rgb)
|
|
321
319
|
|
|
322
|
-
def
|
|
320
|
+
def test_horizontal_rules_carry_cell_bg():
|
|
323
321
|
"""H-rule dash runs inherit the cell-above background (no dark band)."""
|
|
324
322
|
import re
|
|
325
|
-
table = Table(style_name='
|
|
323
|
+
table = Table(style_name='pretty_grid')
|
|
326
324
|
table.use_colors = True
|
|
327
325
|
table.add_column('A', ['a0', 'a1'])
|
|
328
326
|
table.add_column('B', ['b0', 'b1'])
|
|
@@ -339,3 +337,63 @@ def test_flush_horizontal_rules_carry_cell_bg():
|
|
|
339
337
|
if '43m' in line:
|
|
340
338
|
found_yellow_on_rule = True
|
|
341
339
|
assert found_cyan_on_rule and found_yellow_on_rule
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_border_color_foreground_on_modern_and_ascii():
|
|
343
|
+
import os
|
|
344
|
+
os.environ['FORCE_COLOR'] = '1'
|
|
345
|
+
os.environ.pop('NO_COLOR', None)
|
|
346
|
+
for style in ('modern', 'ascii'):
|
|
347
|
+
table = Table(style_name=style)
|
|
348
|
+
table.use_colors = True
|
|
349
|
+
table.border_color = 'cyan'
|
|
350
|
+
table.add_column('A', ['x'])
|
|
351
|
+
table.add_column('B', ['y'])
|
|
352
|
+
rendered = str(table)
|
|
353
|
+
assert '\x1b[' in rendered or '\033[' in rendered
|
|
354
|
+
assert '36m' in rendered # cyan FG
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def test_border_text_on_top_rule_with_color():
|
|
358
|
+
import os
|
|
359
|
+
os.environ['FORCE_COLOR'] = '1'
|
|
360
|
+
os.environ.pop('NO_COLOR', None)
|
|
361
|
+
table = Table(style_name='ascii')
|
|
362
|
+
table.use_colors = True
|
|
363
|
+
table.border_color = 'blue'
|
|
364
|
+
table.add_column('name', ['C', 'Go'])
|
|
365
|
+
table.add_column('year', [1972, 2009])
|
|
366
|
+
table.border_text('Languages', where='top', color='bold yellow', offset=2)
|
|
367
|
+
rendered = str(table)
|
|
368
|
+
plain_lines = []
|
|
369
|
+
import re
|
|
370
|
+
for line in rendered.splitlines():
|
|
371
|
+
plain_lines.append(re.sub('\x1b' r'\[[0-9;]*m', '', line))
|
|
372
|
+
assert any('Languages' in line for line in plain_lines)
|
|
373
|
+
assert 'Languages' in plain_lines[0]
|
|
374
|
+
assert '33m' in rendered or '1;33m' in rendered
|
|
375
|
+
assert '34m' in rendered # blue chrome
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def test_border_text_left_vertical():
|
|
379
|
+
table = Table(style_name='ascii')
|
|
380
|
+
table.add_column('A', ['1', '2'])
|
|
381
|
+
table.border_text('AB', where='left', offset=1)
|
|
382
|
+
import re
|
|
383
|
+
plain = [re.sub('\x1b' r'\[[0-9;]*m', '', line) for line in str(table).splitlines()]
|
|
384
|
+
# First data-ish lines after offset should start with A then B
|
|
385
|
+
assert plain[1].startswith('A')
|
|
386
|
+
assert plain[2].startswith('B')
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def test_blocks_style_still_works_with_colors():
|
|
390
|
+
import os
|
|
391
|
+
os.environ['FORCE_COLOR'] = '1'
|
|
392
|
+
os.environ.pop('NO_COLOR', None)
|
|
393
|
+
table = Table(style_name='blocks')
|
|
394
|
+
table.use_colors = True
|
|
395
|
+
table.header_color = 'bold white on blue'
|
|
396
|
+
table.column_colors = {'A': 'black on green'}
|
|
397
|
+
table.add_column('A', ['x', 'y'])
|
|
398
|
+
rendered = str(table)
|
|
399
|
+
assert '42m' in rendered or '44m' in rendered
|
|
@@ -36,7 +36,7 @@ def build_table(style_name):
|
|
|
36
36
|
def test_the_catalogue_holds_43_styles():
|
|
37
37
|
# A canary: adding a style is meant to be purely additive, and the README,
|
|
38
38
|
# ARCHITECTURE.md and style_examples.md all quote this number.
|
|
39
|
-
assert len(ALL_STYLES) ==
|
|
39
|
+
assert len(ALL_STYLES) == 56
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def test_style_names_are_unique():
|
|
@@ -212,3 +212,25 @@ def test_blocks_style_keeps_cell_padding_for_background_fills():
|
|
|
212
212
|
rendered = str(table)
|
|
213
213
|
assert '\x1b[' in rendered or '\033[' in rendered or '[' in rendered
|
|
214
214
|
assert '42m' in rendered or '44m' in rendered # green or blue bg
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
TABLED_STYLES = [
|
|
218
|
+
'ascii', 'modern', 'sharp', 'rounded', 'modern_rounded', 'extended',
|
|
219
|
+
'psql', 'markdown', 're_structured_text', 'dots', 'ascii_rounded',
|
|
220
|
+
'blank', 'empty',
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@pytest.mark.parametrize('style_name', TABLED_STYLES)
|
|
225
|
+
def test_tabled_style_names_are_catalogued(style_name):
|
|
226
|
+
assert style_name in ALL_STYLES
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@pytest.mark.parametrize('style_name', TABLED_STYLES)
|
|
230
|
+
def test_tabled_styles_render_without_error(style_name):
|
|
231
|
+
rendered = str(build_table(style_name))
|
|
232
|
+
assert rendered
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def test_flush_style_removed():
|
|
236
|
+
assert 'flush' not in ALL_STYLES
|
|
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
|