Hello community, here is the log from the commit of package python-texttable for openSUSE:Leap:15.2 checked in at 2020-03-02 13:23:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-texttable (Old) and /work/SRC/openSUSE:Leap:15.2/.python-texttable.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-texttable" Mon Mar 2 13:23:57 2020 rev:17 rq:777216 version:1.6.2 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-texttable/python-texttable.changes 2020-01-15 15:53:48.947610712 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-texttable.new.26092/python-texttable.changes 2020-03-02 13:23:58.334471715 +0100 @@ -1,0 +2,36 @@ +Mon Jul 22 12:41:17 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 1.6.2: + * Fix auto-formatting NaN + +------------------------------------------------------------------- +Fri Feb 15 12:46:31 UTC 2019 - John Vandenberg <[email protected]> + +- Update to 1.6.1 + * Packaging fixes only + +------------------------------------------------------------------- +Fri Feb 15 01:35:10 UTC 2019 - John Vandenberg <[email protected]> + +- Update to 1.6.0 + * Added texttable.pyi + * Added missing set_header_align method stub + * Allow chaining of method calls + * Replace distutils with setuptools + * Create a method for redefining the max_width + * Switch to MIT License + * Use wcwidth if available for better rendering (basic emoji support) + * Update README.md + +------------------------------------------------------------------- +Fri Jul 20 11:36:41 UTC 2018 - [email protected] + +- Version update to 1.4.0: + * Add set_header_align() method (#45) + * Fix missing textwrapper command when cjkwrap is not used (#43) + * Remove redundant code for unsupported/EOL Python (#31) + * Use test_cjkwrap only when cjkwrap is available (#35) + * Use cjkwrap for better CJK text support (#34) +- Enable tests + +------------------------------------------------------------------- Old: ---- texttable-1.1.1.tar.gz New: ---- texttable-1.6.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-texttable.spec ++++++ --- /var/tmp/diff_new_pack.MtHHSE/_old 2020-03-02 13:23:59.042473123 +0100 +++ /var/tmp/diff_new_pack.MtHHSE/_new 2020-03-02 13:23:59.042473123 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-texttable # -# Copyright (c) 2017 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,29 +12,26 @@ # 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-%{**}} -%bcond_with test Name: python-texttable -Version: 1.1.1 +Version: 1.6.2 Release: 0 Summary: Module for creating simple ASCII tables -License: LGPL-3.0 +License: MIT Group: Development/Languages/Python -Url: https://github.com/foutaise/texttable/ +URL: https://github.com/foutaise/texttable/ Source: https://files.pythonhosted.org/packages/source/t/texttable/texttable-%{version}.tar.gz -BuildRequires: %{python_module devel} +BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} -%if %{with test} -BuildRequires: python3-testsuite -%endif BuildRequires: fdupes BuildRequires: python-rpm-macros +Requires: python-base +Recommends: python-wcwidth BuildArch: noarch - %python_subpackages %description @@ -51,14 +48,12 @@ %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} -%if %{with test} %check -%python_exec setup.py test -%endif +%pytest tests.py %files %{python_files} %license LICENSE -%doc README.md +%doc README.md CHANGELOG.md %{python_sitelib}/* %changelog ++++++ texttable-1.1.1.tar.gz -> texttable-1.6.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/.coveragerc new/texttable-1.6.2/.coveragerc --- old/texttable-1.1.1/.coveragerc 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/.coveragerc 2018-06-12 19:37:11.000000000 +0200 @@ -0,0 +1,10 @@ +# .coveragerc to control coverage.py + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma: + pragma: no cover + + # Don't complain if non-runnable code isn't run: + if __name__ == .__main__.: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/.gitignore new/texttable-1.6.2/.gitignore --- old/texttable-1.1.1/.gitignore 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/.gitignore 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -/.cache/ -/.coverage -/.tox/ -/MANIFEST -/__pycache__/ -*.egg-info/ -*.pyc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/CHANGELOG.md new/texttable-1.6.2/CHANGELOG.md --- old/texttable-1.1.1/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/CHANGELOG.md 2019-07-01 11:39:46.000000000 +0200 @@ -0,0 +1,66 @@ +# Version History + +v1.6.2 (2019-07-01) +* Fix auto-formatting NaN (https://github.com/foutaise/texttable/pull/60) + +v1.6.1 (2019-02-15) +* Include tests, license in source tarball (https://github.com/foutaise/texttable/issues/58) +* Add changelog + +v1.6.0 (2019-01-17) +* Add basic emoji support (https://github.com/foutaise/texttable/issues/55) + +v1.5.0 (2018-11-02) +* Create a method for redefining the max_width (https://github.com/foutaise/texttable/issues/54) +* Use setuptools instead of distutils to upload metadata to PyPI (https://github.com/foutaise/texttable/issues/49) +* Switch to MIT license + +v1.4.0 (2018-06-22) +* Add set_header_align() method (https://github.com/foutaise/texttable/issues/45) + +v1.3.1 (2018-06-12) +* Fix missing textwrapper command when cjkwrap is not used (https://github.com/foutaise/texttable/issues/43) + +v1.3.0 (2018-06-11) +* Remove redundant code for unsupported/EOL Python (https://github.com/foutaise/texttable/pull/31) + +v1.2.1 (2018-01-03) +* Use test_cjkwrap only when cjkwrap is available (https://github.com/foutaise/texttable/issues/35) + +v1.2.0 (2018-01-03) +* Use cjkwrap for better CJK text support (https://github.com/foutaise/texttable/issues/34) + +v1.1.1 (2017-10-26) +* Fallback to text on TypeError (https://github.com/foutaise/texttable/issues/28) + +v1.1.0 (2017-10-22) +* Easier formatting, allow callable as a column datatype (PR https://github.com/foutaise/texttable/pull/27) + +v1.0.0 (2017-10-14) +* Fix bug in wide chars handling (https://github.com/foutaise/texttable/issues/9) +* Avoid use of sys.version to obtain Python version (https://github.com/foutaise/texttable/pull/24) + +v0.9.1 (2017-06-27) +* Add support for combining characters (https://github.com/foutaise/texttable/pull/19) + +v0.9.0 (2017-05-16) +* Fix width of table exceeds max_width parameter (https://github.com/foutaise/texttable/pull/15) + +v0.8.8 (2017-03-30) +* Add east asian support (https://github.com/foutaise/texttable/pull/12) +* Relative col widths improvements + unit tests (https://github.com/foutaise/texttable/pull/13) + +v0.8.7 (2016-11-14) +* Proper handling of unicode in headers (https://github.com/foutaise/texttable/issues/9) + +v0.8.6 (2016-10-21) +* Preserve empty lines (https://github.com/foutaise/texttable/pull/8) + +v0.8.5 (2016-10-16) +* Better handling of unicode encodings (https://github.com/foutaise/texttable/pull/6) + +v0.8.4 (2015-11-16) +* Fix pypi url + +v0.8.3 (2015-11-16) +* Update README.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/LICENSE new/texttable-1.6.2/LICENSE --- old/texttable-1.1.1/LICENSE 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/LICENSE 2019-02-15 13:19:32.000000000 +0100 @@ -1,165 +1,22 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 +The MIT License (MIT) - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Copyright (c) 2019 Gerome Fournier +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/MANIFEST.in new/texttable-1.6.2/MANIFEST.in --- old/texttable-1.1.1/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/MANIFEST.in 2019-02-15 11:13:55.000000000 +0100 @@ -0,0 +1,8 @@ +include *.md +include *.py +include *.pyi +include LICENSE +include tox.ini +include .coveragerc + +global-exclude *.pyc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/PKG-INFO new/texttable-1.6.2/PKG-INFO --- old/texttable-1.1.1/PKG-INFO 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/PKG-INFO 2019-07-01 11:47:18.000000000 +0200 @@ -1,23 +1,284 @@ -Metadata-Version: 1.0 +Metadata-Version: 2.1 Name: texttable -Version: 1.1.1 +Version: 1.6.2 Summary: module for creating simple ASCII tables Home-page: https://github.com/foutaise/texttable/ Author: Gerome Fournier Author-email: [email protected] -License: LGPL -Download-URL: https://github.com/foutaise/texttable/archive/v1.1.1.tar.gz -Description: texttable is a module to generate a formatted text table, using ASCII - characters. +License: MIT +Download-URL: https://github.com/foutaise/texttable/archive/v1.6.2.tar.gz +Description: # texttable + + Python module for creating simple ASCII tables + + ## Availability + + This module is available on [PyPI](https://pypi.org/project/texttable/), and has been packaged for several Linux/Unix platforms + ([Debian](https://packages.debian.org/search?&searchon=names&keywords=python-texttable+), + [FreeBSD](https://www.freebsd.org/cgi/ports.cgi?query=texttable&stype=all), Fedora, Suse...). + + ## Dependencies + + If available, [cjkwrap](https://github.com/fgallaire/cjkwrap) library is used instead of textwrap, for a better wrapping of CJK text. + + If available, [wcwidth](https://github.com/jquast/wcwidth) library is used for a better rendering (basic emoji support). + + ## Documentation + + ``` + NAME + texttable - module for creating simple ASCII tables + + FILE + /usr/local/lib/python2.7/dist-packages/texttable.py + + DESCRIPTION + + Example: + + table = Texttable() + table.set_cols_align(["l", "r", "c"]) + table.set_cols_valign(["t", "m", "b"]) + table.add_rows([["Name", "Age", "Nickname"], + ["Mr\nXavier\nHuon", 32, "Xav'"], + ["Mr\nBaptiste\nClement", 1, "Baby"], + ["Mme\nLouise\nBourgeau", 28, "Lou\n\nLoue"]]) + print table.draw() + "\n" + + table = Texttable() + table.set_deco(Texttable.HEADER) + table.set_cols_dtype(['t', # text + 'f', # float (decimal) + 'e', # float (exponent) + 'i', # integer + 'a']) # automatic + table.set_cols_align(["l", "r", "r", "r", "l"]) + table.add_rows([["text", "float", "exp", "int", "auto"], + ["abcd", "67", 654, 89, 128.001], + ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023], + ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], + ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) + print table.draw() + + Result: + + +----------+-----+----------+ + | Name | Age | Nickname | + +==========+=====+==========+ + | Mr | | | + | Xavier | 32 | | + | Huon | | Xav' | + +----------+-----+----------+ + | Mr | | | + | Baptiste | 1 | | + | Clement | | Baby | + +----------+-----+----------+ + | Mme | | Lou | + | Louise | 28 | | + | Bourgeau | | Loue | + +----------+-----+----------+ + + text float exp int auto + ============================================== + abcd 67.000 6.540e+02 89 128.001 + efghijk 67.543 6.540e-01 90 1.280e+22 + lmn 0.000 5.000e-78 89 0.000 + opqrstu 0.023 5.000e+78 92 1.280e+22 + + CLASSES + class Texttable + | Methods defined here: + | + | __init__(self, max_width=80) + | Constructor + | + | - max_width is an integer, specifying the maximum width of the table + | - if set to 0, size is unlimited, therefore cells won't be wrapped + | + | add_row(self, array) + | Add a row in the rows stack + | + | - cells can contain newlines and tabs + | + | add_rows(self, rows, header=True) + | Add several rows in the rows stack + | + | - The 'rows' argument can be either an iterator returning arrays, + | or a by-dimensional array + | - 'header' specifies if the first row should be used as the header + | of the table + | + | draw(self) + | Draw the table + | + | - the table is returned as a whole string + | + | header(self, array) + | Specify the header of the table + | + | reset(self) + | Reset the instance + | + | - reset rows and header + | + | set_chars(self, array) + | Set the characters used to draw lines between rows and columns + | + | - the array should contain 4 fields: + | + | [horizontal, vertical, corner, header] + | + | - default is set to: + | + | ['-', '|', '+', '='] + | + | set_cols_align(self, array) + | Set the desired columns alignment + | + | - the elements of the array should be either "l", "c" or "r": + | + | * "l": column flushed left + | * "c": column centered + | * "r": column flushed right + | + | set_cols_dtype(self, array) + | Set the desired columns datatype for the cols. + | + | - the elements of the array should be either a callable or any of + | "a", "t", "f", "e" or "i": + | + | * "a": automatic (try to use the most appropriate datatype) + | * "t": treat as text + | * "f": treat as float in decimal format + | * "e": treat as float in exponential format + | * "i": treat as int + | * a callable: should return formatted string for any value given + | + | - by default, automatic datatyping is used for each column + | + | set_cols_valign(self, array) + | Set the desired columns vertical alignment + | + | - the elements of the array should be either "t", "m" or "b": + | + | * "t": column aligned on the top of the cell + | * "m": column aligned on the middle of the cell + | * "b": column aligned on the bottom of the cell + | + | set_cols_width(self, array) + | Set the desired columns width + | + | - the elements of the array should be integers, specifying the + | width of each column. For example: + | + | [10, 20, 5] + | + | set_deco(self, deco) + | Set the table decoration + | + | - 'deco' can be a combinaison of: + | + | Texttable.BORDER: Border around the table + | Texttable.HEADER: Horizontal line below the header + | Texttable.HLINES: Horizontal lines between rows + | Texttable.VLINES: Vertical lines between columns + | + | All of them are enabled by default + | + | - example: + | + | Texttable.BORDER | Texttable.HEADER + | + | set_header_align(self, array) + | Set the desired header alignment + | + | - the elements of the array should be either "l", "c" or "r": + | + | * "l": column flushed left + | * "c": column centered + | * "r": column flushed right + | + | set_max_width(self, max_width) + | Set the maximum width of the table + | + | - max_width is an integer, specifying the maximum width of the table + | - if set to 0, size is unlimited, therefore cells won't be wrapped + | + | set_precision(self, width) + | Set the desired precision for float/exponential formats + | + | - width must be an integer >= 0 + | + | - default value is set to 3 + | + | ---------------------------------------------------------------------- + | Data and other attributes defined here: + | + | BORDER = 1 + | + | HEADER = 2 + | + | HLINES = 4 + | + | VLINES = 8 + + DATA + __all__ = ['Texttable', 'ArraySizeError'] + __author__ = 'Gerome Fournier <jef(at)foutaise.org>' + __credits__ = 'Jeff Kowalczyk:\n - textwrap improved import\n ...at... + __license__ = 'MIT' + __version__ = '1.6.2' + + VERSION + 1.6.2 + + AUTHOR + Gerome Fournier <jef(at)foutaise.org> + + CREDITS + Jeff Kowalczyk: + - textwrap improved import + - comment concerning header output + + Anonymous: + - add_rows method, for adding rows in one go + + Sergey Simonenko: + - redefined len() function to deal with non-ASCII characters + + Roger Lew: + - columns datatype specifications + + Brian Peterson: + - better handling of unicode errors + + Frank Sachsenheim: + - add Python 2/3-compatibility + + Maximilian Hils: + - fix minor bug for Python 3 compatibility + + frinkelpi: + - preserve empty lines + ``` + Platform: any -Classifier: Development Status :: 4 - Beta +Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: Intended Audience :: End Users/Desktop -Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) +Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: POSIX Classifier: Operating System :: MacOS Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Text Processing Classifier: Topic :: Utilities +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Description-Content-Type: text/markdown diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/README.md new/texttable-1.6.2/README.md --- old/texttable-1.1.1/README.md 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/README.md 2019-07-01 11:40:25.000000000 +0200 @@ -4,10 +4,16 @@ ## Availability -This module is available on [PypI](https://pypi.python.org/pypi/texttable/1.1.1), and has been packaged for several Linux/Unix platforms +This module is available on [PyPI](https://pypi.org/project/texttable/), and has been packaged for several Linux/Unix platforms ([Debian](https://packages.debian.org/search?&searchon=names&keywords=python-texttable+), [FreeBSD](https://www.freebsd.org/cgi/ports.cgi?query=texttable&stype=all), Fedora, Suse...). +## Dependencies + +If available, [cjkwrap](https://github.com/fgallaire/cjkwrap) library is used instead of textwrap, for a better wrapping of CJK text. + +If available, [wcwidth](https://github.com/jquast/wcwidth) library is used for a better rendering (basic emoji support). + ## Documentation ``` @@ -174,6 +180,21 @@ | | Texttable.BORDER | Texttable.HEADER | + | set_header_align(self, array) + | Set the desired header alignment + | + | - the elements of the array should be either "l", "c" or "r": + | + | * "l": column flushed left + | * "c": column centered + | * "r": column flushed right + | + | set_max_width(self, max_width) + | Set the maximum width of the table + | + | - max_width is an integer, specifying the maximum width of the table + | - if set to 0, size is unlimited, therefore cells won't be wrapped + | | set_precision(self, width) | Set the desired precision for float/exponential formats | @@ -196,11 +217,11 @@ __all__ = ['Texttable', 'ArraySizeError'] __author__ = 'Gerome Fournier <jef(at)foutaise.org>' __credits__ = 'Jeff Kowalczyk:\n - textwrap improved import\n ...at... - __license__ = 'LGPL' - __version__ = '1.1.1' + __license__ = 'MIT' + __version__ = '1.6.2' VERSION - 1.1.1 + 1.6.2 AUTHOR Gerome Fournier <jef(at)foutaise.org> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/setup.cfg new/texttable-1.6.2/setup.cfg --- old/texttable-1.1.1/setup.cfg 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/setup.cfg 2019-07-01 11:47:18.000000000 +0200 @@ -0,0 +1,4 @@ +[egg_info] +tag_build = +tag_date = 0 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/setup.py new/texttable-1.6.2/setup.py --- old/texttable-1.1.1/setup.py 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/setup.py 2019-07-01 11:40:28.000000000 +0200 @@ -1,54 +1,34 @@ #!/usr/bin/env python # # texttable - module for creating simple ASCII tables -# Copyright (C) 2003-2015 Gerome Fournier <jef(at)foutaise.org> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# Copyright (C) 2003-2019 Gerome Fournier <jef(at)foutaise.org> -DESCRIPTION = "module for creating simple ASCII tables" - -LONG_DESCRIPTION = """\ -texttable is a module to generate a formatted text table, using ASCII -characters.""" +from setuptools import setup -import sys +DESCRIPTION = "module for creating simple ASCII tables" -from distutils.core import setup -if sys.version < '2.2.3': - from distutils.dist import DistributionMetadata - DistributionMetadata.classifiers = None - DistributionMetadata.download_url = None +with open("README.md") as f: + LONG_DESCRIPTION = f.read() setup( - name = "texttable", - version = "1.1.1", - author = "Gerome Fournier", - author_email = "[email protected]", - url = "https://github.com/foutaise/texttable/", - download_url = "https://github.com/foutaise/texttable/archive/v1.1.1.tar.gz", - license = "LGPL", - py_modules = ["texttable"], - description = DESCRIPTION, - long_description = LONG_DESCRIPTION, - platforms = "any", - classifiers = [ - 'Development Status :: 4 - Beta', + name="texttable", + version="1.6.2", + author="Gerome Fournier", + author_email="[email protected]", + url="https://github.com/foutaise/texttable/", + download_url="https://github.com/foutaise/texttable/archive/v1.6.2.tar.gz", + license="MIT", + py_modules=["texttable"], + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + long_description_content_type="text/markdown", + platforms="any", + classifiers=[ + 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: End Users/Desktop', - 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', + 'License :: OSI Approved :: MIT License', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: MacOS', @@ -61,5 +41,6 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ] ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/tests.py new/texttable-1.6.2/tests.py --- old/texttable-1.1.1/tests.py 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/tests.py 2019-06-24 14:19:02.000000000 +0200 @@ -121,6 +121,44 @@ +----+-------+ ''') +def test_exceeding_max_width3(): + table = Texttable() + table.set_max_width(35) + table.set_deco(Texttable.HEADER) + table.add_rows([ + ["key", "value"], + [1, "a"], + [2, "b"], + [3, "very long, very long, very long"], + ]) + assert clean(table.draw()) == dedent('''\ + key value + =================================== + 1 a + 2 b + 3 very long, very long, very + long + ''') + +def test_exceeding_max_width4(): + table = Texttable() + table.set_max_width(14) + table.add_rows([ + ["a", "b"], + [1, "+"], + [22, "++++++++"], + ]) + assert clean(table.draw()) == dedent('''\ + +----+-------+ + | a | b | + +====+=======+ + | 1 | + | + +----+-------+ + | 22 | +++++ | + | | +++ | + +----+-------+ + ''') + def test_obj2unicode(): table = Texttable() table.set_deco(Texttable.HEADER) @@ -196,3 +234,72 @@ | a | 1s | [3] | +-----+------------+---------+ ''') + +def test_cjkwarp(): + try: + import cjkwrap + table = Texttable() + + table.set_cols_align(["r", "l"]) + table.add_rows([ + ["Name", 'Discuz! 6.x/7.x 全局变量防御绕过导致命令执行'], + ["Description", '由于php5.3.x版本里php.ini的设置里request_order默认值为GP,导致Discuz! 6.x/7.x 全局变量防御绕过漏洞'], + ], header = False) + assert clean(table.draw()) == u_dedent('''\ + +-------------+----------------------------------------------------------------+ + | Name | Discuz! 6.x/7.x 全局变量防御绕过导致命令执行 | + +-------------+----------------------------------------------------------------+ + | Description | 由于php5.3.x版本里php.ini的设置里request_order默认值为GP,导致 | + | | Discuz! 6.x/7.x 全局变量防御绕过漏洞 | + +-------------+----------------------------------------------------------------+ + ''') + except ImportError: + True + +def test_chaining(): + table = Texttable() + table.reset() + table.set_max_width(50) + table.set_chars(list('-|+=')) + table.set_deco(Texttable.BORDER) + table.set_header_align(list('lll')) + table.set_cols_align(list('lll')) + table.set_cols_valign(list('mmm')) + table.set_cols_dtype(list('ttt')) + table.set_cols_width([3, 3, 3]) + table.set_precision(3) + table.header(list('abc')) + table.add_row(list('def')) + table.add_rows([list('ghi')], False) + s1 = table.draw() + s2 = (Texttable() + .reset() + .set_max_width(50) + .set_chars(list('-|+=')) + .set_deco(Texttable.BORDER) + .set_header_align(list('lll')) + .set_cols_align(list('lll')) + .set_cols_valign(list('mmm')) + .set_cols_dtype(list('ttt')) + .set_cols_width([3, 3, 3]) + .set_precision(3) + .header(list('abc')) + .add_row(list('def')) + .add_rows([list('ghi')], False) + .draw()) + assert s1 == s2 + +def test_nan(): + table = Texttable() + table.set_cols_align(["l"]) + table.add_rows([ + ["A NaN"], + ["NaN"], + ]) + assert clean(table.draw()) == u_dedent('''\ + +-------+ + | A NaN | + +=======+ + | NaN | + +-------+ + ''') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.egg-info/PKG-INFO new/texttable-1.6.2/texttable.egg-info/PKG-INFO --- old/texttable-1.1.1/texttable.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/texttable.egg-info/PKG-INFO 2019-07-01 11:47:18.000000000 +0200 @@ -0,0 +1,284 @@ +Metadata-Version: 2.1 +Name: texttable +Version: 1.6.2 +Summary: module for creating simple ASCII tables +Home-page: https://github.com/foutaise/texttable/ +Author: Gerome Fournier +Author-email: [email protected] +License: MIT +Download-URL: https://github.com/foutaise/texttable/archive/v1.6.2.tar.gz +Description: # texttable + + Python module for creating simple ASCII tables + + ## Availability + + This module is available on [PyPI](https://pypi.org/project/texttable/), and has been packaged for several Linux/Unix platforms + ([Debian](https://packages.debian.org/search?&searchon=names&keywords=python-texttable+), + [FreeBSD](https://www.freebsd.org/cgi/ports.cgi?query=texttable&stype=all), Fedora, Suse...). + + ## Dependencies + + If available, [cjkwrap](https://github.com/fgallaire/cjkwrap) library is used instead of textwrap, for a better wrapping of CJK text. + + If available, [wcwidth](https://github.com/jquast/wcwidth) library is used for a better rendering (basic emoji support). + + ## Documentation + + ``` + NAME + texttable - module for creating simple ASCII tables + + FILE + /usr/local/lib/python2.7/dist-packages/texttable.py + + DESCRIPTION + + Example: + + table = Texttable() + table.set_cols_align(["l", "r", "c"]) + table.set_cols_valign(["t", "m", "b"]) + table.add_rows([["Name", "Age", "Nickname"], + ["Mr\nXavier\nHuon", 32, "Xav'"], + ["Mr\nBaptiste\nClement", 1, "Baby"], + ["Mme\nLouise\nBourgeau", 28, "Lou\n\nLoue"]]) + print table.draw() + "\n" + + table = Texttable() + table.set_deco(Texttable.HEADER) + table.set_cols_dtype(['t', # text + 'f', # float (decimal) + 'e', # float (exponent) + 'i', # integer + 'a']) # automatic + table.set_cols_align(["l", "r", "r", "r", "l"]) + table.add_rows([["text", "float", "exp", "int", "auto"], + ["abcd", "67", 654, 89, 128.001], + ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023], + ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], + ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) + print table.draw() + + Result: + + +----------+-----+----------+ + | Name | Age | Nickname | + +==========+=====+==========+ + | Mr | | | + | Xavier | 32 | | + | Huon | | Xav' | + +----------+-----+----------+ + | Mr | | | + | Baptiste | 1 | | + | Clement | | Baby | + +----------+-----+----------+ + | Mme | | Lou | + | Louise | 28 | | + | Bourgeau | | Loue | + +----------+-----+----------+ + + text float exp int auto + ============================================== + abcd 67.000 6.540e+02 89 128.001 + efghijk 67.543 6.540e-01 90 1.280e+22 + lmn 0.000 5.000e-78 89 0.000 + opqrstu 0.023 5.000e+78 92 1.280e+22 + + CLASSES + class Texttable + | Methods defined here: + | + | __init__(self, max_width=80) + | Constructor + | + | - max_width is an integer, specifying the maximum width of the table + | - if set to 0, size is unlimited, therefore cells won't be wrapped + | + | add_row(self, array) + | Add a row in the rows stack + | + | - cells can contain newlines and tabs + | + | add_rows(self, rows, header=True) + | Add several rows in the rows stack + | + | - The 'rows' argument can be either an iterator returning arrays, + | or a by-dimensional array + | - 'header' specifies if the first row should be used as the header + | of the table + | + | draw(self) + | Draw the table + | + | - the table is returned as a whole string + | + | header(self, array) + | Specify the header of the table + | + | reset(self) + | Reset the instance + | + | - reset rows and header + | + | set_chars(self, array) + | Set the characters used to draw lines between rows and columns + | + | - the array should contain 4 fields: + | + | [horizontal, vertical, corner, header] + | + | - default is set to: + | + | ['-', '|', '+', '='] + | + | set_cols_align(self, array) + | Set the desired columns alignment + | + | - the elements of the array should be either "l", "c" or "r": + | + | * "l": column flushed left + | * "c": column centered + | * "r": column flushed right + | + | set_cols_dtype(self, array) + | Set the desired columns datatype for the cols. + | + | - the elements of the array should be either a callable or any of + | "a", "t", "f", "e" or "i": + | + | * "a": automatic (try to use the most appropriate datatype) + | * "t": treat as text + | * "f": treat as float in decimal format + | * "e": treat as float in exponential format + | * "i": treat as int + | * a callable: should return formatted string for any value given + | + | - by default, automatic datatyping is used for each column + | + | set_cols_valign(self, array) + | Set the desired columns vertical alignment + | + | - the elements of the array should be either "t", "m" or "b": + | + | * "t": column aligned on the top of the cell + | * "m": column aligned on the middle of the cell + | * "b": column aligned on the bottom of the cell + | + | set_cols_width(self, array) + | Set the desired columns width + | + | - the elements of the array should be integers, specifying the + | width of each column. For example: + | + | [10, 20, 5] + | + | set_deco(self, deco) + | Set the table decoration + | + | - 'deco' can be a combinaison of: + | + | Texttable.BORDER: Border around the table + | Texttable.HEADER: Horizontal line below the header + | Texttable.HLINES: Horizontal lines between rows + | Texttable.VLINES: Vertical lines between columns + | + | All of them are enabled by default + | + | - example: + | + | Texttable.BORDER | Texttable.HEADER + | + | set_header_align(self, array) + | Set the desired header alignment + | + | - the elements of the array should be either "l", "c" or "r": + | + | * "l": column flushed left + | * "c": column centered + | * "r": column flushed right + | + | set_max_width(self, max_width) + | Set the maximum width of the table + | + | - max_width is an integer, specifying the maximum width of the table + | - if set to 0, size is unlimited, therefore cells won't be wrapped + | + | set_precision(self, width) + | Set the desired precision for float/exponential formats + | + | - width must be an integer >= 0 + | + | - default value is set to 3 + | + | ---------------------------------------------------------------------- + | Data and other attributes defined here: + | + | BORDER = 1 + | + | HEADER = 2 + | + | HLINES = 4 + | + | VLINES = 8 + + DATA + __all__ = ['Texttable', 'ArraySizeError'] + __author__ = 'Gerome Fournier <jef(at)foutaise.org>' + __credits__ = 'Jeff Kowalczyk:\n - textwrap improved import\n ...at... + __license__ = 'MIT' + __version__ = '1.6.2' + + VERSION + 1.6.2 + + AUTHOR + Gerome Fournier <jef(at)foutaise.org> + + CREDITS + Jeff Kowalczyk: + - textwrap improved import + - comment concerning header output + + Anonymous: + - add_rows method, for adding rows in one go + + Sergey Simonenko: + - redefined len() function to deal with non-ASCII characters + + Roger Lew: + - columns datatype specifications + + Brian Peterson: + - better handling of unicode errors + + Frank Sachsenheim: + - add Python 2/3-compatibility + + Maximilian Hils: + - fix minor bug for Python 3 compatibility + + frinkelpi: + - preserve empty lines + ``` + +Platform: any +Classifier: Development Status :: 5 - Production/Stable +Classifier: Environment :: Console +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: End Users/Desktop +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: Microsoft :: Windows +Classifier: Operating System :: POSIX +Classifier: Operating System :: MacOS +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Topic :: Text Processing +Classifier: Topic :: Utilities +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Description-Content-Type: text/markdown diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.egg-info/SOURCES.txt new/texttable-1.6.2/texttable.egg-info/SOURCES.txt --- old/texttable-1.1.1/texttable.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/texttable.egg-info/SOURCES.txt 2019-07-01 11:47:18.000000000 +0200 @@ -0,0 +1,14 @@ +.coveragerc +CHANGELOG.md +LICENSE +MANIFEST.in +README.md +setup.py +tests.py +texttable.py +texttable.pyi +tox.ini +texttable.egg-info/PKG-INFO +texttable.egg-info/SOURCES.txt +texttable.egg-info/dependency_links.txt +texttable.egg-info/top_level.txt \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.egg-info/dependency_links.txt new/texttable-1.6.2/texttable.egg-info/dependency_links.txt --- old/texttable-1.1.1/texttable.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/texttable.egg-info/dependency_links.txt 2019-07-01 11:47:18.000000000 +0200 @@ -0,0 +1 @@ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.egg-info/top_level.txt new/texttable-1.6.2/texttable.egg-info/top_level.txt --- old/texttable-1.1.1/texttable.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/texttable.egg-info/top_level.txt 2019-07-01 11:47:18.000000000 +0200 @@ -0,0 +1 @@ +texttable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.py new/texttable-1.6.2/texttable.py --- old/texttable-1.1.1/texttable.py 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/texttable.py 2019-07-01 11:40:33.000000000 +0200 @@ -1,19 +1,5 @@ # texttable - module for creating simple ASCII tables -# Copyright (C) 2003-2015 Gerome Fournier <jef(at)foutaise.org> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# Copyright (C) 2003-2019 Gerome Fournier <jef(at)foutaise.org> """module for creating simple ASCII tables @@ -75,8 +61,8 @@ __all__ = ["Texttable", "ArraySizeError"] __author__ = 'Gerome Fournier <jef(at)foutaise.org>' -__license__ = 'LGPL' -__version__ = '1.1.1' +__license__ = 'MIT' +__version__ = '1.6.2' __credits__ = """\ Jeff Kowalczyk: - textwrap improved import @@ -105,22 +91,46 @@ """ import sys -import string import unicodedata +# define a text wrapping function to wrap some text +# to a specific width: +# - use cjkwrap if available (better CJK support) +# - fallback to textwrap otherwise try: - if sys.version_info >= (2, 3): + import cjkwrap + def textwrapper(txt, width): + return cjkwrap.wrap(txt, width) +except ImportError: + try: import textwrap - elif sys.version_info >= (2, 2): - from optparse import textwrap - else: - from optik import textwrap + def textwrapper(txt, width): + return textwrap.wrap(txt, width) + except ImportError: + sys.stderr.write("Can't import textwrap module!\n") + raise + +# define a function to calculate the rendering width of a unicode character +# - use wcwidth if available +# - fallback to unicodedata information otherwise +try: + import wcwidth + def uchar_width(c): + """Return the rendering width of a unicode character + """ + return max(0, wcwidth.wcwidth(c)) except ImportError: - sys.stderr.write("Can't import textwrap module!\n") - raise + def uchar_width(c): + """Return the rendering width of a unicode character + """ + if unicodedata.east_asian_width(c) in 'WF': + return 2 + elif unicodedata.combining(c): + return 0 + else: + return 1 -if sys.version_info >= (2, 7): - from functools import reduce +from functools import reduce if sys.version_info >= (3, 0): unicode_type = str @@ -149,12 +159,7 @@ """Redefining len here so it will be able to work with non-ASCII characters """ if isinstance(iterable, bytes_type) or isinstance(iterable, unicode_type): - unicode_data = obj2unicode(iterable) - if hasattr(unicodedata, 'east_asian_width'): - w = unicodedata.east_asian_width - return sum([w(c) in 'WF' and 2 or (0 if unicodedata.combining(c) else 1) for c in unicode_data]) - else: - return unicode_data.__len__() + return sum([uchar_width(c) for c in obj2unicode(iterable)]) else: return iterable.__len__() @@ -190,9 +195,7 @@ - if set to 0, size is unlimited, therefore cells won't be wrapped """ - if max_width <= 0: - max_width = False - self._max_width = max_width + self.set_max_width(max_width) self._precision = 3 self._deco = Texttable.VLINES | Texttable.HLINES | Texttable.BORDER | \ @@ -210,6 +213,16 @@ self._row_size = None self._header = [] self._rows = [] + return self + + def set_max_width(self, max_width): + """Set the maximum width of the table + + - max_width is an integer, specifying the maximum width of the table + - if set to 0, size is unlimited, therefore cells won't be wrapped + """ + self._max_width = max_width if max_width > 0 else False + return self def set_chars(self, array): """Set the characters used to draw lines between rows and columns @@ -228,6 +241,7 @@ array = [ x[:1] for x in [ str(s) for s in array ] ] (self._char_horiz, self._char_vert, self._char_corner, self._char_header) = array + return self def set_deco(self, deco): """Set the table decoration @@ -247,6 +261,21 @@ """ self._deco = deco + return self + + def set_header_align(self, array): + """Set the desired header alignment + + - the elements of the array should be either "l", "c" or "r": + + * "l": column flushed left + * "c": column centered + * "r": column flushed right + """ + + self._check_row_size(array) + self._header_align = array + return self def set_cols_align(self, array): """Set the desired columns alignment @@ -260,6 +289,7 @@ self._check_row_size(array) self._align = array + return self def set_cols_valign(self, array): """Set the desired columns vertical alignment @@ -273,6 +303,7 @@ self._check_row_size(array) self._valign = array + return self def set_cols_dtype(self, array): """Set the desired columns datatype for the cols. @@ -292,6 +323,7 @@ self._check_row_size(array) self._dtype = array + return self def set_cols_width(self, array): """Set the desired columns width @@ -311,6 +343,7 @@ sys.stderr.write("Wrong argument in column width specification\n") raise self._width = array + return self def set_precision(self, width): """Set the desired precision for float/exponential formats @@ -323,6 +356,7 @@ if not type(width) is int or width < 0: raise ValueError('width must be an integer greater then 0') self._precision = width + return self def header(self, array): """Specify the header of the table @@ -330,6 +364,7 @@ self._check_row_size(array) self._header = list(map(obj2unicode, array)) + return self def add_row(self, array): """Add a row in the rows stack @@ -346,6 +381,7 @@ for i, x in enumerate(array): cells.append(self._str(i, x)) self._rows.append(cells) + return self def add_rows(self, rows, header=True): """Add several rows in the rows stack @@ -366,6 +402,7 @@ rows = rows[1:] for row in rows: self.add_row(row) + return self def draw(self): """Draw the table @@ -446,11 +483,12 @@ f = cls._to_float(x) if abs(f) > 1e8: fn = cls._fmt_exp + elif f != f: # NaN + fn = cls._fmt_text + elif f - round(f) == 0: + fn = cls._fmt_int else: - if f - round(f) == 0: - fn = cls._fmt_int - else: - fn = cls._fmt_float + fn = cls._fmt_float return fn(x, **kw) def _str(self, i, x): @@ -608,6 +646,8 @@ """Check if alignment has been specified, set default one if not """ + if not hasattr(self, "_header_align"): + self._header_align = ["c"] * self._row_size if not hasattr(self, "_align"): self._align = ["l"] * self._row_size if not hasattr(self, "_valign"): @@ -631,7 +671,7 @@ cell_line = cell[i] fill = width - len(cell_line) if isheader: - align = "c" + align = self._header_align[length - 1] if align == "r": out += fill * space + cell_line elif align == "c": @@ -658,7 +698,7 @@ if c.strip() == "": array.append("") else: - array.extend(textwrap.wrap(c, width)) + array.extend(textwrapper(c, width)) line_wrapped.append(array) max_cell_lines = reduce(max, list(map(len, line_wrapped))) for cell, valign in zip(line_wrapped, self._valign): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/texttable.pyi new/texttable-1.6.2/texttable.pyi --- old/texttable-1.1.1/texttable.pyi 1970-01-01 01:00:00.000000000 +0100 +++ new/texttable-1.6.2/texttable.pyi 2019-02-15 07:13:58.000000000 +0100 @@ -0,0 +1,38 @@ +from typing import * + +class Texttable: + + BORDER: int + HEADER: int + HLINES: int + VLINES: int + + def __init__(self, max_width: int = ...) -> None: ... + + def reset(self) -> 'Texttable': ... + + def set_max_width(self, max_width: int) -> 'Texttable': ... + + def set_chars(self, array: List[str]) -> 'Texttable': ... + + def set_deco(self, deco: int) -> 'Texttable': ... + + def set_header_align(self, array: List[str]) -> 'Texttable': ... + + def set_cols_align(self, array: List[str]) -> 'Texttable': ... + + def set_cols_valign(self, array: List[str]) -> 'Texttable': ... + + def set_cols_dtype(self, array: List[Union[str, Callable[[Any], str]]]) -> 'Texttable': ... + + def set_cols_width(self, array: List[int]) -> 'Texttable': ... + + def set_precision(self, width: int) -> 'Texttable': ... + + def header(self, array: List[str]) -> 'Texttable': ... + + def add_row(self, array: List[Union[Union[int, str], float]]) -> 'Texttable': ... + + def add_rows(self, rows: List[object], header: bool = ...) -> 'Texttable': ... + + def draw(self) -> str: ... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/texttable-1.1.1/tox.ini new/texttable-1.6.2/tox.ini --- old/texttable-1.1.1/tox.ini 2017-10-26 14:23:51.000000000 +0200 +++ new/texttable-1.6.2/tox.ini 2019-02-15 07:13:58.000000000 +0100 @@ -1,8 +1,9 @@ [tox] -envlist = py27,py35,py36 +envlist = py27,py35,py36,py37 [testenv] deps = pytest pytest-cov -commands = py.test --cov-report=term-missing --cov=texttable tests.py + cjkwrap +commands = pytest --cov-report=term-missing --cov=texttable tests.py
