Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-cli-helpers for openSUSE:Factory checked in at 2025-09-15 19:52:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-cli-helpers (Old) and /work/SRC/openSUSE:Factory/.python-cli-helpers.new.1977 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-cli-helpers" Mon Sep 15 19:52:16 2025 rev:11 rq:1304689 version:2.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-cli-helpers/python-cli-helpers.changes 2025-07-14 10:56:30.864600945 +0200 +++ /work/SRC/openSUSE:Factory/.python-cli-helpers.new.1977/python-cli-helpers.changes 2025-09-15 19:56:08.791265167 +0200 @@ -1,0 +2,9 @@ +Sun Sep 14 21:02:09 UTC 2025 - Dirk Müller <[email protected]> + +- update to 2.7.0: + * Add `mysql` and `mysql_unicode` output formats which right- + align numbers. + * Register the JSON formats so they are actually usable. + * Make JSON formats able to encode Decimals and None/NULLs. + +------------------------------------------------------------------- Old: ---- cli_helpers-2.5.0.tar.gz New: ---- cli_helpers-2.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-cli-helpers.spec ++++++ --- /var/tmp/diff_new_pack.hQLnTM/_old 2025-09-15 19:56:09.243284145 +0200 +++ /var/tmp/diff_new_pack.hQLnTM/_new 2025-09-15 19:56:09.247284314 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-cli-helpers # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2025 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-cli-helpers -Version: 2.5.0 +Version: 2.7.0 Release: 0 Summary: Helpers for building command-line apps License: BSD-3-Clause ++++++ cli_helpers-2.5.0.tar.gz -> cli_helpers-2.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/CHANGELOG new/cli_helpers-2.7.0/CHANGELOG --- old/cli_helpers-2.5.0/CHANGELOG 2025-07-10 21:29:15.000000000 +0200 +++ new/cli_helpers-2.7.0/CHANGELOG 2025-07-28 12:30:41.000000000 +0200 @@ -1,7 +1,22 @@ # Changelog +## Version 2.7.0 + +(released on 2025-07-28) + +- Add `mysql` and `mysql_unicode` output formats which right-align numbers. + +## Version 2.6.0 + +(released on 2025-07-12) + +- Register the JSON formats so they are actually usable. +- Make JSON formats able to encode Decimals and None/NULLs. + ## Version 2.5.0 +(released on 2025-07-10) + - Added noheader CSV and TSV output formats. - Added `jsonl` and `jsonl_escaped` output formats. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/PKG-INFO new/cli_helpers-2.7.0/PKG-INFO --- old/cli_helpers-2.5.0/PKG-INFO 2025-07-10 21:33:10.000000000 +0200 +++ new/cli_helpers-2.7.0/PKG-INFO 2025-07-28 12:35:43.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: cli_helpers -Version: 2.5.0 +Version: 2.7.0 Summary: Helpers for building command-line apps Home-page: https://github.com/dbcli/cli_helpers Author: dbcli diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/cli_helpers/__init__.py new/cli_helpers-2.7.0/cli_helpers/__init__.py --- old/cli_helpers-2.5.0/cli_helpers/__init__.py 2025-07-10 21:29:15.000000000 +0200 +++ new/cli_helpers-2.7.0/cli_helpers/__init__.py 2025-07-28 12:31:07.000000000 +0200 @@ -1 +1 @@ -__version__ = "2.5.0" +__version__ = "2.7.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/cli_helpers/tabular_output/json_output_adapter.py new/cli_helpers-2.7.0/cli_helpers/tabular_output/json_output_adapter.py --- old/cli_helpers-2.5.0/cli_helpers/tabular_output/json_output_adapter.py 2025-07-10 20:14:05.000000000 +0200 +++ new/cli_helpers-2.7.0/cli_helpers/tabular_output/json_output_adapter.py 2025-07-12 18:23:20.000000000 +0200 @@ -1,13 +1,22 @@ # -*- coding: utf-8 -*- """A JSON data output adapter""" +from decimal import Decimal from itertools import chain import json -from .preprocessors import bytes_to_string, override_missing_value, convert_to_string +from .preprocessors import bytes_to_string supported_formats = ("jsonl", "jsonl_escaped") -preprocessors = (override_missing_value, bytes_to_string, convert_to_string) +preprocessors = (bytes_to_string,) + + +class CustomEncoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, Decimal): + return float(o) + else: + return super(CustomEncoder, self).default(o) def adapter(data, headers, table_format="jsonl", **_kwargs): @@ -22,6 +31,7 @@ for row in chain(data): yield json.dumps( dict(zip(headers, row, strict=True)), + cls=CustomEncoder, separators=(",", ":"), ensure_ascii=ensure_ascii, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/cli_helpers/tabular_output/output_formatter.py new/cli_helpers-2.7.0/cli_helpers/tabular_output/output_formatter.py --- old/cli_helpers-2.5.0/cli_helpers/tabular_output/output_formatter.py 2022-09-14 02:59:33.000000000 +0200 +++ new/cli_helpers-2.7.0/cli_helpers/tabular_output/output_formatter.py 2025-07-12 18:23:20.000000000 +0200 @@ -17,6 +17,7 @@ vertical_table_adapter, tabulate_adapter, tsv_output_adapter, + json_output_adapter, ) from decimal import Decimal @@ -253,3 +254,14 @@ tsv_output_adapter.preprocessors, {"table_format": tsv_format, "missing_value": "", "max_field_width": None}, ) + +for json_format in json_output_adapter.supported_formats: + TabularOutputFormatter.register_new_formatter( + json_format, + json_output_adapter.adapter, + json_output_adapter.preprocessors, + { + "table_format": json_format, + "max_field_width": None, + }, + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/cli_helpers/tabular_output/tabulate_adapter.py new/cli_helpers-2.7.0/cli_helpers/tabular_output/tabulate_adapter.py --- old/cli_helpers-2.5.0/cli_helpers/tabular_output/tabulate_adapter.py 2023-10-01 02:11:46.000000000 +0200 +++ new/cli_helpers-2.7.0/cli_helpers/tabular_output/tabulate_adapter.py 2025-07-28 12:30:41.000000000 +0200 @@ -63,6 +63,28 @@ with_header_hide=None, ) +tabulate._table_formats["mysql"] = tabulate.TableFormat( + lineabove=tabulate.Line("+", "-", "+", "+"), + linebelowheader=tabulate.Line("+", "-", "+", "+"), + linebetweenrows=None, + linebelow=tabulate.Line("+", "-", "+", "+"), + headerrow=tabulate.DataRow("|", "|", "|"), + datarow=tabulate.DataRow("|", "|", "|"), + padding=1, + with_header_hide=None, +) + +tabulate._table_formats["mysql_unicode"] = tabulate.TableFormat( + lineabove=tabulate.Line("┌", "─", "┬", "┐"), + linebelowheader=tabulate.Line("├", "─", "┼", "┤"), + linebetweenrows=None, + linebelow=tabulate.Line("└", "─", "┴", "┘"), + headerrow=tabulate.DataRow("│", "│", "│"), + datarow=tabulate.DataRow("│", "│", "│"), + padding=1, + with_header_hide=None, +) + # "minimal" is the same as "plain", but without headers tabulate._table_formats["minimal"] = tabulate._table_formats["plain"] @@ -70,6 +92,8 @@ tabulate.multiline_formats["double"] = "double" tabulate.multiline_formats["ascii"] = "ascii" tabulate.multiline_formats["minimal"] = "minimal" +tabulate.multiline_formats["mysql"] = "mysql" +tabulate.multiline_formats["mysql_unicode"] = "mysql_unicode" supported_markup_formats = ( "mediawiki", @@ -95,6 +119,8 @@ "rst", "github", "double", + "mysql", + "mysql_unicode", ) supported_formats = supported_markup_formats + supported_table_formats @@ -102,6 +128,8 @@ default_kwargs = { "ascii": {"numalign": "left"}, "ascii_escaped": {"numalign": "left"}, + "mysql": {"numalign": "right"}, + "mysql_unicode": {"numalign": "right"}, } headless_formats = ("minimal",) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/cli_helpers.egg-info/PKG-INFO new/cli_helpers-2.7.0/cli_helpers.egg-info/PKG-INFO --- old/cli_helpers-2.5.0/cli_helpers.egg-info/PKG-INFO 2025-07-10 21:33:10.000000000 +0200 +++ new/cli_helpers-2.7.0/cli_helpers.egg-info/PKG-INFO 2025-07-28 12:35:43.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: cli_helpers -Version: 2.5.0 +Version: 2.7.0 Summary: Helpers for building command-line apps Home-page: https://github.com/dbcli/cli_helpers Author: dbcli diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/release.py new/cli_helpers-2.7.0/release.py --- old/cli_helpers-2.5.0/release.py 2025-07-10 21:32:53.000000000 +0200 +++ new/cli_helpers-2.7.0/release.py 2025-07-10 21:33:34.000000000 +0200 @@ -127,7 +127,7 @@ if not click.confirm("Are you sure?", default=False): sys.exit(1) - # commit_for_release("cli_helpers/__init__.py", ver) + commit_for_release("cli_helpers/__init__.py", ver) create_git_tag("v{}".format(ver)) create_distribution_files() push_to_github() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/tests/tabular_output/test_json_output_adapter.py new/cli_helpers-2.7.0/tests/tabular_output/test_json_output_adapter.py --- old/cli_helpers-2.5.0/tests/tabular_output/test_json_output_adapter.py 2025-07-10 20:14:05.000000000 +0200 +++ new/cli_helpers-2.7.0/tests/tabular_output/test_json_output_adapter.py 2025-07-12 18:23:20.000000000 +0200 @@ -3,6 +3,8 @@ from __future__ import unicode_literals +from decimal import Decimal + from cli_helpers.tabular_output import json_output_adapter @@ -29,6 +31,28 @@ ) +def test_decimal_with_jsonl(): + """Test that the jsonl wrapper can pass through Decimal values.""" + data = [["ab\r\nc", 1], ["d", Decimal(4.56)]] + headers = ["letters", "number"] + output = json_output_adapter.adapter(iter(data), headers, table_format="jsonl") + assert ( + "\n".join(output) + == """{"letters":"ab\\r\\nc","number":1}\n{"letters":"d","number":4.56}""" + ) + + +def test_null_with_jsonl(): + """Test that the jsonl wrapper can pass through null values.""" + data = [["ab\r\nc", None], ["d", None]] + headers = ["letters", "value"] + output = json_output_adapter.adapter(iter(data), headers, table_format="jsonl") + assert ( + "\n".join(output) + == """{"letters":"ab\\r\\nc","value":null}\n{"letters":"d","value":null}""" + ) + + def test_unicode_with_jsonl_esc(): """Test that the jsonl_escaped wrapper JSON-escapes non-ascii characters.""" data = [["观音", 1], ["Ποσειδῶν", 456]] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cli_helpers-2.5.0/tests/tabular_output/test_output_formatter.py new/cli_helpers-2.7.0/tests/tabular_output/test_output_formatter.py --- old/cli_helpers-2.5.0/tests/tabular_output/test_output_formatter.py 2023-10-01 02:11:46.000000000 +0200 +++ new/cli_helpers-2.7.0/tests/tabular_output/test_output_formatter.py 2025-07-28 12:30:41.000000000 +0200 @@ -83,6 +83,78 @@ ) +def test_tabular_output_mysql(): + """Test the mysql output format.""" + headers = ["text", "numeric"] + data = [ + ["abc", Decimal(1)], + ["defg", Decimal("11.1")], + ["hi", Decimal("1.1")], + ["Pablo\rß\n", 0], + ] + expected = dedent( + """\ + +-------+---------+ + | text | numeric | + +-------+---------+ + | abc | 1 | + | defg | 11.1 | + | hi | 1.1 | + | Pablo | 0 | + | ß | | + +-------+---------+""" + ) + + print(expected) + print( + "\n".join( + TabularOutputFormatter().format_output( + iter(data), headers, format_name="mysql" + ) + ) + ) + assert expected == "\n".join( + TabularOutputFormatter().format_output(iter(data), headers, format_name="mysql") + ) + + +def test_tabular_output_mysql_unicode(): + """Test the mysql_unicode output format.""" + headers = ["text", "numeric"] + data = [ + ["abc", Decimal(1)], + ["defg", Decimal("11.1")], + ["hi", Decimal("1.1")], + ["Pablo\rß\n", 0], + ] + expected = dedent( + """\ + ┌───────┬─────────┐ + │ text │ numeric │ + ├───────┼─────────┤ + │ abc │ 1 │ + │ defg │ 11.1 │ + │ hi │ 1.1 │ + │ Pablo │ 0 │ + │ ß │ │ + └───────┴─────────┘""" + ) + + print(expected) + print( + "\n".join( + TabularOutputFormatter().format_output( + iter(data), headers, format_name="mysql_unicode" + ) + ) + ) + assert expected == "\n".join( + TabularOutputFormatter().format_output( + iter(data), headers, format_name="mysql_unicode" + ) + ) + + def test_tabular_format_output_wrapper(): """Test the format_output wrapper.""" data = [["1", None], ["2", "Sam"], ["3", "Joe"]] @@ -177,6 +249,13 @@ formatter.format_output((), (), format_name="foobar") +def test_supported_json_formats(): + """Test that the JSONl formats are known.""" + formatter = TabularOutputFormatter() + assert "jsonl" in formatter.supported_formats + assert "jsonl_escaped" in formatter.supported_formats + + def test_tabulate_ansi_escape_in_default_value(): """Test that ANSI escape codes work with tabulate."""
