Hello community,
here is the log from the commit of package python-tabulate for openSUSE:Factory checked in at 2019-02-14 14:31:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-tabulate (Old)
and /work/SRC/openSUSE:Factory/.python-tabulate.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tabulate"
Thu Feb 14 14:31:11 2019 rev:3 rq:673450 version:0.8.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-tabulate/python-tabulate.changes 2018-03-28 10:33:27.264572248 +0200
+++ /work/SRC/openSUSE:Factory/.python-tabulate.new.28833/python-tabulate.changes 2019-02-14 14:31:53.591692785 +0100
@@ -1,0 +2,16 @@
+Wed Feb 6 21:45:56 UTC 2019 - Jan Engelhardt
+
+- Use noun phrase in summary.
+
+-------------------------------------------------------------------
+Wed Feb 6 02:01:00 UTC 2019 - John Vandenberg
+
+- Update to 0.8.3
+ * Bug fixes
+ * New format: `github`
+ * Custom colum alignment
+- Recommend wcwidth needed for wide character support
+- Suggest pandas which is supported
+- Run tests for wcwidth and pandas
+
+-------------------------------------------------------------------
@@ -48 +63,0 @@
-
Old:
----
tabulate-0.8.2.tar.gz
New:
----
tabulate-0.8.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-tabulate.spec ++++++
--- /var/tmp/diff_new_pack.utZlfb/_old 2019-02-14 14:31:54.139692534 +0100
+++ /var/tmp/diff_new_pack.utZlfb/_new 2019-02-14 14:31:54.143692532 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-tabulate
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,30 +12,33 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-tabulate
-Version: 0.8.2
+Version: 0.8.3
Release: 0
-Summary: Pretty-print tabular data in Python
+Summary: Pretty-printer for tabular data in Python
License: MIT
Group: Development/Languages/Python
URL: https://bitbucket.org/astanin/python-tabulate
Source: https://files.pythonhosted.org/packages/source/t/tabulate/tabulate-%{version}.tar.gz
BuildRequires: %{python_module nose}
+BuildRequires: %{python_module pandas}
BuildRequires: %{python_module setuptools}
+BuildRequires: %{python_module wcwidth}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-setuptools
-Suggests: python-wcwidth
+Recommends: python-wcwidth
+Suggests: python-pandas
BuildArch: noarch
%python_subpackages
%description
-Pretty-print tabular data in Python.
+Pretty-printer for tabular data in Python.
The main use cases of the library are:
@@ -62,7 +65,7 @@
%files %{python_files}
%license LICENSE
-%doc README README.rst
+%doc README.rst
%python3_only %{_bindir}/tabulate
%{python_sitelib}/*
++++++ tabulate-0.8.2.tar.gz -> tabulate-0.8.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/PKG-INFO new/tabulate-0.8.3/PKG-INFO
--- old/tabulate-0.8.2/PKG-INFO 2017-11-26 13:18:02.000000000 +0100
+++ new/tabulate-0.8.3/PKG-INFO 2019-01-25 00:26:41.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: tabulate
-Version: 0.8.2
+Version: 0.8.3
Summary: Pretty-print tabular data
Home-page: https://bitbucket.org/astanin/python-tabulate
Author: Sergey Astanin
@@ -65,7 +65,7 @@
>>> table = [["Sun",696000,1989100000],["Earth",6371,5973.6],
... ["Moon",1737,73.5],["Mars",3390,641.85]]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
----- ------ -------------
Sun 696000 1.9891e+09
Earth 6371 5973.6
@@ -91,7 +91,7 @@
The second optional argument named ``headers`` defines a list of
column headers to be used::
- >>> print tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])
+ >>> print(tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"]))
Planet R (km) mass (x 10^29 kg)
-------- -------- -------------------
Sun 696000 1.9891e+09
@@ -101,8 +101,8 @@
If ``headers="firstrow"``, then the first row of data is used::
- >>> print tabulate([["Name","Age"],["Alice",24],["Bob",19]],
- ... headers="firstrow")
+ >>> print(tabulate([["Name","Age"],["Alice",24],["Bob",19]],
+ ... headers="firstrow"))
Name Age
------ -----
Alice 24
@@ -113,8 +113,8 @@
column indices are used. It also works for NumPy record arrays and
lists of dictionaries or named tuples::
- >>> print tabulate({"Name": ["Alice", "Bob"],
- ... "Age": [24, 19]}, headers="keys")
+ >>> print(tabulate({"Name": ["Alice", "Bob"],
+ ... "Age": [24, 19]}, headers="keys"))
Age Name
----- ------
24 Alice
@@ -150,6 +150,7 @@
- "plain"
- "simple"
+ - "github"
- "grid"
- "fancy_grid"
- "pipe"
@@ -171,7 +172,7 @@
>>> table = [["spam",42],["eggs",451],["bacon",0]]
>>> headers = ["item", "qty"]
- >>> print tabulate(table, headers, tablefmt="plain")
+ >>> print(tabulate(table, headers, tablefmt="plain"))
item qty
spam 42
eggs 451
@@ -181,18 +182,29 @@
versions). It corresponds to ``simple_tables`` in `Pandoc Markdown
extensions`::
- >>> print tabulate(table, headers, tablefmt="simple")
+ >>> print(tabulate(table, headers, tablefmt="simple"))
item qty
------ -----
spam 42
eggs 451
bacon 0
+ ``github`` follows the conventions of `Github flavored Markdown`. It
+ corresponds to the ``pipe`` format without alignment colons::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ |--------|-------|
+ | spam | 42 |
+ | eggs | 451 |
+ | bacon | 0 |
+
+
``grid`` is like tables formatted by Emacs' `table.el`
package. It corresponds to ``grid_tables`` in Pandoc Markdown
extensions::
- >>> print tabulate(table, headers, tablefmt="grid")
+ >>> print(tabulate(table, headers, tablefmt="grid"))
+--------+-------+
| item | qty |
+========+=======+
@@ -205,7 +217,7 @@
``fancy_grid`` draws a grid using box-drawing characters::
- >>> print tabulate(table, headers, tablefmt="fancy_grid")
+ >>> print(tabulate(table, headers, tablefmt="fancy_grid"))
╒════════╤═══════╕
│ item │ qty │
╞════════╪═══════╡
@@ -218,7 +230,7 @@
``presto`` is like tables formatted by Presto cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="presto"))
item | qty
--------+-------
spam | 42
@@ -227,7 +239,7 @@
``psql`` is like tables formatted by Postgres' psql cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="psql"))
+--------+-------+
| item | qty |
|--------+-------|
@@ -240,7 +252,7 @@
corresponds to ``pipe_tables`` in Pandoc. This format uses colons to
indicate column alignment::
- >>> print tabulate(table, headers, tablefmt="pipe")
+ >>> print(tabulate(table, headers, tablefmt="pipe"))
| item | qty |
|:-------|------:|
| spam | 42 |
@@ -250,7 +262,7 @@
``orgtbl`` follows the conventions of Emacs `org-mode`, and is editable
also in the minor `orgtbl-mode`. Hence its name::
- >>> print tabulate(table, headers, tablefmt="orgtbl")
+ >>> print(tabulate(table, headers, tablefmt="orgtbl"))
| item | qty |
|--------+-------|
| spam | 42 |
@@ -259,7 +271,7 @@
``jira`` follows the conventions of Atlassian Jira markup language::
- >>> print tabulate(table, headers, tablefmt="jira")
+ >>> print(tabulate(table, headers, tablefmt="jira"))
|| item || qty ||
| spam | 42 |
| eggs | 451 |
@@ -267,7 +279,7 @@
``rst`` formats data like a simple table of the `reStructuredText` format::
- >>> print tabulate(table, headers, tablefmt="rst")
+ >>> print(tabulate(table, headers, tablefmt="rst"))
====== =====
item qty
====== =====
@@ -279,7 +291,7 @@
``mediawiki`` format produces a table markup used in `Wikipedia` and on
other MediaWiki-based sites::
- >>> print tabulate(table, headers, tablefmt="mediawiki")
+ >>> print(tabulate(table, headers, tablefmt="mediawiki"))
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
@@ -295,7 +307,7 @@
``moinmoin`` format produces a table markup used in `MoinMoin`
wikis::
- >>> print tabulate(d,headers,tablefmt="moinmoin")
+ >>> print(tabulate(table, headers, tablefmt="moinmoin"))
|| ''' item ''' || ''' quantity ''' ||
|| spam || 41.999 ||
|| eggs || 451 ||
@@ -304,7 +316,7 @@
``youtrack`` format produces a table markup used in Youtrack
tickets::
- >>> print tabulate(d,headers,tablefmt="youtrack")
+ >>> print(tabulate(table, headers, tablefmt="youtrack"))
|| item || quantity ||
| spam | 41.999 |
| eggs | 451 |
@@ -312,7 +324,7 @@
``textile`` format produces a table markup used in `Textile` format::
- >>> print tabulate(table, headers, tablefmt='textile')
+ >>> print(tabulate(table, headers, tablefmt="textile"))
|_. item |_. qty |
|<. spam |>. 42 |
|<. eggs |>. 451 |
@@ -320,7 +332,7 @@
``html`` produces standard HTML markup::
- >>> print tabulate(table, headers, tablefmt="html")
+ >>> print(tabulate(table, headers, tablefmt="html"))
<table>
<tbody>
<tr><th>item </th><th style="text-align: right;"> qty</th></tr>
@@ -334,7 +346,7 @@
replacing special characters like ```` or ``\`` to their LaTeX
correspondents::
- >>> print tabulate(table, headers, tablefmt="latex")
+ >>> print(tabulate(table, headers, tablefmt="latex"))
\begin{tabular}{lr}
\hline
item & qty \\
@@ -378,7 +390,7 @@
Aligning by a decimal point works best when you need to compare
numbers at a glance::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]])
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]]))
----------
1.2345
123.45
@@ -389,7 +401,7 @@
Compare this with a more common right alignment::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right")
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right"))
------
1.2345
123.45
@@ -409,7 +421,7 @@
>>> table = list(csv.reader(StringIO("spam, 42\neggs, 451\n")))
>>> table
[['spam', ' 42'], ['eggs', ' 451']]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
---- ----
spam 42
eggs 451
@@ -417,13 +429,30 @@
+ Custom column alignment
+ ~~~~~~~~~~~~~~~~~~~~~~~
+
+ ``tabulate`` allows a custom column alignment to override the above. The
+ ``colalign`` argument can be a list or a tuple of ``stralign`` named arguments.
+ Possible column alignments are: ``right``, ``center``, ``left``, ``decimal``
+ (only for numbers), and ``None`` (to disable alignment). Omitting an alignment
+ uses the default. For example::
+
+ >>> print(tabulate([["one", "two"], ["three", "four"]], colalign=("right",))
+ ----- ----
+ one two
+ three four
+ ----- ----
+
+
+
Number formatting
~~~~~~~~~~~~~~~~~
``tabulate`` allows to define custom number formatting applied to all
columns of decimal numbers. Use ``floatfmt`` named argument::
- >>> print tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f")
+ >>> print(tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f"))
-- ------
pi 3.1416
e 2.7183
@@ -432,7 +461,7 @@
``floatfmt`` argument can be a list or a tuple of format strings,
one per column, in which case every column may have different number formatting::
- >>> print tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f"))
+ >>> print(tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f")))
--- ----- -------
0.1 0.123 0.12345
--- ----- -------
@@ -510,6 +539,16 @@
more 42
spam
+ ``github`` tables::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ | name | |
+ |--------|-------|
+ | eggs | 451 |
+ | more | 42 |
+ | spam | |
+
``grid`` tables::
>>> print(tabulate(table, headers, tablefmt="grid"))
@@ -621,8 +660,8 @@
-s REGEXP, --sep REGEXP use a custom column separator (default: whitespace)
-F FPFMT, --float FPFMT floating point number format (default: g)
-f FMT, --format FMT set output table format; supported formats:
- plain, simple, grid, fancy_grid, pipe, orgtbl,
- rst, mediawiki, html, latex, latex_raw,
+ plain, simple, github, grid, fancy_grid, pipe,
+ orgtbl, rst, mediawiki, html, latex, latex_raw,
latex_booktabs, tsv
(default: simple)
@@ -648,54 +687,25 @@
pretty-printers. Given a 10x10 table (a list of lists) of mixed text
and numeric data, ``tabulate`` appears to be slower than
``asciitable``, and faster than ``PrettyTable`` and ``texttable``
- The following mini-benchmark was run in Python 3.5.2 on Windows
+ The following mini-benchmark was run in Python 3.7.1 on Windows
::
- ================================= ========== ===========
- Table formatter time, μs rel. time
- ================================= ========== ===========
- csv to StringIO 14.5 1.0
- join with tabs and newlines 20.3 1.4
- asciitable (0.8.0) 355.1 24.5
- tabulate (0.8.2) 830.3 57.3
- tabulate (0.8.2, WIDE_CHARS_MODE) 1483.4 102.4
- PrettyTable (0.7.2) 1611.9 111.2
- texttable (0.8.8) 1916.5 132.3
- ================================= ========== ===========
-
+ =========================== ========== ===========
+ Table formatter time, μs rel. time
+ =========================== ========== ===========
+ csv to StringIO 15.6 1.0
+ join with tabs and newlines 20.4 1.3
+ asciitable (0.8.0) 285.5 18.3
+ tabulate (0.8.3) 685.8 44.0
+ PrettyTable (0.7.2) 1277.4 81.9
+ texttable (1.6.0) 1744.7 111.8
+ =========================== ========== ===========
Version history
---------------
- - 0.8.2: Bug fixes.
- - 0.8.1: Multiline data in several output formats.
- New ``latex_raw`` format.
- Column-specific floating point formatting.
- Python 3.5 & 3.6 support. Drop support for Python 2.6, 3.2, 3.3 (should still work).
- - 0.7.7: Identical to 0.7.6, resolving some PyPI issues.
- - 0.7.6: Bug fixes. New table formats (``psql``, ``jira``, ``moinmoin``, ``textile``).
- Wide character support. Printing from database cursors.
- Option to print row indices. Boolean columns. Ragged rows.
- Option to disable number parsing.
- - 0.7.5: Bug fixes. ``--float`` format option for the command line utility.
- - 0.7.4: Bug fixes. ``fancy_grid`` and ``html`` formats. Command line utility.
- - 0.7.3: Bug fixes. Python 3.4 support. Iterables of dicts. ``latex_booktabs`` format.
- - 0.7.2: Python 3.2 support.
- - 0.7.1: Bug fixes. ``tsv`` format. Column alignment can be disabled.
- - 0.7: ``latex`` tables. Printing lists of named tuples and NumPy
- record arrays. Fix printing date and time values. Python <= 2.6.4 is supported.
- - 0.6: ``mediawiki`` tables, bug fixes.
- - 0.5.1: Fix README.rst formatting. Optimize (performance similar to 0.4.4).
- - 0.5: ANSI color sequences. Printing dicts of iterables and Pandas' dataframes.
- - 0.4.4: Python 2.6 support.
- - 0.4.3: Bug fix, None as a missing value.
- - 0.4.2: Fix manifest file.
- - 0.4.1: Update license and documentation.
- - 0.4: Unicode support, Python3 support, ``rst`` tables.
- - 0.3: Initial PyPI release. Table formats: ``simple``, ``plain``,
- ``grid``, ``pipe``, and ``orgtbl``.
-
+ The full version history can be found at the `changelog <./CHANGELOG>`.
How to contribute
-----------------
@@ -761,3 +771,4 @@
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development :: Libraries
+Provides-Extra: widechars
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/README.rst new/tabulate-0.8.3/README.rst
--- old/tabulate-0.8.2/README.rst 2017-11-26 13:07:03.000000000 +0100
+++ new/tabulate-0.8.3/README.rst 2019-01-25 00:22:22.000000000 +0100
@@ -65,7 +65,7 @@
>>> table = [["Sun",696000,1989100000],["Earth",6371,5973.6],
... ["Moon",1737,73.5],["Mars",3390,641.85]]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
----- ------ -------------
Sun 696000 1.9891e+09
Earth 6371 5973.6
@@ -91,7 +91,7 @@
The second optional argument named ``headers`` defines a list of
column headers to be used::
- >>> print tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])
+ >>> print(tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"]))
Planet R (km) mass (x 10^29 kg)
-------- -------- -------------------
Sun 696000 1.9891e+09
@@ -101,8 +101,8 @@
If ``headers="firstrow"``, then the first row of data is used::
- >>> print tabulate([["Name","Age"],["Alice",24],["Bob",19]],
- ... headers="firstrow")
+ >>> print(tabulate([["Name","Age"],["Alice",24],["Bob",19]],
+ ... headers="firstrow"))
Name Age
------ -----
Alice 24
@@ -113,8 +113,8 @@
column indices are used. It also works for NumPy record arrays and
lists of dictionaries or named tuples::
- >>> print tabulate({"Name": ["Alice", "Bob"],
- ... "Age": [24, 19]}, headers="keys")
+ >>> print(tabulate({"Name": ["Alice", "Bob"],
+ ... "Age": [24, 19]}, headers="keys"))
Age Name
----- ------
24 Alice
@@ -150,6 +150,7 @@
- "plain"
- "simple"
+- "github"
- "grid"
- "fancy_grid"
- "pipe"
@@ -171,7 +172,7 @@
>>> table = [["spam",42],["eggs",451],["bacon",0]]
>>> headers = ["item", "qty"]
- >>> print tabulate(table, headers, tablefmt="plain")
+ >>> print(tabulate(table, headers, tablefmt="plain"))
item qty
spam 42
eggs 451
@@ -181,18 +182,29 @@
versions). It corresponds to ``simple_tables`` in `Pandoc Markdown
extensions`_::
- >>> print tabulate(table, headers, tablefmt="simple")
+ >>> print(tabulate(table, headers, tablefmt="simple"))
item qty
------ -----
spam 42
eggs 451
bacon 0
+``github`` follows the conventions of `Github flavored Markdown`. It
+corresponds to the ``pipe`` format without alignment colons::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ |--------|-------|
+ | spam | 42 |
+ | eggs | 451 |
+ | bacon | 0 |
+
+
``grid`` is like tables formatted by Emacs' `table.el`_
package. It corresponds to ``grid_tables`` in Pandoc Markdown
extensions::
- >>> print tabulate(table, headers, tablefmt="grid")
+ >>> print(tabulate(table, headers, tablefmt="grid"))
+--------+-------+
| item | qty |
+========+=======+
@@ -205,7 +217,7 @@
``fancy_grid`` draws a grid using box-drawing characters::
- >>> print tabulate(table, headers, tablefmt="fancy_grid")
+ >>> print(tabulate(table, headers, tablefmt="fancy_grid"))
╒════════╤═══════╕
│ item │ qty │
╞════════╪═══════╡
@@ -218,7 +230,7 @@
``presto`` is like tables formatted by Presto cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="presto"))
item | qty
--------+-------
spam | 42
@@ -227,7 +239,7 @@
``psql`` is like tables formatted by Postgres' psql cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="psql"))
+--------+-------+
| item | qty |
|--------+-------|
@@ -240,7 +252,7 @@
corresponds to ``pipe_tables`` in Pandoc. This format uses colons to
indicate column alignment::
- >>> print tabulate(table, headers, tablefmt="pipe")
+ >>> print(tabulate(table, headers, tablefmt="pipe"))
| item | qty |
|:-------|------:|
| spam | 42 |
@@ -250,7 +262,7 @@
``orgtbl`` follows the conventions of Emacs `org-mode`_, and is editable
also in the minor `orgtbl-mode`. Hence its name::
- >>> print tabulate(table, headers, tablefmt="orgtbl")
+ >>> print(tabulate(table, headers, tablefmt="orgtbl"))
| item | qty |
|--------+-------|
| spam | 42 |
@@ -259,7 +271,7 @@
``jira`` follows the conventions of Atlassian Jira markup language::
- >>> print tabulate(table, headers, tablefmt="jira")
+ >>> print(tabulate(table, headers, tablefmt="jira"))
|| item || qty ||
| spam | 42 |
| eggs | 451 |
@@ -267,7 +279,7 @@
``rst`` formats data like a simple table of the `reStructuredText`_ format::
- >>> print tabulate(table, headers, tablefmt="rst")
+ >>> print(tabulate(table, headers, tablefmt="rst"))
====== =====
item qty
====== =====
@@ -279,7 +291,7 @@
``mediawiki`` format produces a table markup used in `Wikipedia`_ and on
other MediaWiki-based sites::
- >>> print tabulate(table, headers, tablefmt="mediawiki")
+ >>> print(tabulate(table, headers, tablefmt="mediawiki"))
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
@@ -295,7 +307,7 @@
``moinmoin`` format produces a table markup used in `MoinMoin`_
wikis::
- >>> print tabulate(d,headers,tablefmt="moinmoin")
+ >>> print(tabulate(table, headers, tablefmt="moinmoin"))
|| ''' item ''' || ''' quantity ''' ||
|| spam || 41.999 ||
|| eggs || 451 ||
@@ -304,7 +316,7 @@
``youtrack`` format produces a table markup used in Youtrack
tickets::
- >>> print tabulate(d,headers,tablefmt="youtrack")
+ >>> print(tabulate(table, headers, tablefmt="youtrack"))
|| item || quantity ||
| spam | 41.999 |
| eggs | 451 |
@@ -312,7 +324,7 @@
``textile`` format produces a table markup used in `Textile`_ format::
- >>> print tabulate(table, headers, tablefmt='textile')
+ >>> print(tabulate(table, headers, tablefmt="textile"))
|_. item |_. qty |
|<. spam |>. 42 |
|<. eggs |>. 451 |
@@ -320,7 +332,7 @@
``html`` produces standard HTML markup::
- >>> print tabulate(table, headers, tablefmt="html")
+ >>> print(tabulate(table, headers, tablefmt="html"))
<table>
<tbody>
<tr><th>item </th><th style="text-align: right;"> qty</th></tr>
@@ -334,7 +346,7 @@
replacing special characters like ``_`` or ``\`` to their LaTeX
correspondents::
- >>> print tabulate(table, headers, tablefmt="latex")
+ >>> print(tabulate(table, headers, tablefmt="latex"))
\begin{tabular}{lr}
\hline
item & qty \\
@@ -378,7 +390,7 @@
Aligning by a decimal point works best when you need to compare
numbers at a glance::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]])
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]]))
----------
1.2345
123.45
@@ -389,7 +401,7 @@
Compare this with a more common right alignment::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right")
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right"))
------
1.2345
123.45
@@ -409,7 +421,7 @@
>>> table = list(csv.reader(StringIO("spam, 42\neggs, 451\n")))
>>> table
[['spam', ' 42'], ['eggs', ' 451']]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
---- ----
spam 42
eggs 451
@@ -417,13 +429,30 @@
+Custom column alignment
+~~~~~~~~~~~~~~~~~~~~~~~
+
+``tabulate`` allows a custom column alignment to override the above. The
+``colalign`` argument can be a list or a tuple of ``stralign`` named arguments.
+Possible column alignments are: ``right``, ``center``, ``left``, ``decimal``
+(only for numbers), and ``None`` (to disable alignment). Omitting an alignment
+uses the default. For example::
+
+ >>> print(tabulate([["one", "two"], ["three", "four"]], colalign=("right",))
+ ----- ----
+ one two
+ three four
+ ----- ----
+
+
+
Number formatting
~~~~~~~~~~~~~~~~~
``tabulate`` allows to define custom number formatting applied to all
columns of decimal numbers. Use ``floatfmt`` named argument::
- >>> print tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f")
+ >>> print(tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f"))
-- ------
pi 3.1416
e 2.7183
@@ -432,7 +461,7 @@
``floatfmt`` argument can be a list or a tuple of format strings,
one per column, in which case every column may have different number formatting::
- >>> print tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f"))
+ >>> print(tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f")))
--- ----- -------
0.1 0.123 0.12345
--- ----- -------
@@ -510,6 +539,16 @@
more 42
spam
+``github`` tables::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ | name | |
+ |--------|-------|
+ | eggs | 451 |
+ | more | 42 |
+ | spam | |
+
``grid`` tables::
>>> print(tabulate(table, headers, tablefmt="grid"))
@@ -621,8 +660,8 @@
-s REGEXP, --sep REGEXP use a custom column separator (default: whitespace)
-F FPFMT, --float FPFMT floating point number format (default: g)
-f FMT, --format FMT set output table format; supported formats:
- plain, simple, grid, fancy_grid, pipe, orgtbl,
- rst, mediawiki, html, latex, latex_raw,
+ plain, simple, github, grid, fancy_grid, pipe,
+ orgtbl, rst, mediawiki, html, latex, latex_raw,
latex_booktabs, tsv
(default: simple)
@@ -648,54 +687,25 @@
pretty-printers. Given a 10x10 table (a list of lists) of mixed text
and numeric data, ``tabulate`` appears to be slower than
``asciitable``, and faster than ``PrettyTable`` and ``texttable``
-The following mini-benchmark was run in Python 3.5.2 on Windows
+The following mini-benchmark was run in Python 3.7.1 on Windows
::
- ================================= ========== ===========
- Table formatter time, μs rel. time
- ================================= ========== ===========
- csv to StringIO 14.5 1.0
- join with tabs and newlines 20.3 1.4
- asciitable (0.8.0) 355.1 24.5
- tabulate (0.8.2) 830.3 57.3
- tabulate (0.8.2, WIDE_CHARS_MODE) 1483.4 102.4
- PrettyTable (0.7.2) 1611.9 111.2
- texttable (0.8.8) 1916.5 132.3
- ================================= ========== ===========
-
+ =========================== ========== ===========
+ Table formatter time, μs rel. time
+ =========================== ========== ===========
+ csv to StringIO 15.6 1.0
+ join with tabs and newlines 20.4 1.3
+ asciitable (0.8.0) 285.5 18.3
+ tabulate (0.8.3) 685.8 44.0
+ PrettyTable (0.7.2) 1277.4 81.9
+ texttable (1.6.0) 1744.7 111.8
+ =========================== ========== ===========
Version history
---------------
-- 0.8.2: Bug fixes.
-- 0.8.1: Multiline data in several output formats.
- New ``latex_raw`` format.
- Column-specific floating point formatting.
- Python 3.5 & 3.6 support. Drop support for Python 2.6, 3.2, 3.3 (should still work).
-- 0.7.7: Identical to 0.7.6, resolving some PyPI issues.
-- 0.7.6: Bug fixes. New table formats (``psql``, ``jira``, ``moinmoin``, ``textile``).
- Wide character support. Printing from database cursors.
- Option to print row indices. Boolean columns. Ragged rows.
- Option to disable number parsing.
-- 0.7.5: Bug fixes. ``--float`` format option for the command line utility.
-- 0.7.4: Bug fixes. ``fancy_grid`` and ``html`` formats. Command line utility.
-- 0.7.3: Bug fixes. Python 3.4 support. Iterables of dicts. ``latex_booktabs`` format.
-- 0.7.2: Python 3.2 support.
-- 0.7.1: Bug fixes. ``tsv`` format. Column alignment can be disabled.
-- 0.7: ``latex`` tables. Printing lists of named tuples and NumPy
- record arrays. Fix printing date and time values. Python <= 2.6.4 is supported.
-- 0.6: ``mediawiki`` tables, bug fixes.
-- 0.5.1: Fix README.rst formatting. Optimize (performance similar to 0.4.4).
-- 0.5: ANSI color sequences. Printing dicts of iterables and Pandas' dataframes.
-- 0.4.4: Python 2.6 support.
-- 0.4.3: Bug fix, None as a missing value.
-- 0.4.2: Fix manifest file.
-- 0.4.1: Update license and documentation.
-- 0.4: Unicode support, Python3 support, ``rst`` tables.
-- 0.3: Initial PyPI release. Table formats: ``simple``, ``plain``,
- ``grid``, ``pipe``, and ``orgtbl``.
-
+The full version history can be found at the `changelog <./CHANGELOG>`_.
How to contribute
-----------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/setup.py new/tabulate-0.8.3/setup.py
--- old/tabulate-0.8.2/setup.py 2017-10-25 22:06:55.000000000 +0200
+++ new/tabulate-0.8.3/setup.py 2018-09-24 21:53:30.000000000 +0200
@@ -37,7 +37,7 @@
setup(name='tabulate',
- version='0.8.2',
+ version='0.8.3',
description='Pretty-print tabular data',
long_description=LONG_DESCRIPTION,
author='Sergey Astanin',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/tabulate.egg-info/PKG-INFO new/tabulate-0.8.3/tabulate.egg-info/PKG-INFO
--- old/tabulate-0.8.2/tabulate.egg-info/PKG-INFO 2017-11-26 13:18:02.000000000 +0100
+++ new/tabulate-0.8.3/tabulate.egg-info/PKG-INFO 2019-01-25 00:26:41.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: tabulate
-Version: 0.8.2
+Version: 0.8.3
Summary: Pretty-print tabular data
Home-page: https://bitbucket.org/astanin/python-tabulate
Author: Sergey Astanin
@@ -65,7 +65,7 @@
>>> table = [["Sun",696000,1989100000],["Earth",6371,5973.6],
... ["Moon",1737,73.5],["Mars",3390,641.85]]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
----- ------ -------------
Sun 696000 1.9891e+09
Earth 6371 5973.6
@@ -91,7 +91,7 @@
The second optional argument named ``headers`` defines a list of
column headers to be used::
- >>> print tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])
+ >>> print(tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"]))
Planet R (km) mass (x 10^29 kg)
-------- -------- -------------------
Sun 696000 1.9891e+09
@@ -101,8 +101,8 @@
If ``headers="firstrow"``, then the first row of data is used::
- >>> print tabulate([["Name","Age"],["Alice",24],["Bob",19]],
- ... headers="firstrow")
+ >>> print(tabulate([["Name","Age"],["Alice",24],["Bob",19]],
+ ... headers="firstrow"))
Name Age
------ -----
Alice 24
@@ -113,8 +113,8 @@
column indices are used. It also works for NumPy record arrays and
lists of dictionaries or named tuples::
- >>> print tabulate({"Name": ["Alice", "Bob"],
- ... "Age": [24, 19]}, headers="keys")
+ >>> print(tabulate({"Name": ["Alice", "Bob"],
+ ... "Age": [24, 19]}, headers="keys"))
Age Name
----- ------
24 Alice
@@ -150,6 +150,7 @@
- "plain"
- "simple"
+ - "github"
- "grid"
- "fancy_grid"
- "pipe"
@@ -171,7 +172,7 @@
>>> table = [["spam",42],["eggs",451],["bacon",0]]
>>> headers = ["item", "qty"]
- >>> print tabulate(table, headers, tablefmt="plain")
+ >>> print(tabulate(table, headers, tablefmt="plain"))
item qty
spam 42
eggs 451
@@ -181,18 +182,29 @@
versions). It corresponds to ``simple_tables`` in `Pandoc Markdown
extensions`::
- >>> print tabulate(table, headers, tablefmt="simple")
+ >>> print(tabulate(table, headers, tablefmt="simple"))
item qty
------ -----
spam 42
eggs 451
bacon 0
+ ``github`` follows the conventions of `Github flavored Markdown`. It
+ corresponds to the ``pipe`` format without alignment colons::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ |--------|-------|
+ | spam | 42 |
+ | eggs | 451 |
+ | bacon | 0 |
+
+
``grid`` is like tables formatted by Emacs' `table.el`
package. It corresponds to ``grid_tables`` in Pandoc Markdown
extensions::
- >>> print tabulate(table, headers, tablefmt="grid")
+ >>> print(tabulate(table, headers, tablefmt="grid"))
+--------+-------+
| item | qty |
+========+=======+
@@ -205,7 +217,7 @@
``fancy_grid`` draws a grid using box-drawing characters::
- >>> print tabulate(table, headers, tablefmt="fancy_grid")
+ >>> print(tabulate(table, headers, tablefmt="fancy_grid"))
╒════════╤═══════╕
│ item │ qty │
╞════════╪═══════╡
@@ -218,7 +230,7 @@
``presto`` is like tables formatted by Presto cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="presto"))
item | qty
--------+-------
spam | 42
@@ -227,7 +239,7 @@
``psql`` is like tables formatted by Postgres' psql cli::
- >>> print tabulate.tabulate()
+ >>> print(tabulate(table, headers, tablefmt="psql"))
+--------+-------+
| item | qty |
|--------+-------|
@@ -240,7 +252,7 @@
corresponds to ``pipe_tables`` in Pandoc. This format uses colons to
indicate column alignment::
- >>> print tabulate(table, headers, tablefmt="pipe")
+ >>> print(tabulate(table, headers, tablefmt="pipe"))
| item | qty |
|:-------|------:|
| spam | 42 |
@@ -250,7 +262,7 @@
``orgtbl`` follows the conventions of Emacs `org-mode`, and is editable
also in the minor `orgtbl-mode`. Hence its name::
- >>> print tabulate(table, headers, tablefmt="orgtbl")
+ >>> print(tabulate(table, headers, tablefmt="orgtbl"))
| item | qty |
|--------+-------|
| spam | 42 |
@@ -259,7 +271,7 @@
``jira`` follows the conventions of Atlassian Jira markup language::
- >>> print tabulate(table, headers, tablefmt="jira")
+ >>> print(tabulate(table, headers, tablefmt="jira"))
|| item || qty ||
| spam | 42 |
| eggs | 451 |
@@ -267,7 +279,7 @@
``rst`` formats data like a simple table of the `reStructuredText` format::
- >>> print tabulate(table, headers, tablefmt="rst")
+ >>> print(tabulate(table, headers, tablefmt="rst"))
====== =====
item qty
====== =====
@@ -279,7 +291,7 @@
``mediawiki`` format produces a table markup used in `Wikipedia` and on
other MediaWiki-based sites::
- >>> print tabulate(table, headers, tablefmt="mediawiki")
+ >>> print(tabulate(table, headers, tablefmt="mediawiki"))
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
@@ -295,7 +307,7 @@
``moinmoin`` format produces a table markup used in `MoinMoin`
wikis::
- >>> print tabulate(d,headers,tablefmt="moinmoin")
+ >>> print(tabulate(table, headers, tablefmt="moinmoin"))
|| ''' item ''' || ''' quantity ''' ||
|| spam || 41.999 ||
|| eggs || 451 ||
@@ -304,7 +316,7 @@
``youtrack`` format produces a table markup used in Youtrack
tickets::
- >>> print tabulate(d,headers,tablefmt="youtrack")
+ >>> print(tabulate(table, headers, tablefmt="youtrack"))
|| item || quantity ||
| spam | 41.999 |
| eggs | 451 |
@@ -312,7 +324,7 @@
``textile`` format produces a table markup used in `Textile` format::
- >>> print tabulate(table, headers, tablefmt='textile')
+ >>> print(tabulate(table, headers, tablefmt="textile"))
|_. item |_. qty |
|<. spam |>. 42 |
|<. eggs |>. 451 |
@@ -320,7 +332,7 @@
``html`` produces standard HTML markup::
- >>> print tabulate(table, headers, tablefmt="html")
+ >>> print(tabulate(table, headers, tablefmt="html"))
<table>
<tbody>
<tr><th>item </th><th style="text-align: right;"> qty</th></tr>
@@ -334,7 +346,7 @@
replacing special characters like ```` or ``\`` to their LaTeX
correspondents::
- >>> print tabulate(table, headers, tablefmt="latex")
+ >>> print(tabulate(table, headers, tablefmt="latex"))
\begin{tabular}{lr}
\hline
item & qty \\
@@ -378,7 +390,7 @@
Aligning by a decimal point works best when you need to compare
numbers at a glance::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]])
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]]))
----------
1.2345
123.45
@@ -389,7 +401,7 @@
Compare this with a more common right alignment::
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right")
+ >>> print(tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right"))
------
1.2345
123.45
@@ -409,7 +421,7 @@
>>> table = list(csv.reader(StringIO("spam, 42\neggs, 451\n")))
>>> table
[['spam', ' 42'], ['eggs', ' 451']]
- >>> print tabulate(table)
+ >>> print(tabulate(table))
---- ----
spam 42
eggs 451
@@ -417,13 +429,30 @@
+ Custom column alignment
+ ~~~~~~~~~~~~~~~~~~~~~~~
+
+ ``tabulate`` allows a custom column alignment to override the above. The
+ ``colalign`` argument can be a list or a tuple of ``stralign`` named arguments.
+ Possible column alignments are: ``right``, ``center``, ``left``, ``decimal``
+ (only for numbers), and ``None`` (to disable alignment). Omitting an alignment
+ uses the default. For example::
+
+ >>> print(tabulate([["one", "two"], ["three", "four"]], colalign=("right",))
+ ----- ----
+ one two
+ three four
+ ----- ----
+
+
+
Number formatting
~~~~~~~~~~~~~~~~~
``tabulate`` allows to define custom number formatting applied to all
columns of decimal numbers. Use ``floatfmt`` named argument::
- >>> print tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f")
+ >>> print(tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f"))
-- ------
pi 3.1416
e 2.7183
@@ -432,7 +461,7 @@
``floatfmt`` argument can be a list or a tuple of format strings,
one per column, in which case every column may have different number formatting::
- >>> print tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f"))
+ >>> print(tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f")))
--- ----- -------
0.1 0.123 0.12345
--- ----- -------
@@ -510,6 +539,16 @@
more 42
spam
+ ``github`` tables::
+
+ >>> print(tabulate(table, headers, tablefmt="github"))
+ | item | qty |
+ | name | |
+ |--------|-------|
+ | eggs | 451 |
+ | more | 42 |
+ | spam | |
+
``grid`` tables::
>>> print(tabulate(table, headers, tablefmt="grid"))
@@ -621,8 +660,8 @@
-s REGEXP, --sep REGEXP use a custom column separator (default: whitespace)
-F FPFMT, --float FPFMT floating point number format (default: g)
-f FMT, --format FMT set output table format; supported formats:
- plain, simple, grid, fancy_grid, pipe, orgtbl,
- rst, mediawiki, html, latex, latex_raw,
+ plain, simple, github, grid, fancy_grid, pipe,
+ orgtbl, rst, mediawiki, html, latex, latex_raw,
latex_booktabs, tsv
(default: simple)
@@ -648,54 +687,25 @@
pretty-printers. Given a 10x10 table (a list of lists) of mixed text
and numeric data, ``tabulate`` appears to be slower than
``asciitable``, and faster than ``PrettyTable`` and ``texttable``
- The following mini-benchmark was run in Python 3.5.2 on Windows
+ The following mini-benchmark was run in Python 3.7.1 on Windows
::
- ================================= ========== ===========
- Table formatter time, μs rel. time
- ================================= ========== ===========
- csv to StringIO 14.5 1.0
- join with tabs and newlines 20.3 1.4
- asciitable (0.8.0) 355.1 24.5
- tabulate (0.8.2) 830.3 57.3
- tabulate (0.8.2, WIDE_CHARS_MODE) 1483.4 102.4
- PrettyTable (0.7.2) 1611.9 111.2
- texttable (0.8.8) 1916.5 132.3
- ================================= ========== ===========
-
+ =========================== ========== ===========
+ Table formatter time, μs rel. time
+ =========================== ========== ===========
+ csv to StringIO 15.6 1.0
+ join with tabs and newlines 20.4 1.3
+ asciitable (0.8.0) 285.5 18.3
+ tabulate (0.8.3) 685.8 44.0
+ PrettyTable (0.7.2) 1277.4 81.9
+ texttable (1.6.0) 1744.7 111.8
+ =========================== ========== ===========
Version history
---------------
- - 0.8.2: Bug fixes.
- - 0.8.1: Multiline data in several output formats.
- New ``latex_raw`` format.
- Column-specific floating point formatting.
- Python 3.5 & 3.6 support. Drop support for Python 2.6, 3.2, 3.3 (should still work).
- - 0.7.7: Identical to 0.7.6, resolving some PyPI issues.
- - 0.7.6: Bug fixes. New table formats (``psql``, ``jira``, ``moinmoin``, ``textile``).
- Wide character support. Printing from database cursors.
- Option to print row indices. Boolean columns. Ragged rows.
- Option to disable number parsing.
- - 0.7.5: Bug fixes. ``--float`` format option for the command line utility.
- - 0.7.4: Bug fixes. ``fancy_grid`` and ``html`` formats. Command line utility.
- - 0.7.3: Bug fixes. Python 3.4 support. Iterables of dicts. ``latex_booktabs`` format.
- - 0.7.2: Python 3.2 support.
- - 0.7.1: Bug fixes. ``tsv`` format. Column alignment can be disabled.
- - 0.7: ``latex`` tables. Printing lists of named tuples and NumPy
- record arrays. Fix printing date and time values. Python <= 2.6.4 is supported.
- - 0.6: ``mediawiki`` tables, bug fixes.
- - 0.5.1: Fix README.rst formatting. Optimize (performance similar to 0.4.4).
- - 0.5: ANSI color sequences. Printing dicts of iterables and Pandas' dataframes.
- - 0.4.4: Python 2.6 support.
- - 0.4.3: Bug fix, None as a missing value.
- - 0.4.2: Fix manifest file.
- - 0.4.1: Update license and documentation.
- - 0.4: Unicode support, Python3 support, ``rst`` tables.
- - 0.3: Initial PyPI release. Table formats: ``simple``, ``plain``,
- ``grid``, ``pipe``, and ``orgtbl``.
-
+ The full version history can be found at the `changelog <./CHANGELOG>`.
How to contribute
-----------------
@@ -761,3 +771,4 @@
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development :: Libraries
+Provides-Extra: widechars
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/tabulate.py new/tabulate-0.8.3/tabulate.py
--- old/tabulate-0.8.2/tabulate.py 2017-10-25 22:07:11.000000000 +0200
+++ new/tabulate-0.8.3/tabulate.py 2019-01-25 00:18:32.000000000 +0100
@@ -4,12 +4,17 @@
from __future__ import print_function
from __future__ import unicode_literals
-from collections import namedtuple, Iterable
+from collections import namedtuple
from platform import python_version_tuple
import re
import math
+if python_version_tuple() >= ("3", "3", "0"):
+ from collections.abc import Iterable
+else:
+ from collections import Iterable
+
if python_version_tuple()[0] < "3":
from itertools import izip_longest
from functools import partial
@@ -47,7 +52,7 @@
__all__ = ["tabulate", "tabulate_formats", "simple_separated_format"]
-__version__ = "0.8.2"
+__version__ = "0.8.3"
# minimum extra space in headers
@@ -247,6 +252,15 @@
headerrow=DataRow("│", "│", "│"),
datarow=DataRow("│", "│", "│"),
padding=1, with_header_hide=None),
+ "github":
+ TableFormat(lineabove=Line("|", "-", "|", "|"),
+ linebelowheader=Line("|", "-", "|", "|"),
+ linebetweenrows=None,
+ linebelow=None,
+ headerrow=DataRow("|", "|", "|"),
+ datarow=DataRow("|", "|", "|"),
+ padding=1,
+ with_header_hide=["lineabove"]),
"pipe":
TableFormat(lineabove=_pipe_line_with_colons,
linebelowheader=_pipe_line_with_colons,
@@ -958,7 +972,8 @@
def tabulate(tabular_data, headers=(), tablefmt="simple",
floatfmt=_DEFAULT_FLOATFMT, numalign="decimal", stralign="left",
- missingval=_DEFAULT_MISSINGVAL, showindex="default", disable_numparse=False):
+ missingval=_DEFAULT_MISSINGVAL, showindex="default", disable_numparse=False,
+ colalign=None):
"""Format a fixed width table for pretty printing.
>>> print(tabulate([[1, 2.34], [-56, "8.999"], ["2", "10001"]]))
@@ -1287,6 +1302,10 @@
# align columns
aligns = [numalign if ct in [int,float] else stralign for ct in coltypes]
+ if colalign is not None:
+ assert isinstance(colalign, Iterable)
+ for idx, align in enumerate(colalign):
+ aligns[idx] = align
minwidths = [width_fn(h) + MIN_PADDING for h in headers] if headers else [0]*len(cols)
cols = [_align_column(c, a, minw, has_invisible, enable_widechars, is_multiline)
for c, a, minw in zip(cols, aligns, minwidths)]
@@ -1461,14 +1480,16 @@
usage = textwrap.dedent(_main.__doc__)
try:
opts, args = getopt.getopt(sys.argv[1:],
- "h1o:s:F:f:",
- ["help", "header", "output", "sep=", "float=", "format="])
+ "h1o:s:F:A:f:",
+ ["help", "header", "output", "sep=", "float=", "align=",
+ "format="])
except getopt.GetoptError as e:
print(e)
print(usage)
sys.exit(2)
headers = []
floatfmt = _DEFAULT_FLOATFMT
+ colalign = None
tablefmt = "simple"
sep = r"\s+"
outfile = "-"
@@ -1479,6 +1500,8 @@
outfile = value
elif opt in ["-F", "--float"]:
floatfmt = value
+ elif opt in ["-C", "--colalign"]:
+ colalign = value.split()
elif opt in ["-f", "--format"]:
if value not in tabulate_formats:
print("%s is not a supported table format" % value)
@@ -1497,17 +1520,20 @@
f = sys.stdin
if _is_file(f):
_pprint_file(f, headers=headers, tablefmt=tablefmt,
- sep=sep, floatfmt=floatfmt, file=out)
+ sep=sep, floatfmt=floatfmt, file=out,
+ colalign=colalign)
else:
with open(f) as fobj:
_pprint_file(fobj, headers=headers, tablefmt=tablefmt,
- sep=sep, floatfmt=floatfmt, file=out)
+ sep=sep, floatfmt=floatfmt, file=out,
+ colalign=colalign)
-def _pprint_file(fobject, headers, tablefmt, sep, floatfmt, file):
+def _pprint_file(fobject, headers, tablefmt, sep, floatfmt, file, colalign):
rows = fobject.readlines()
table = [re.split(sep, r.rstrip()) for r in rows if r.strip()]
- print(tabulate(table, headers, tablefmt, floatfmt=floatfmt), file=file)
+ print(tabulate(table, headers, tablefmt, floatfmt=floatfmt,
+ colalign=colalign), file=file)
if __name__ == "__main__":
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tabulate-0.8.2/test/test_output.py new/tabulate-0.8.3/test/test_output.py
--- old/tabulate-0.8.2/test/test_output.py 2017-10-25 22:00:06.000000000 +0200
+++ new/tabulate-0.8.3/test/test_output.py 2019-01-25 00:12:58.000000000 +0100
@@ -191,6 +191,16 @@
assert_equal(expected, result)
+def test_github():
+ "Output: github with headers"
+ expected = '\n'.join(['| strings | numbers |',
+ '|-----------|-----------|',
+ '| spam | 41.9999 |',
+ '| eggs | 451 |',])
+ result = tabulate(_test_table, _test_table_headers, tablefmt="github")
+ assert_equal(expected, result)
+
+
def test_grid():
"Output: grid with headers"
expected = '\n'.join(['+-----------+-----------+',
@@ -936,6 +946,12 @@
expected = '0.1 0.123 0.12345'
assert_equal(expected, result)
+def test_colalign_multi():
+ "Output: string columns with custom colalign"
+ result = tabulate([["one", "two"], ["three", "four"]], colalign=("right",), tablefmt="plain")
+ expected = ' one two\nthree four'
+ assert_equal(expected, result)
+
def test_float_conversions():
"Output: float format parsed"
test_headers = ["str", "bad_float", "just_float", 'with_inf', 'with_nan', 'neg_inf']