Merging upstream version 2.3.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
9f89672eb0
commit
22daebc5ff
7 changed files with 77 additions and 12 deletions
1
AUTHORS
1
AUTHORS
|
@ -24,6 +24,7 @@ This project receives help from these awesome contributors:
|
||||||
- Waldir Pimenta
|
- Waldir Pimenta
|
||||||
- Mel Dafert
|
- Mel Dafert
|
||||||
- Andrii Kohut
|
- Andrii Kohut
|
||||||
|
- Roland Walker
|
||||||
|
|
||||||
Thanks
|
Thanks
|
||||||
------
|
------
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Version 2.3.0
|
||||||
|
-------------
|
||||||
|
|
||||||
|
(released on 2022-10-12)
|
||||||
|
|
||||||
|
* don't escape newlines, etc. in ascii tables, and add ascii_escaped table format
|
||||||
|
|
||||||
Version 2.2.1
|
Version 2.2.1
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = "2.2.1"
|
__version__ = "2.3.0"
|
||||||
|
|
|
@ -52,9 +52,25 @@ tabulate._table_formats["ascii"] = tabulate.TableFormat(
|
||||||
with_header_hide=None,
|
with_header_hide=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tabulate._table_formats["ascii_escaped"] = tabulate.TableFormat(
|
||||||
|
lineabove=tabulate.Line("+", "-", "+", "+"),
|
||||||
|
linebelowheader=tabulate.Line("+", "-", "+", "+"),
|
||||||
|
linebetweenrows=None,
|
||||||
|
linebelow=tabulate.Line("+", "-", "+", "+"),
|
||||||
|
headerrow=tabulate.DataRow("|", "|", "|"),
|
||||||
|
datarow=tabulate.DataRow("|", "|", "|"),
|
||||||
|
padding=1,
|
||||||
|
with_header_hide=None,
|
||||||
|
)
|
||||||
|
|
||||||
# "minimal" is the same as "plain", but without headers
|
# "minimal" is the same as "plain", but without headers
|
||||||
tabulate._table_formats["minimal"] = tabulate._table_formats["plain"]
|
tabulate._table_formats["minimal"] = tabulate._table_formats["plain"]
|
||||||
|
|
||||||
|
tabulate.multiline_formats["psql_unicode"] = "psql_unicode"
|
||||||
|
tabulate.multiline_formats["double"] = "double"
|
||||||
|
tabulate.multiline_formats["ascii"] = "ascii"
|
||||||
|
tabulate.multiline_formats["minimal"] = "minimal"
|
||||||
|
|
||||||
supported_markup_formats = (
|
supported_markup_formats = (
|
||||||
"mediawiki",
|
"mediawiki",
|
||||||
"html",
|
"html",
|
||||||
|
@ -66,6 +82,7 @@ supported_markup_formats = (
|
||||||
)
|
)
|
||||||
supported_table_formats = (
|
supported_table_formats = (
|
||||||
"ascii",
|
"ascii",
|
||||||
|
"ascii_escaped",
|
||||||
"plain",
|
"plain",
|
||||||
"simple",
|
"simple",
|
||||||
"minimal",
|
"minimal",
|
||||||
|
@ -82,7 +99,10 @@ supported_table_formats = (
|
||||||
|
|
||||||
supported_formats = supported_markup_formats + supported_table_formats
|
supported_formats = supported_markup_formats + supported_table_formats
|
||||||
|
|
||||||
default_kwargs = {"ascii": {"numalign": "left"}}
|
default_kwargs = {
|
||||||
|
"ascii": {"numalign": "left"},
|
||||||
|
"ascii_escaped": {"numalign": "left"},
|
||||||
|
}
|
||||||
headless_formats = ("minimal",)
|
headless_formats = ("minimal",)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ CLI Helpers provides a simple way to display your tabular data (columns/rows) in
|
||||||
>>> data = [[1, 'Asgard', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
|
>>> data = [[1, 'Asgard', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
|
||||||
>>> headers = ['id', 'city', 'visited']
|
>>> headers = ['id', 'city', 'visited']
|
||||||
|
|
||||||
>>> print(tabular_output.format_output(data, headers, format_name='simple'))
|
>>> print("\n".join(tabular_output.format_output(iter(data), headers, format_name='simple')))
|
||||||
|
|
||||||
id city visited
|
id city visited
|
||||||
---- --------- ---------
|
---- --------- ---------
|
||||||
|
@ -57,7 +57,7 @@ same data from our first example and put it in the ``fancy_grid`` format::
|
||||||
|
|
||||||
>>> data = [[1, 'Asgard', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
|
>>> data = [[1, 'Asgard', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
|
||||||
>>> headers = ['id', 'city', 'visited']
|
>>> headers = ['id', 'city', 'visited']
|
||||||
>>> print(formatter.format_output(data, headers, format_name='fancy_grid'))
|
>>> print("\n".join(formatter.format_output(iter(data), headers, format_name='fancy_grid')))
|
||||||
╒══════╤═══════════╤═══════════╕
|
╒══════╤═══════════╤═══════════╕
|
||||||
│ id │ city │ visited │
|
│ id │ city │ visited │
|
||||||
╞══════╪═══════════╪═══════════╡
|
╞══════╪═══════════╪═══════════╡
|
||||||
|
@ -70,7 +70,7 @@ same data from our first example and put it in the ``fancy_grid`` format::
|
||||||
|
|
||||||
That was easy! How about CLI Helper's vertical table layout?
|
That was easy! How about CLI Helper's vertical table layout?
|
||||||
|
|
||||||
>>> print(formatter.format_output(data, headers, format_name='vertical'))
|
>>> print("\n".join(formatter.format_output(iter(data), headers, format_name='vertical')))
|
||||||
***************************[ 1. row ]***************************
|
***************************[ 1. row ]***************************
|
||||||
id | 1
|
id | 1
|
||||||
city | Asgard
|
city | Asgard
|
||||||
|
@ -93,7 +93,7 @@ object, you can specify a default formatter so you don't have to pass the
|
||||||
format name each time you want to format your data::
|
format name each time you want to format your data::
|
||||||
|
|
||||||
>>> formatter = TabularOutputFormatter(format_name='plain')
|
>>> formatter = TabularOutputFormatter(format_name='plain')
|
||||||
>>> print(formatter.format_output(data, headers))
|
>>> print("\n".join(formatter.format_output(iter(data), headers)))
|
||||||
id city visited
|
id city visited
|
||||||
1 Asgard True
|
1 Asgard True
|
||||||
2 Camelot False
|
2 Camelot False
|
||||||
|
@ -115,13 +115,13 @@ formats, we could::
|
||||||
|
|
||||||
>>> data = [[1, 1.5], [2, 19.605], [3, 100.0]]
|
>>> data = [[1, 1.5], [2, 19.605], [3, 100.0]]
|
||||||
>>> headers = ['id', 'rating']
|
>>> headers = ['id', 'rating']
|
||||||
>>> print(format_output(data, headers, format_name='simple', disable_numparse=True))
|
>>> print("\n".join(format_output(iter(data), headers, format_name='simple', disable_numparse=True)))
|
||||||
id rating
|
id rating
|
||||||
---- --------
|
---- --------
|
||||||
1 1.5
|
1 1.5
|
||||||
2 19.605
|
2 19.605
|
||||||
3 100.0
|
3 100.0
|
||||||
>>> print(format_output(data, headers, format_name='simple', disable_numparse=False))
|
>>> print("\n".join(format_output(iter(data), headers, format_name='simple', disable_numparse=False)))
|
||||||
id rating
|
id rating
|
||||||
---- --------
|
---- --------
|
||||||
1 1.5
|
1 1.5
|
||||||
|
@ -140,7 +140,7 @@ far-fetched example to prove the point::
|
||||||
>>> step = 3
|
>>> step = 3
|
||||||
>>> data = [range(n, n + step) for n in range(0, 9, step)]
|
>>> data = [range(n, n + step) for n in range(0, 9, step)]
|
||||||
>>> headers = 'abc'
|
>>> headers = 'abc'
|
||||||
>>> print(format_output(data, headers, format_name='simple'))
|
>>> print("\n".join(format_output(iter(data), headers, format_name='simple')))
|
||||||
a b c
|
a b c
|
||||||
--- --- ---
|
--- --- ---
|
||||||
0 1 2
|
0 1 2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
autopep8==1.3.3
|
autopep8==1.3.3
|
||||||
codecov==2.0.9
|
codecov==2.0.16
|
||||||
coverage==4.3.4
|
coverage==4.3.4
|
||||||
black>=20.8b1
|
black>=20.8b1
|
||||||
Pygments>=2.4.0
|
Pygments>=2.4.0
|
||||||
|
|
|
@ -21,6 +21,41 @@ def test_tabular_output_formatter():
|
||||||
["hi", Decimal("1.1")],
|
["hi", Decimal("1.1")],
|
||||||
["Pablo\rß\n", 0],
|
["Pablo\rß\n", 0],
|
||||||
]
|
]
|
||||||
|
expected = dedent(
|
||||||
|
"""\
|
||||||
|
+-------+---------+
|
||||||
|
| text | numeric |
|
||||||
|
+-------+---------+
|
||||||
|
| abc | 1 |
|
||||||
|
| defg | 11.1 |
|
||||||
|
| hi | 1.1 |
|
||||||
|
| Pablo | 0 |
|
||||||
|
| ß | |
|
||||||
|
+-------+---------+"""
|
||||||
|
)
|
||||||
|
|
||||||
|
print(expected)
|
||||||
|
print(
|
||||||
|
"\n".join(
|
||||||
|
TabularOutputFormatter().format_output(
|
||||||
|
iter(data), headers, format_name="ascii"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert expected == "\n".join(
|
||||||
|
TabularOutputFormatter().format_output(iter(data), headers, format_name="ascii")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_tabular_output_escaped():
|
||||||
|
"""Test the ascii_escaped output format."""
|
||||||
|
headers = ["text", "numeric"]
|
||||||
|
data = [
|
||||||
|
["abc", Decimal(1)],
|
||||||
|
["defg", Decimal("11.1")],
|
||||||
|
["hi", Decimal("1.1")],
|
||||||
|
["Pablo\rß\n", 0],
|
||||||
|
]
|
||||||
expected = dedent(
|
expected = dedent(
|
||||||
"""\
|
"""\
|
||||||
+------------+---------+
|
+------------+---------+
|
||||||
|
@ -37,12 +72,14 @@ def test_tabular_output_formatter():
|
||||||
print(
|
print(
|
||||||
"\n".join(
|
"\n".join(
|
||||||
TabularOutputFormatter().format_output(
|
TabularOutputFormatter().format_output(
|
||||||
iter(data), headers, format_name="ascii"
|
iter(data), headers, format_name="ascii_escaped"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert expected == "\n".join(
|
assert expected == "\n".join(
|
||||||
TabularOutputFormatter().format_output(iter(data), headers, format_name="ascii")
|
TabularOutputFormatter().format_output(
|
||||||
|
iter(data), headers, format_name="ascii_escaped"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue