Hello community, here is the log from the commit of package python-cli-helpers for openSUSE:Factory checked in at 2019-06-13 23:01:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-cli-helpers (Old) and /work/SRC/openSUSE:Factory/.python-cli-helpers.new.4811 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-cli-helpers" Thu Jun 13 23:01:26 2019 rev:2 rq:707625 version:1.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-cli-helpers/python-cli-helpers.changes 2019-02-26 22:18:57.734138774 +0100 +++ /work/SRC/openSUSE:Factory/.python-cli-helpers.new.4811/python-cli-helpers.changes 2019-06-13 23:01:33.587508774 +0200 @@ -1,0 +2,13 @@ +Tue May 28 10:47:19 UTC 2019 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 1.2.0: + * Run tests on Python 3.7. + * Use twine check during packaging tests. + * Rename old tsv format to csv-tab (because it add quotes), introduce new tsv output adapter. + * Truncate long fields for tabular display. + * Return the supported table formats as unicode. + * Override tab with 4 spaces for terminal tables. +- Add patch to fix build with new pygments: + * pygments.patch + +------------------------------------------------------------------- Old: ---- cli_helpers-1.1.0.tar.gz New: ---- cli_helpers-1.2.0.tar.gz pygments.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-cli-helpers.spec ++++++ --- /var/tmp/diff_new_pack.MP4qNr/_old 2019-06-13 23:01:34.059508064 +0200 +++ /var/tmp/diff_new_pack.MP4qNr/_new 2019-06-13 23:01:34.063508058 +0200 @@ -18,21 +18,29 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-cli-helpers -Version: 1.1.0 +Version: 1.2.0 Release: 0 Summary: Helpers for building command-line apps License: BSD-3-Clause Group: Development/Languages/Python -Url: https://github.com/dbcli/cli_helpers -Source: https://files.pythonhosted.org/packages/source/c/cli-helpers/cli_helpers-%{version}.tar.gz +URL: https://github.com/dbcli/cli_helpers +Source: https://files.pythonhosted.org/packages/source/c/cli_helpers/cli_helpers-%{version}.tar.gz +Patch0: pygments.patch BuildRequires: %{python_module setuptools} +BuildRequires: fdupes BuildRequires: python-rpm-macros +Requires: python-Pygments >= 2.4 +Requires: python-configobj >= 5.0.5 +Requires: python-tabulate >= 0.8.2 +Requires: python-terminaltables >= 3.0.0 +Requires: python-wcwidth +BuildArch: noarch # SECTION test requirements -BuildRequires: %{python_module mock >= 2.0.0} -BuildRequires: %{python_module pytest >= 3.0.7} # Package dependencies -BuildRequires: %{python_module Pygments >= 1.6} +BuildRequires: %{python_module Pygments >= 2.4} BuildRequires: %{python_module configobj >= 5.0.5} +BuildRequires: %{python_module mock >= 2.0.0} +BuildRequires: %{python_module pytest >= 3.0.7} BuildRequires: %{python_module tabulate >= 0.8.2} BuildRequires: %{python_module terminaltables >= 3.0.0} BuildRequires: %{python_module wcwidth} @@ -40,17 +48,9 @@ BuildRequires: python2-backports.csv >= 1.0.0 %endif # /SECTION -BuildRequires: fdupes -BuildArch: noarch -Requires: python-Pygments >= 1.6 -Requires: python-configobj >= 5.0.5 -Requires: python-tabulate >= 0.8.2 -Requires: python-terminaltables >= 3.0.0 -Requires: python-wcwidth %ifpython2 Requires: python2-backports.csv >= 1.0.0 %endif - %python_subpackages %description @@ -68,6 +68,7 @@ %prep %setup -q -n cli_helpers-%{version} +%patch0 -p1 %build %python_build @@ -77,7 +78,7 @@ %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_exec -m pytest +%pytest %files %{python_files} %license LICENSE ++++++ cli_helpers-1.1.0.tar.gz -> cli_helpers-1.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/AUTHORS new/cli_helpers-1.2.0/AUTHORS --- old/cli_helpers-1.1.0/AUTHORS 2018-10-16 02:56:50.000000000 +0200 +++ new/cli_helpers-1.2.0/AUTHORS 2019-04-06 01:49:19.000000000 +0200 @@ -16,6 +16,7 @@ - Terje Røsten - Frederic Aoustin +- Zhaolong Zhu Thanks diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/CHANGELOG new/cli_helpers-1.2.0/CHANGELOG --- old/cli_helpers-1.1.0/CHANGELOG 2018-10-18 13:59:50.000000000 +0200 +++ new/cli_helpers-1.2.0/CHANGELOG 2019-04-06 01:54:13.000000000 +0200 @@ -1,6 +1,18 @@ Changelog ========= +Version 1.2.0 +------------- + +(released on 2019-04-05) + +* Run tests on Python 3.7. +* Use twine check during packaging tests. +* Rename old tsv format to csv-tab (because it add quotes), introduce new tsv output adapter. +* Truncate long fields for tabular display. +* Return the supported table formats as unicode. +* Override tab with 4 spaces for terminal tables. + Version 1.1.0 ------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/PKG-INFO new/cli_helpers-1.2.0/PKG-INFO --- old/cli_helpers-1.1.0/PKG-INFO 2018-10-18 14:03:55.000000000 +0200 +++ new/cli_helpers-1.2.0/PKG-INFO 2019-04-06 02:01:19.000000000 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: cli_helpers -Version: 1.1.0 +Version: 1.2.0 Summary: Helpers for building command-line apps Home-page: https://github.com/dbcli/cli_helpers Author: dbcli Author-email: tho...@roten.us License: UNKNOWN -Description-Content-Type: UNKNOWN Description: =========== CLI Helpers =========== @@ -56,6 +55,9 @@ Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Terminals :: Terminal Emulators/X Terminals +Description-Content-Type: text/x-rst +Provides-Extra: styles diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/__init__.py new/cli_helpers-1.2.0/cli_helpers/__init__.py --- old/cli_helpers-1.1.0/cli_helpers/__init__.py 2018-10-18 14:00:30.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/__init__.py 2019-04-06 01:54:37.000000000 +0200 @@ -1 +1 @@ -__version__ = '1.1.0' +__version__ = '1.2.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/delimited_output_adapter.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/delimited_output_adapter.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/delimited_output_adapter.py 2018-05-27 22:03:52.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/delimited_output_adapter.py 2018-12-02 01:49:53.000000000 +0100 @@ -8,7 +8,7 @@ from cli_helpers.utils import filter_dict_by_key from .preprocessors import bytes_to_string, override_missing_value -supported_formats = ('csv', 'tsv') +supported_formats = ('csv', 'csv-tab') preprocessors = (override_missing_value, bytes_to_string) @@ -29,7 +29,7 @@ 'quotechar', 'quoting', 'skipinitialspace', 'strict') if table_format == 'csv': delimiter = ',' - elif table_format == 'tsv': + elif table_format == 'csv-tab': delimiter = '\t' else: raise ValueError('Invalid table_format specified.') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/output_formatter.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/output_formatter.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/output_formatter.py 2018-10-16 02:56:50.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/output_formatter.py 2019-03-26 17:06:31.000000000 +0100 @@ -8,12 +8,13 @@ zip_longest) from cli_helpers.utils import unique_items from . import (delimited_output_adapter, vertical_table_adapter, - tabulate_adapter, terminaltables_adapter) + tabulate_adapter, terminaltables_adapter, tsv_output_adapter) from decimal import Decimal import itertools MISSING_VALUE = '<null>' +MAX_FIELD_WIDTH = 500 TYPES = { type(None): 0, @@ -198,24 +199,30 @@ TabularOutputFormatter.register_new_formatter( vertical_format, vertical_table_adapter.adapter, vertical_table_adapter.preprocessors, - {'table_format': vertical_format, 'missing_value': MISSING_VALUE}) + {'table_format': vertical_format, 'missing_value': MISSING_VALUE, 'max_field_width': None}) for delimited_format in delimited_output_adapter.supported_formats: TabularOutputFormatter.register_new_formatter( delimited_format, delimited_output_adapter.adapter, delimited_output_adapter.preprocessors, - {'table_format': delimited_format, 'missing_value': ''}) + {'table_format': delimited_format, 'missing_value': '', 'max_field_width': None}) for tabulate_format in tabulate_adapter.supported_formats: TabularOutputFormatter.register_new_formatter( tabulate_format, tabulate_adapter.adapter, tabulate_adapter.preprocessors + (tabulate_adapter.style_output_table(tabulate_format),), - {'table_format': tabulate_format, 'missing_value': MISSING_VALUE}) + {'table_format': tabulate_format, 'missing_value': MISSING_VALUE, 'max_field_width': MAX_FIELD_WIDTH}) for terminaltables_format in terminaltables_adapter.supported_formats: TabularOutputFormatter.register_new_formatter( terminaltables_format, terminaltables_adapter.adapter, terminaltables_adapter.preprocessors + (terminaltables_adapter.style_output_table(terminaltables_format),), - {'table_format': terminaltables_format, 'missing_value': MISSING_VALUE}) + {'table_format': terminaltables_format, 'missing_value': MISSING_VALUE, 'max_field_width': MAX_FIELD_WIDTH}) + +for tsv_format in tsv_output_adapter.supported_formats: + TabularOutputFormatter.register_new_formatter( + tsv_format, tsv_output_adapter.adapter, + tsv_output_adapter.preprocessors, + {'table_format': tsv_format, 'missing_value': '', 'max_field_width': None}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/preprocessors.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/preprocessors.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/preprocessors.py 2018-02-10 23:20:18.000000000 +0100 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/preprocessors.py 2019-04-06 01:49:19.000000000 +0200 @@ -8,6 +8,22 @@ HAS_PYGMENTS, Terminal256Formatter, StringIO) +def truncate_string(data, headers, max_field_width=None, **_): + """Truncate very long strings. Only needed for tabular + representation, because trying to tabulate very long data + is problematic in terms of performance, and does not make any + sense visually. + + :param iterable data: An :term:`iterable` (e.g. list) of rows. + :param iterable headers: The column headers. + :param int max_field_width: Width to truncate field for display + :return: The processed data and headers. + :rtype: tuple + """ + return (([utils.truncate_string(v, max_field_width) for v in row] for row in data), + [utils.truncate_string(h, max_field_width) for h in headers]) + + def convert_to_string(data, headers, **_): """Convert all *data* and *headers* to strings. @@ -40,6 +56,21 @@ headers) +def override_tab_value(data, headers, new_value=' ', **_): + """Override tab values in the *data* with *new_value*. + + :param iterable data: An :term:`iterable` (e.g. list) of rows. + :param iterable headers: The column headers. + :param new_value: The new value to use for tab. + :return: The processed data and headers. + :rtype: tuple + + """ + return (([v.replace('\t', new_value) if isinstance(v, text_type) else v + for v in row] for row in data), + headers) + + def bytes_to_string(data, headers, **_): """Convert all *data* and *headers* bytes to strings. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/tabulate_adapter.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/tabulate_adapter.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/tabulate_adapter.py 2018-10-16 02:56:50.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/tabulate_adapter.py 2019-03-26 17:06:31.000000000 +0100 @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- """Format adapter for the tabulate module.""" +from __future__ import unicode_literals + from cli_helpers.utils import filter_dict_by_key -from .preprocessors import (convert_to_string, override_missing_value, +from .preprocessors import (convert_to_string, truncate_string, override_missing_value, style_output, HAS_PYGMENTS, Terminal256Formatter, StringIO) import tabulate @@ -13,7 +15,7 @@ 'orgtbl', 'psql', 'rst') supported_formats = supported_markup_formats + supported_table_formats -preprocessors = (override_missing_value, convert_to_string, style_output) +preprocessors = (override_missing_value, convert_to_string, truncate_string, style_output) def style_output_table(format_name=""): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/terminaltables_adapter.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/terminaltables_adapter.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/terminaltables_adapter.py 2018-10-16 02:56:50.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/terminaltables_adapter.py 2019-04-06 01:49:19.000000000 +0200 @@ -1,15 +1,21 @@ # -*- coding: utf-8 -*- """Format adapter for the terminaltables module.""" +from __future__ import unicode_literals + import terminaltables import itertools from cli_helpers.utils import filter_dict_by_key -from .preprocessors import (convert_to_string, override_missing_value, - style_output, HAS_PYGMENTS, Terminal256Formatter, StringIO) +from .preprocessors import (convert_to_string, truncate_string, override_missing_value, + style_output, HAS_PYGMENTS, Terminal256Formatter, StringIO, + override_tab_value) supported_formats = ('ascii', 'double', 'github') -preprocessors = (override_missing_value, convert_to_string, style_output) +preprocessors = ( + override_missing_value, convert_to_string, override_tab_value, + truncate_string, style_output +) table_format_handler = { 'ascii': terminaltables.AsciiTable, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/tabular_output/tsv_output_adapter.py new/cli_helpers-1.2.0/cli_helpers/tabular_output/tsv_output_adapter.py --- old/cli_helpers-1.1.0/cli_helpers/tabular_output/tsv_output_adapter.py 1970-01-01 01:00:00.000000000 +0100 +++ new/cli_helpers-1.2.0/cli_helpers/tabular_output/tsv_output_adapter.py 2018-12-02 01:49:53.000000000 +0100 @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +"""A tsv data output adapter""" + +from __future__ import unicode_literals + +from .preprocessors import bytes_to_string, override_missing_value, convert_to_string +from itertools import chain +from cli_helpers.utils import replace + +supported_formats = ('tsv',) +preprocessors = (override_missing_value, bytes_to_string, convert_to_string) + +def adapter(data, headers, **kwargs): + """Wrap the formatting inside a function for TabularOutputFormatter.""" + for row in chain((headers,), data): + yield "\t".join((replace(r, (('\n', r'\n'), ('\t', r'\t'))) for r in row)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers/utils.py new/cli_helpers-1.2.0/cli_helpers/utils.py --- old/cli_helpers-1.1.0/cli_helpers/utils.py 2018-05-28 20:41:45.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers/utils.py 2019-03-26 17:06:31.000000000 +0100 @@ -29,6 +29,13 @@ return text_type(value) +def truncate_string(value, max_width=None): + """Truncate string values.""" + if isinstance(value, text_type) and max_width is not None and len(value) > max_width: + return value[:max_width] + return value + + def intlen(n): """Find the length of the integer part of a number *n*.""" pos = n.find('.') @@ -48,6 +55,14 @@ _ansi_re = re.compile('\033\[((?:\d|;)*)([a-zA-Z])') + def strip_ansi(value): """Strip the ANSI escape sequences from a string.""" return _ansi_re.sub('', value) + + +def replace(s, replace): + """Replace multiple values in a string""" + for r in replace: + s = s.replace(*r) + return s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers.egg-info/PKG-INFO new/cli_helpers-1.2.0/cli_helpers.egg-info/PKG-INFO --- old/cli_helpers-1.1.0/cli_helpers.egg-info/PKG-INFO 2018-10-18 14:03:55.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers.egg-info/PKG-INFO 2019-04-06 02:01:19.000000000 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: cli-helpers -Version: 1.1.0 +Version: 1.2.0 Summary: Helpers for building command-line apps Home-page: https://github.com/dbcli/cli_helpers Author: dbcli Author-email: tho...@roten.us License: UNKNOWN -Description-Content-Type: UNKNOWN Description: =========== CLI Helpers =========== @@ -56,6 +55,9 @@ Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Terminals :: Terminal Emulators/X Terminals +Description-Content-Type: text/x-rst +Provides-Extra: styles diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/cli_helpers.egg-info/SOURCES.txt new/cli_helpers-1.2.0/cli_helpers.egg-info/SOURCES.txt --- old/cli_helpers-1.1.0/cli_helpers.egg-info/SOURCES.txt 2018-10-18 14:03:55.000000000 +0200 +++ new/cli_helpers-1.2.0/cli_helpers.egg-info/SOURCES.txt 2019-04-06 02:01:19.000000000 +0200 @@ -24,6 +24,7 @@ cli_helpers/tabular_output/preprocessors.py cli_helpers/tabular_output/tabulate_adapter.py cli_helpers/tabular_output/terminaltables_adapter.py +cli_helpers/tabular_output/tsv_output_adapter.py cli_helpers/tabular_output/vertical_table_adapter.py docs/Makefile docs/source/api.rst @@ -50,4 +51,5 @@ tests/tabular_output/test_preprocessors.py tests/tabular_output/test_tabulate_adapter.py tests/tabular_output/test_terminaltables_adapter.py +tests/tabular_output/test_tsv_output_adapter.py tests/tabular_output/test_vertical_table_adapter.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/requirements-dev.txt new/cli_helpers-1.2.0/requirements-dev.txt --- old/cli_helpers-1.1.0/requirements-dev.txt 2018-10-18 13:37:58.000000000 +0200 +++ new/cli_helpers-1.2.0/requirements-dev.txt 2018-12-02 01:49:53.000000000 +0100 @@ -7,4 +7,4 @@ pytest-cov==2.4.0 Sphinx==1.5.5 tox==2.7.0 -twine==1.8.1 +twine==1.12.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/setup.py new/cli_helpers-1.2.0/setup.py --- old/cli_helpers-1.1.0/setup.py 2018-10-18 13:58:30.000000000 +0200 +++ new/cli_helpers-1.2.0/setup.py 2018-12-02 01:49:53.000000000 +0100 @@ -24,7 +24,7 @@ readme = open_file('README.rst') if sys.version_info[0] == 2: - py2_reqs = [ 'backports.csv >= 1.0.0', ] + py2_reqs = ['backports.csv >= 1.0.0'] else: py2_reqs = [] @@ -38,6 +38,7 @@ include_package_data=True, description='Helpers for building command-line apps', long_description=readme, + long_description_content_type='text/x-rst', install_requires=[ 'configobj >= 5.0.5', 'tabulate[widechars] >= 0.8.2', @@ -56,6 +57,7 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Software Development', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Terminals :: Terminal Emulators/X Terminals', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/tests/tabular_output/test_delimited_output_adapter.py new/cli_helpers-1.2.0/tests/tabular_output/test_delimited_output_adapter.py --- old/cli_helpers-1.1.0/tests/tabular_output/test_delimited_output_adapter.py 2018-05-27 22:03:52.000000000 +0200 +++ new/cli_helpers-1.2.0/tests/tabular_output/test_delimited_output_adapter.py 2018-12-02 01:49:53.000000000 +0100 @@ -14,21 +14,21 @@ # Test comma-delimited output. data = [['abc', '1'], ['d', '456']] headers = ['letters', 'number'] - output = delimited_output_adapter.adapter(iter(data), headers) + output = delimited_output_adapter.adapter(iter(data), headers, dialect='unix') assert "\n".join(output) == dedent('''\ - letters,number\n\ - abc,1\n\ - d,456''') + "letters","number"\n\ + "abc","1"\n\ + "d","456"''') # Test tab-delimited output. data = [['abc', '1'], ['d', '456']] headers = ['letters', 'number'] output = delimited_output_adapter.adapter( - iter(data), headers, table_format='tsv') + iter(data), headers, table_format='csv-tab', dialect='unix') assert "\n".join(output) == dedent('''\ - letters\tnumber\n\ - abc\t1\n\ - d\t456''') + "letters"\t"number"\n\ + "abc"\t"1"\n\ + "d"\t"456"''') with pytest.raises(ValueError): output = delimited_output_adapter.adapter( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/tests/tabular_output/test_preprocessors.py new/cli_helpers-1.2.0/tests/tabular_output/test_preprocessors.py --- old/cli_helpers-1.1.0/tests/tabular_output/test_preprocessors.py 2018-05-28 20:51:27.000000000 +0200 +++ new/cli_helpers-1.2.0/tests/tabular_output/test_preprocessors.py 2019-04-06 01:49:19.000000000 +0200 @@ -9,7 +9,7 @@ from cli_helpers.compat import HAS_PYGMENTS from cli_helpers.tabular_output.preprocessors import ( align_decimals, bytes_to_string, convert_to_string, quote_whitespaces, - override_missing_value, style_output, format_numbers) + override_missing_value, override_tab_value, style_output, format_numbers) if HAS_PYGMENTS: from pygments.style import Style @@ -39,6 +39,17 @@ assert expected == (list(results[0]), results[1]) + +def test_override_tab_value(): + """Test the override_tab_value() function.""" + data = [[1, '\tJohn'], [2, 'Jill']] + headers = ['id', 'name'] + expected = ([[1, ' John'], [2, 'Jill']], ['id', 'name']) + results = override_tab_value(data, headers) + + assert expected == (list(results[0]), results[1]) + + def test_bytes_to_string(): """Test the bytes_to_string() function.""" data = [[1, 'John'], [2, b'Jill']] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/tests/tabular_output/test_tsv_output_adapter.py new/cli_helpers-1.2.0/tests/tabular_output/test_tsv_output_adapter.py --- old/cli_helpers-1.1.0/tests/tabular_output/test_tsv_output_adapter.py 1970-01-01 01:00:00.000000000 +0100 +++ new/cli_helpers-1.2.0/tests/tabular_output/test_tsv_output_adapter.py 2018-12-02 01:49:53.000000000 +0100 @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +"""Test the tsv delimited output adapter.""" + +from __future__ import unicode_literals +from textwrap import dedent + +import pytest + +from cli_helpers.tabular_output import tsv_output_adapter + + +def test_tsv_wrapper(): + """Test the tsv output adapter.""" + # Test tab-delimited output. + data = [['ab\r\nc', '1'], ['d', '456']] + headers = ['letters', 'number'] + output = tsv_output_adapter.adapter( + iter(data), headers, table_format='tsv') + assert "\n".join(output) == dedent('''\ + letters\tnumber\n\ + ab\r\\nc\t1\n\ + d\t456''') + + +def test_unicode_with_tsv(): + """Test that the tsv wrapper can handle non-ascii characters.""" + data = [['观音', '1'], ['Ποσειδῶν', '456']] + headers = ['letters', 'number'] + output = tsv_output_adapter.adapter(data, headers) + assert "\n".join(output) == dedent('''\ + letters\tnumber\n\ + 观音\t1\n\ + Ποσειδῶν\t456''') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/tests/test_utils.py new/cli_helpers-1.2.0/tests/test_utils.py --- old/cli_helpers-1.1.0/tests/test_utils.py 2018-05-28 20:41:45.000000000 +0200 +++ new/cli_helpers-1.2.0/tests/test_utils.py 2019-03-26 17:06:31.000000000 +0100 @@ -33,6 +33,12 @@ assert utils.to_string(2.29) == '2.29' +def test_truncate_string(): + """Test string truncate preprocessor.""" + val = 'x' * 1000 + assert utils.truncate_string(val, 10) == 'x' * 10 + + def test_intlen_with_decimal(): """Test that intlen() counts correctly with a decimal place.""" assert utils.intlen('11.1') == 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-1.1.0/tox.ini new/cli_helpers-1.2.0/tox.ini --- old/cli_helpers-1.1.0/tox.ini 2018-10-18 13:58:30.000000000 +0200 +++ new/cli_helpers-1.2.0/tox.ini 2018-12-02 01:49:53.000000000 +0100 @@ -1,5 +1,5 @@ [tox] -envlist = cov-init, py27, py34, py35, py36, noextras, docs, packaging, cov-report +envlist = cov-init, py27, py34, py35, py36, py37, noextras, docs, packaging, cov-report [testenv] passenv = CI TRAVIS TRAVIS_* CODECOV @@ -34,10 +34,13 @@ [testenv:packaging] deps = check-manifest - readme_renderer + readme_renderer[md] + -r{toxinidir}/requirements-dev.txt commands = check-manifest - ./setup.py check -m -r -s + ./setup.py sdist + twine check dist/* + ./setup.py check -m -s [testenv:cov-init] setenv = ++++++ pygments.patch ++++++ >From 19a0e9def85b6a8f066594ae25204338c28eeb04 Mon Sep 17 00:00:00 2001 From: Thomas Roten <tho...@roten.us> Date: Sat, 25 May 2019 15:23:32 -0500 Subject: [PATCH] Fix use of bold in Pygments tests. --- tests/tabular_output/test_preprocessors.py | 6 +-- tests/tabular_output/test_tabulate_adapter.py | 42 +++++++++---------- .../test_terminaltables_adapter.py | 42 +++++++++---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/tabular_output/test_preprocessors.py b/tests/tabular_output/test_preprocessors.py index d79b744..44fc652 100644 --- a/tests/tabular_output/test_preprocessors.py +++ b/tests/tabular_output/test_preprocessors.py @@ -161,7 +161,7 @@ class CliStyle(Style): headers = ['h1', 'h2'] data = [['观音', '2'], ['Ποσειδῶν', 'b']] - expected_headers = ['\x1b[31;01mh1\x1b[39;00m', '\x1b[31;01mh2\x1b[39;00m'] + expected_headers = ['\x1b[91;01mh1\x1b[39;00m', '\x1b[91;01mh2\x1b[39;00m'] expected_data = [['\x1b[38;5;233;48;5;7m观音\x1b[39;49m', '\x1b[38;5;233;48;5;7m2\x1b[39;49m'], ['\x1b[38;5;10mΠοσειδῶν\x1b[39m', '\x1b[38;5;10mb\x1b[39m']] @@ -183,7 +183,7 @@ class CliStyle(Style): headers = ['h1', 'h2'] data = [['观音\nLine2', 'Ποσειδῶν']] - expected_headers = ['\x1b[31;01mh1\x1b[39;00m', '\x1b[31;01mh2\x1b[39;00m'] + expected_headers = ['\x1b[91;01mh1\x1b[39;00m', '\x1b[91;01mh2\x1b[39;00m'] expected_data = [ ['\x1b[38;5;233;48;5;7m观音\x1b[39;49m\n\x1b[38;5;233;48;5;7m' 'Line2\x1b[39;49m', @@ -207,7 +207,7 @@ class CliStyle(Style): headers = ['h1', 'h2'] data = [['1', '2'], ['a', 'b']] - expected_headers = ['\x1b[31;01mh1\x1b[39;00m', '\x1b[31;01mh2\x1b[39;00m'] + expected_headers = ['\x1b[91;01mh1\x1b[39;00m', '\x1b[91;01mh2\x1b[39;00m'] expected_data = [['\x1b[38;5;233;48;5;7m1\x1b[39;49m', '\x1b[38;5;233;48;5;7m2\x1b[39;49m'], ['\x1b[38;5;10ma\x1b[39m', '\x1b[38;5;10mb\x1b[39m']] diff --git a/tests/tabular_output/test_tabulate_adapter.py b/tests/tabular_output/test_tabulate_adapter.py index d2ade12..e0dd5a8 100644 --- a/tests/tabular_output/test_tabulate_adapter.py +++ b/tests/tabular_output/test_tabulate_adapter.py @@ -73,24 +73,24 @@ class CliStyle(Style): output = tabulate_adapter.adapter(iter(data), headers, table_format='psql') assert "\n".join(output) == dedent('''\ - \x1b[31;01m+\x1b[39;00m''' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 6)) + - '''\x1b[31;01m+\x1b[39;00m - \x1b[31;01m|\x1b[39;00m h1 \x1b[31;01m|\x1b[39;00m''' + - ''' h2 \x1b[31;01m|\x1b[39;00m - ''' + '\x1b[31;01m|\x1b[39;00m' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 6)) + - '''\x1b[31;01m|\x1b[39;00m - \x1b[31;01m|\x1b[39;00m 观音 \x1b[31;01m|\x1b[39;00m''' + - ''' 2 \x1b[31;01m|\x1b[39;00m - \x1b[31;01m|\x1b[39;00m Ποσειδῶν \x1b[31;01m|\x1b[39;00m''' + - ''' b \x1b[31;01m|\x1b[39;00m - ''' + '\x1b[31;01m+\x1b[39;00m' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 6)) + - '\x1b[31;01m+\x1b[39;00m') + \x1b[91m+\x1b[39m''' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 6)) + + '''\x1b[91m+\x1b[39m + \x1b[91m|\x1b[39m h1 \x1b[91m|\x1b[39m''' + + ''' h2 \x1b[91m|\x1b[39m + ''' + '\x1b[91m|\x1b[39m' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 6)) + + '''\x1b[91m|\x1b[39m + \x1b[91m|\x1b[39m 观音 \x1b[91m|\x1b[39m''' + + ''' 2 \x1b[91m|\x1b[39m + \x1b[91m|\x1b[39m Ποσειδῶν \x1b[91m|\x1b[39m''' + + ''' b \x1b[91m|\x1b[39m + ''' + '\x1b[91m+\x1b[39m' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 6)) + + '\x1b[91m+\x1b[39m') diff --git a/tests/tabular_output/test_terminaltables_adapter.py b/tests/tabular_output/test_terminaltables_adapter.py index 8794129..f756327 100644 --- a/tests/tabular_output/test_terminaltables_adapter.py +++ b/tests/tabular_output/test_terminaltables_adapter.py @@ -46,24 +46,24 @@ class CliStyle(Style): output = terminaltables_adapter.adapter(iter(data), headers, table_format='ascii') assert "\n".join(output) == dedent('''\ - \x1b[31;01m+\x1b[39;00m''' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 4)) + - '''\x1b[31;01m+\x1b[39;00m - \x1b[31;01m|\x1b[39;00m h1 \x1b[31;01m|\x1b[39;00m''' + - ''' h2 \x1b[31;01m|\x1b[39;00m - ''' + '\x1b[31;01m+\x1b[39;00m' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 4)) + - '''\x1b[31;01m+\x1b[39;00m - \x1b[31;01m|\x1b[39;00m 观音 \x1b[31;01m|\x1b[39;00m''' + - ''' 2 \x1b[31;01m|\x1b[39;00m - \x1b[31;01m|\x1b[39;00m Ποσειδῶν \x1b[31;01m|\x1b[39;00m''' + - ''' b \x1b[31;01m|\x1b[39;00m - ''' + '\x1b[31;01m+\x1b[39;00m' + ( - ('\x1b[31;01m-\x1b[39;00m' * 10) + - '\x1b[31;01m+\x1b[39;00m' + - ('\x1b[31;01m-\x1b[39;00m' * 4)) + - '\x1b[31;01m+\x1b[39;00m') + \x1b[91m+\x1b[39m''' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 4)) + + '''\x1b[91m+\x1b[39m + \x1b[91m|\x1b[39m h1 \x1b[91m|\x1b[39m''' + + ''' h2 \x1b[91m|\x1b[39m + ''' + '\x1b[91m+\x1b[39m' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 4)) + + '''\x1b[91m+\x1b[39m + \x1b[91m|\x1b[39m 观音 \x1b[91m|\x1b[39m''' + + ''' 2 \x1b[91m|\x1b[39m + \x1b[91m|\x1b[39m Ποσειδῶν \x1b[91m|\x1b[39m''' + + ''' b \x1b[91m|\x1b[39m + ''' + '\x1b[91m+\x1b[39m' + ( + ('\x1b[91m-\x1b[39m' * 10) + + '\x1b[91m+\x1b[39m' + + ('\x1b[91m-\x1b[39m' * 4)) + + '\x1b[91m+\x1b[39m') >From ccc7aaffca8fa6e2b2f167a9d0f13e4dafe75aee Mon Sep 17 00:00:00 2001 From: Thomas Roten <tro...@kalkomey.com> Date: Fri, 24 May 2019 12:36:41 -0500 Subject: [PATCH] Pin to Pygments >= 2.4.0 for tests. --- cli_helpers/tabular_output/preprocessors.py | 2 +- tests/tabular_output/test_preprocessors.py | 6 +++--- tests/tabular_output/test_tabulate_adapter.py | 2 +- tests/tabular_output/test_terminaltables_adapter.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cli_helpers/tabular_output/preprocessors.py b/cli_helpers/tabular_output/preprocessors.py index 9bbbd39..8a1c91f 100644 --- a/cli_helpers/tabular_output/preprocessors.py +++ b/cli_helpers/tabular_output/preprocessors.py @@ -193,7 +193,7 @@ def style_output(data, headers, style=None, class YourStyle(Style): default_style = "" styles = { - Token.Output.Header: 'bold #ansired', + Token.Output.Header: 'bold ansibrightred', Token.Output.OddRow: 'bg:#eee #111', Token.Output.EvenRow: '#0f0' } diff --git a/tests/tabular_output/test_preprocessors.py b/tests/tabular_output/test_preprocessors.py index 4eb9165..d79b744 100644 --- a/tests/tabular_output/test_preprocessors.py +++ b/tests/tabular_output/test_preprocessors.py @@ -154,7 +154,7 @@ def test_style_output(): class CliStyle(Style): default_style = "" styles = { - Token.Output.Header: 'bold #ansired', + Token.Output.Header: 'bold ansibrightred', Token.Output.OddRow: 'bg:#eee #111', Token.Output.EvenRow: '#0f0' } @@ -176,7 +176,7 @@ def test_style_output_with_newlines(): class CliStyle(Style): default_style = "" styles = { - Token.Output.Header: 'bold #ansired', + Token.Output.Header: 'bold ansibrightred', Token.Output.OddRow: 'bg:#eee #111', Token.Output.EvenRow: '#0f0' } @@ -200,7 +200,7 @@ def test_style_output_custom_tokens(): class CliStyle(Style): default_style = "" styles = { - Token.Results.Headers: 'bold #ansired', + Token.Results.Headers: 'bold ansibrightred', Token.Results.OddRows: 'bg:#eee #111', Token.Results.EvenRows: '#0f0' } diff --git a/tests/tabular_output/test_tabulate_adapter.py b/tests/tabular_output/test_tabulate_adapter.py index c289cba..d2ade12 100644 --- a/tests/tabular_output/test_tabulate_adapter.py +++ b/tests/tabular_output/test_tabulate_adapter.py @@ -63,7 +63,7 @@ def test_style_output_table(): class CliStyle(Style): default_style = "" styles = { - Token.Output.TableSeparator: '#ansired', + Token.Output.TableSeparator: 'ansibrightred', } headers = ['h1', 'h2'] data = [['观音', '2'], ['Ποσειδῶν', 'b']] diff --git a/tests/tabular_output/test_terminaltables_adapter.py b/tests/tabular_output/test_terminaltables_adapter.py index fc49b99..8794129 100644 --- a/tests/tabular_output/test_terminaltables_adapter.py +++ b/tests/tabular_output/test_terminaltables_adapter.py @@ -36,7 +36,7 @@ def test_style_output_table(): class CliStyle(Style): default_style = "" styles = { - Token.Output.TableSeparator: '#ansired', + Token.Output.TableSeparator: 'ansibrightred', } headers = ['h1', 'h2'] data = [['观音', '2'], ['Ποσειδῶν', 'b']]