Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-prettytable for openSUSE:Factory checked in at 2023-05-09 13:06:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-prettytable (Old) and /work/SRC/openSUSE:Factory/.python-prettytable.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-prettytable" Tue May 9 13:06:35 2023 rev:8 rq:1084996 version:3.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-prettytable/python-prettytable.changes 2023-04-22 22:00:24.277196425 +0200 +++ /work/SRC/openSUSE:Factory/.python-prettytable.new.1533/python-prettytable.changes 2023-05-09 13:06:43.896804486 +0200 @@ -1,0 +2,14 @@ +Fri May 5 07:47:24 UTC 2023 - Daniel Garcia <[email protected]> + +- Update to 3.7.0: + * Add horizontal lines to create sections within a table (#185) @myheroyuki + * Declare support for Python 3.12 (#231) @hugovk + * Rename licence file for detection by GitHub (#229) @hugovk + * Rename master to main (#228) @hugovk +- 3.6.0: + * Updated pre-commit with mypy (#218) @phershbe + * Test Python 3.12 pre-releases (#221) @hugovk + * Fix to min_table_width parameter (#219) @kzwolenik95 + * Widen tables with long titles (#216) @etjones + +------------------------------------------------------------------- Old: ---- prettytable-3.5.0.tar.gz New: ---- prettytable-3.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-prettytable.spec ++++++ --- /var/tmp/diff_new_pack.eRbXnN/_old 2023-05-09 13:06:44.416807581 +0200 +++ /var/tmp/diff_new_pack.eRbXnN/_new 2023-05-09 13:06:44.420807605 +0200 @@ -20,7 +20,7 @@ %define skip_python2 1 %{?sle15_python_module_pythons} Name: python-prettytable -Version: 3.5.0 +Version: 3.7.0 Release: 0 Summary: Library for displaying tabular data in formatted fashion License: BSD-2-Clause @@ -69,7 +69,7 @@ %pytest %files %{python_files} -%license COPYING +%license LICENSE %doc CHANGELOG.md README.md %{python_sitelib}/prettytable %{python_sitelib}/prettytable-%{version}*-info ++++++ prettytable-3.5.0.tar.gz -> prettytable-3.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.github/workflows/labels.yml new/prettytable-3.7.0/.github/workflows/labels.yml --- old/prettytable-3.5.0/.github/workflows/labels.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.github/workflows/labels.yml 2020-02-02 01:00:00.000000000 +0100 @@ -3,7 +3,7 @@ on: push: branches: - - master + - main paths: - .github/labels.yml workflow_dispatch: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.github/workflows/release-drafter.yml new/prettytable-3.7.0/.github/workflows/release-drafter.yml --- old/prettytable-3.5.0/.github/workflows/release-drafter.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.github/workflows/release-drafter.yml 2020-02-02 01:00:00.000000000 +0100 @@ -4,7 +4,7 @@ push: # branches to consider in the event; optional, defaults to all branches: - - master + - main workflow_dispatch: jobs: @@ -15,7 +15,7 @@ if: github.repository_owner == 'jazzband' runs-on: ubuntu-latest steps: - # Drafts your next release notes as pull requests are merged into "master" + # Drafts your next release notes as pull requests are merged into "main" - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.github/workflows/release.yml new/prettytable-3.7.0/.github/workflows/release.yml --- old/prettytable-3.5.0/.github/workflows/release.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.github/workflows/release.yml 2020-02-02 01:00:00.000000000 +0100 @@ -3,7 +3,7 @@ on: push: branches: - - master + - main release: types: - published diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.github/workflows/require-pr-label.yml new/prettytable-3.7.0/.github/workflows/require-pr-label.yml --- old/prettytable-3.5.0/.github/workflows/require-pr-label.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.github/workflows/require-pr-label.yml 2020-02-02 01:00:00.000000000 +0100 @@ -9,7 +9,7 @@ runs-on: ubuntu-latest steps: - - uses: mheap/github-action-required-labels@v2 + - uses: mheap/github-action-required-labels@v3 with: mode: minimum count: 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.github/workflows/test.yml new/prettytable-3.7.0/.github/workflows/test.yml --- old/prettytable-3.5.0/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 @@ -11,7 +11,7 @@ strategy: fail-fast: false matrix: - python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["pypy3.9", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"] os: [windows-latest, macos-latest, ubuntu-latest] steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/.pre-commit-config.yaml new/prettytable-3.7.0/.pre-commit-config.yaml --- old/prettytable-3.5.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -1,61 +1,71 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.3.0 hooks: - id: black - args: [--target-version=py37] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: [--add-import=from __future__ import annotations] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [flake8-2020, flake8-implicit-str-concat] - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa + - id: python-no-log-warn - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: + - id: check-case-conflict - id: check-merge-conflict - id: check-toml - id: check-yaml + - id: end-of-file-fixer - repo: https://github.com/tox-dev/pyproject-fmt - rev: 0.3.5 + rev: 0.9.2 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.10.1 + rev: v0.12.2 hooks: - id: validate-pyproject - repo: https://github.com/tox-dev/tox-ini-fmt - rev: 0.5.2 + rev: 1.0.0 hooks: - id: tox-ini-fmt - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.4 + rev: v3.0.0-alpha.6 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] exclude: ^.github/ISSUE_TEMPLATE/bug_report.md$ + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.1.1" + hooks: + - id: mypy + additional_dependencies: [types-colorama, types-setuptools] + args: [--pretty, --show-error-codes] + exclude: ^tests/ + ci: autoupdate_schedule: quarterly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/COPYING new/prettytable-3.7.0/COPYING --- old/prettytable-3.5.0/COPYING 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/COPYING 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -# Copyright (c) 2009-2014 Luke Maurits <[email protected]> -# All rights reserved. -# With contributions from: -# * Chris Clark -# * Klein Stephane -# * John Filleau -# * Vladimir VrziÄ -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/LICENSE new/prettytable-3.7.0/LICENSE --- old/prettytable-3.5.0/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/LICENSE 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,30 @@ +# Copyright (c) 2009-2014 Luke Maurits <[email protected]> +# All rights reserved. +# With contributions from: +# * Chris Clark +# * Klein Stephane +# * John Filleau +# * Vladimir VrziÄ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/PKG-INFO new/prettytable-3.7.0/PKG-INFO --- old/prettytable-3.5.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,13 +1,14 @@ Metadata-Version: 2.1 Name: prettytable -Version: 3.5.0 +Version: 3.7.0 Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format +Project-URL: Changelog, https://github.com/jazzband/prettytable/releases Project-URL: Homepage, https://github.com/jazzband/prettytable Project-URL: Source, https://github.com/jazzband/prettytable Author-email: Luke Maurits <[email protected]> Maintainer: Jazzband License: BSD (3 clause) -License-File: COPYING +License-File: LICENSE Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 @@ -17,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Text Processing @@ -37,9 +39,25 @@ [](https://pypi.org/project/prettytable/) [](https://pypistats.org/packages/prettytable) [](https://github.com/jazzband/prettytable/actions) -[](https://codecov.io/gh/jazzband/prettytable) +[](https://codecov.io/gh/jazzband/prettytable) [](https://github.com/psf/black) +PrettyTable lets you print tables in an attractive ASCII form: + +``` ++-----------+------+------------+-----------------+ +| City name | Area | Population | Annual Rainfall | ++-----------+------+------------+-----------------+ +| Adelaide | 1295 | 1158259 | 600.5 | +| Brisbane | 5905 | 1857594 | 1146.4 | +| Darwin | 112 | 120900 | 1714.7 | +| Hobart | 1357 | 205556 | 619.5 | +| Melbourne | 1566 | 3806092 | 646.9 | +| Perth | 5386 | 1554769 | 869.4 | +| Sydney | 2058 | 4336374 | 1214.8 | ++-----------+------+------------+-----------------+ +``` + ## Installation Install via pip: @@ -386,6 +404,43 @@ elements are the data in each of the table's columns, in order, including a repeated instance of the data in the `sort_by` column. +#### Adding sections to a table + +You can divide your table into different sections using the `divider` argument. This +will add a dividing line into the table under the row who has this field set. So we can +set up a table like this: + +```python +x = PrettyTable() +x.field_names = ["City name", "Area", "Population", "Annual Rainfall"] +x.add_row(["Adelaide", 1295, 1158259, 600.5]) +x.add_row(["Brisbane", 5905, 1857594, 1146.4]) +x.add_row(["Darwin", 112, 120900, 1714.7]) +x.add_row(["Hobart", 1357, 205556, 619.5], divider=True) +x.add_row(["Melbourne", 1566, 3806092, 646.9]) +x.add_row(["Perth", 5386, 1554769, 869.4]) +x.add_row(["Sydney", 2058, 4336374, 1214.8]) +``` + +to get a table like this: + +``` ++-----------+------+------------+-----------------+ +| City name | Area | Population | Annual Rainfall | ++-----------+------+------------+-----------------+ +| Adelaide | 1295 | 1158259 | 600.5 | +| Brisbane | 5905 | 1857594 | 1146.4 | +| Darwin | 112 | 120900 | 1714.7 | +| Hobart | 1357 | 205556 | 619.5 | ++-----------+------+------------+-----------------+ +| Melbourne | 1566 | 3806092 | 646.9 | +| Perth | 5386 | 1554769 | 869.4 | +| Sydney | 2058 | 4336374 | 1214.8 | ++-----------+------+------------+-----------------+ +``` + +Any added dividers will be removed if a table is sorted. + ### Changing the appearance of your table - the easy way By default, PrettyTable produces ASCII tables that look like the ones used in SQL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/README.md new/prettytable-3.7.0/README.md --- old/prettytable-3.5.0/README.md 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/README.md 2020-02-02 01:00:00.000000000 +0100 @@ -5,9 +5,25 @@ [](https://pypi.org/project/prettytable/) [](https://pypistats.org/packages/prettytable) [](https://github.com/jazzband/prettytable/actions) -[](https://codecov.io/gh/jazzband/prettytable) +[](https://codecov.io/gh/jazzband/prettytable) [](https://github.com/psf/black) +PrettyTable lets you print tables in an attractive ASCII form: + +``` ++-----------+------+------------+-----------------+ +| City name | Area | Population | Annual Rainfall | ++-----------+------+------------+-----------------+ +| Adelaide | 1295 | 1158259 | 600.5 | +| Brisbane | 5905 | 1857594 | 1146.4 | +| Darwin | 112 | 120900 | 1714.7 | +| Hobart | 1357 | 205556 | 619.5 | +| Melbourne | 1566 | 3806092 | 646.9 | +| Perth | 5386 | 1554769 | 869.4 | +| Sydney | 2058 | 4336374 | 1214.8 | ++-----------+------+------------+-----------------+ +``` + ## Installation Install via pip: @@ -354,6 +370,43 @@ elements are the data in each of the table's columns, in order, including a repeated instance of the data in the `sort_by` column. +#### Adding sections to a table + +You can divide your table into different sections using the `divider` argument. This +will add a dividing line into the table under the row who has this field set. So we can +set up a table like this: + +```python +x = PrettyTable() +x.field_names = ["City name", "Area", "Population", "Annual Rainfall"] +x.add_row(["Adelaide", 1295, 1158259, 600.5]) +x.add_row(["Brisbane", 5905, 1857594, 1146.4]) +x.add_row(["Darwin", 112, 120900, 1714.7]) +x.add_row(["Hobart", 1357, 205556, 619.5], divider=True) +x.add_row(["Melbourne", 1566, 3806092, 646.9]) +x.add_row(["Perth", 5386, 1554769, 869.4]) +x.add_row(["Sydney", 2058, 4336374, 1214.8]) +``` + +to get a table like this: + +``` ++-----------+------+------------+-----------------+ +| City name | Area | Population | Annual Rainfall | ++-----------+------+------------+-----------------+ +| Adelaide | 1295 | 1158259 | 600.5 | +| Brisbane | 5905 | 1857594 | 1146.4 | +| Darwin | 112 | 120900 | 1714.7 | +| Hobart | 1357 | 205556 | 619.5 | ++-----------+------+------------+-----------------+ +| Melbourne | 1566 | 3806092 | 646.9 | +| Perth | 5386 | 1554769 | 869.4 | +| Sydney | 2058 | 4336374 | 1214.8 | ++-----------+------+------------+-----------------+ +``` + +Any added dividers will be removed if a table is sorted. + ### Changing the appearance of your table - the easy way By default, PrettyTable produces ASCII tables that look like the ones used in SQL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/RELEASING.md new/prettytable-3.7.0/RELEASING.md --- old/prettytable-3.5.0/RELEASING.md 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/RELEASING.md 2020-02-02 01:00:00.000000000 +0100 @@ -2,9 +2,9 @@ Jazzband guidelines: https://jazzband.co/about/releases -- [ ] Get master to the appropriate code release state. +- [ ] Get `main` to the appropriate code release state. [GitHub Actions](https://github.com/jazzband/prettytable/actions) should pass on - master. + `main`. [](https://github.com/jazzband/prettytable/actions) - [ ] Edit release draft, adjust text if needed: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/pyproject.toml new/prettytable-3.7.0/pyproject.toml --- old/prettytable-3.5.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -13,13 +13,6 @@ maintainers = [{name ="Jazzband"}] authors = [{name = "Luke Maurits", email = "[email protected]"}] requires-python = ">=3.7" -dependencies = [ - 'importlib-metadata; python_version < "3.8"', - "wcwidth", -] -dynamic = [ - "version", -] classifiers = [ "License :: OSI Approved :: BSD License", "Programming Language :: Python", @@ -30,23 +23,30 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Text Processing", "Typing :: Typed", ] +dynamic = [ + "version", +] +dependencies = [ + 'importlib-metadata; python_version < "3.8"', + "wcwidth", +] [project.optional-dependencies] tests = [ "pytest", "pytest-cov", "pytest-lazy-fixture", ] - [project.urls] +Changelog = "https://github.com/jazzband/prettytable/releases" Homepage = "https://github.com/jazzband/prettytable" Source = "https://github.com/jazzband/prettytable" - [tool.hatch] version.source = "vcs" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/src/prettytable/__init__.py new/prettytable-3.7.0/src/prettytable/__init__.py --- old/prettytable-3.5.0/src/prettytable/__init__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/src/prettytable/__init__.py 2020-02-02 01:00:00.000000000 +0100 @@ -49,6 +49,6 @@ import importlib.metadata as importlib_metadata except ImportError: # <Python 3.7 and lower - import importlib_metadata + import importlib_metadata # type: ignore __version__ = importlib_metadata.version(__name__) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/src/prettytable/colortable.py new/prettytable-3.7.0/src/prettytable/colortable.py --- old/prettytable-3.5.0/src/prettytable/colortable.py 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/src/prettytable/colortable.py 2020-02-02 01:00:00.000000000 +0100 @@ -4,13 +4,11 @@ try: from colorama import init -except ImportError: - # Do nothing if not installed - def init(): - pass + init() +except ImportError: + pass -init() RESET_CODE = "\x1b[0m" @@ -34,6 +32,7 @@ self.junction_char = junction_char self.junction_color = Theme.format_code(junction_color) + @staticmethod def format_code(s: str) -> str: """Takes string and intelligently puts it into an ANSI escape sequence""" if s.strip() == "": diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/src/prettytable/prettytable.py new/prettytable-3.7.0/src/prettytable/prettytable.py --- old/prettytable-3.5.0/src/prettytable/prettytable.py 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/src/prettytable/prettytable.py 2020-02-02 01:00:00.000000000 +0100 @@ -45,7 +45,7 @@ from html.parser import HTMLParser from typing import Any -import wcwidth +import wcwidth # type: ignore # hrule styles FRAME = 0 @@ -134,8 +134,9 @@ self.encoding = kwargs.get("encoding", "UTF-8") # Data - self._field_names = [] - self._rows = [] + self._field_names: list[str] = [] + self._rows: list[list] = [] + self._dividers: list[bool] = [] self.align = {} self.valign = {} self.max_width = {} @@ -147,7 +148,7 @@ if field_names: self.field_names = field_names else: - self._widths = [] + self._widths: list[int] = [] # Options self._options = [ @@ -206,7 +207,7 @@ self._start = kwargs["start"] or 0 self._end = kwargs["end"] or None self._fields = kwargs["fields"] or None - self._none_format = {} + self._none_format: dict[None, None] = {} if kwargs["header"] in (True, False): self._header = kwargs["header"] @@ -297,7 +298,6 @@ return (excess // 2) * " " + text + (excess // 2) * " " def __getattr__(self, name): - if name == "rowcount": return len(self._rows) elif name == "colcount": @@ -311,7 +311,6 @@ raise AttributeError(name) def __getitem__(self, index): - new = PrettyTable() new.field_names = self.field_names for attr in self._options: @@ -565,6 +564,10 @@ return self._rows[:] @property + def dividers(self) -> list[bool]: + return self._dividers[:] + + @property def xhtml(self) -> bool: """Print <br/> tags if True, <br> tags if False""" return self._xhtml @@ -1254,7 +1257,6 @@ ############################## def _get_options(self, kwargs): - options = {} for option in self._options: if option in kwargs: @@ -1269,7 +1271,6 @@ ############################## def set_style(self, style) -> None: - if style == DEFAULT: self._set_default_style() elif style == MSWORD_FRIENDLY: @@ -1305,7 +1306,6 @@ self._horizontal_align_char = ":" def _set_default_style(self): - self.header = True self.border = True self._hrules = FRAME @@ -1327,7 +1327,6 @@ self._bottom_left_junction_char = None def _set_msword_style(self): - self.header = True self.border = True self._hrules = NONE @@ -1337,7 +1336,6 @@ self.vertical_char = "|" def _set_columns_style(self): - self.header = True self.border = False self.padding_width = 1 @@ -1371,7 +1369,6 @@ self.bottom_left_junction_char = "â" def _set_random_style(self): - # Just for fun! self.header = random.choice((True, False)) self.border = random.choice((True, False)) @@ -1389,7 +1386,6 @@ ############################## def add_rows(self, rows) -> None: - """Add rows to the table Arguments: @@ -1399,8 +1395,7 @@ for row in rows: self.add_row(row) - def add_row(self, row) -> None: - + def add_row(self, row, *, divider=False) -> None: """Add a row to the table Arguments: @@ -1416,9 +1411,9 @@ if not self._field_names: self.field_names = [f"Field {n + 1}" for n in range(0, len(row))] self._rows.append(list(row)) + self._dividers.append(divider) def del_row(self, row_index) -> None: - """Delete a row from the table Arguments: @@ -1431,11 +1426,11 @@ f"table only has {len(self._rows)} rows" ) del self._rows[row_index] + del self._dividers[row_index] def add_column( self, fieldname, column, align: str = "c", valign: str = "t" ) -> None: - """Add a column to the table. Arguments: @@ -1457,6 +1452,7 @@ for i in range(0, len(column)): if len(self._rows) < i + 1: self._rows.append([]) + self._dividers.append(False) self._rows[i].append(column[i]) else: raise ValueError( @@ -1475,7 +1471,6 @@ row.insert(0, i + 1) def del_column(self, fieldname) -> None: - """Delete a column from the table Arguments: @@ -1495,17 +1490,17 @@ del row[col_index] def clear_rows(self) -> None: - """Delete all rows from the table but keep the current field names""" self._rows = [] + self._dividers = [] def clear(self) -> None: - """Delete all rows and field names from the table, maintaining nothing but styling options""" self._rows = [] + self._dividers = [] self._field_names = [] self._widths = [] @@ -1583,15 +1578,29 @@ title_width = 0 min_table_width = self.min_table_width or 0 min_width = max(title_width, min_table_width) - table_width = self._compute_table_width(options) - if table_width < min_width: + if options["border"]: + borders = len(widths) + 1 + elif options["preserve_internal_border"]: + borders = len(widths) + else: + borders = 0 + + # Subtract padding for each column and borders + min_width -= ( + sum([sum(self._get_padding_widths(options)) for _ in widths]) + borders + ) + # What is being scaled is content so we sum column widths + content_width = sum(widths) or 1 + + if content_width < min_width: # Grow widths in proportion - scale = 1.0 * min_width / table_width - widths = [int(math.ceil(w * scale)) for w in widths] + scale = 1.0 * min_width / content_width + widths = [int(math.floor(w * scale)) for w in widths] + if sum(widths) < min_width: + widths[-1] += min_width - sum(widths) self._widths = widths def _get_padding_widths(self, options): - if options["left_padding_width"] is not None: lpad = options["left_padding_width"] else: @@ -1631,6 +1640,23 @@ return rows + def _get_dividers(self, options): + """Return only those dividers that should be printed, based on slicing. + + Arguments: + + options - dictionary of option settings.""" + + if options["oldsortslice"]: + dividers = copy.deepcopy(self._dividers[options["start"] : options["end"]]) + else: + dividers = copy.deepcopy(self._dividers) + + if options["sortby"]: + dividers = [False for divider in dividers] + + return dividers + def _format_row(self, row): return [ self._format_value(field, value) @@ -1645,7 +1671,6 @@ ############################## def get_string(self, **kwargs) -> str: - """Return string representation of table in current state. Arguments: @@ -1704,6 +1729,7 @@ # Get the rows we need to print, taking into account slicing, sorting, etc. rows = self._get_rows(options) + dividers = self._get_dividers(options) # Turn all data in all rows into Unicode, formatted as desired formatted_rows = self._format_rows(rows) @@ -1728,8 +1754,10 @@ ) # Add rows - for row in formatted_rows[:-1]: + for row, divider in zip(formatted_rows[:-1], dividers[:-1]): lines.append(self._stringify_row(row, options, self._hrule)) + if divider: + lines.append(self._stringify_hrule(options, where="bottom_")) if formatted_rows: lines.append( self._stringify_row( @@ -1752,7 +1780,6 @@ return "\n".join(lines) def _stringify_hrule(self, options, where=""): - if not options["border"] and not options["preserve_internal_border"]: return "" lpad, rpad = self._get_padding_widths(options) @@ -1792,7 +1819,6 @@ return "".join(bits) def _stringify_title(self, title, options): - lines = [] lpad, rpad = self._get_padding_widths(options) if options["border"]: @@ -1816,7 +1842,6 @@ return "\n".join(lines) def _stringify_header(self, options): - bits = [] lpad, rpad = self._get_padding_widths(options) if options["border"]: @@ -1839,7 +1864,7 @@ bits.append(options["vertical_char"]) else: bits.append(" ") - for (field, width) in zip(self._field_names, self._widths): + for field, width in zip(self._field_names, self._widths): if options["fields"] and field not in options["fields"]: continue if self._header_style == "cap": @@ -1883,8 +1908,7 @@ return "".join(bits) def _stringify_row(self, row, options, hrule): - - for (index, field, value, width) in zip( + for index, field, value, width in zip( range(0, len(row)), self._field_names, row, self._widths ): # Enforce max widths @@ -1916,8 +1940,7 @@ else: bits[y].append(" ") - for (field, value, width) in zip(self._field_names, row, self._widths): - + for field, value, width in zip(self._field_names, row, self._widths): valign = self._valign[field] lines = value.split("\n") d_height = row_height - len(lines) @@ -1973,7 +1996,6 @@ return "\n".join(bits) def paginate(self, page_length: int = 58, line_break: str = "\f", **kwargs): - pages = [] kwargs["start"] = kwargs.get("start", 0) true_end = kwargs.get("end", self.rowcount) @@ -1989,7 +2011,6 @@ # CSV STRING METHODS # ############################## def get_csv_string(self, **kwargs) -> str: - """Return string representation of CSV formatted table in the current state Keyword arguments are first interpreted as table formatting options, and @@ -2017,7 +2038,6 @@ # JSON STRING METHODS # ############################## def get_json_string(self, **kwargs) -> str: - """Return string representation of JSON formatted table in the current state Keyword arguments are first interpreted as table formatting options, and @@ -2028,7 +2048,7 @@ """ options = self._get_options(kwargs) - json_options = dict(indent=4, separators=(",", ": "), sort_keys=True) + json_options: Any = dict(indent=4, separators=(",", ": "), sort_keys=True) json_options.update( {key: value for key, value in kwargs.items() if key not in options} ) @@ -2088,7 +2108,6 @@ return string def _get_simple_html_string(self, options): - lines = [] if options["xhtml"]: linebreak = "<br/>" @@ -2139,7 +2158,6 @@ return "\n".join(lines) def _get_formatted_html_string(self, options): - lines = [] lpad, rpad = self._get_padding_widths(options) if options["xhtml"]: @@ -2420,9 +2438,9 @@ def __init__(self, **kwargs) -> None: HTMLParser.__init__(self) self.kwargs = kwargs - self.tables = [] - self.last_row = [] - self.rows = [] + self.tables: list[list] = [] + self.last_row: list[str] = [] + self.rows: list[Any] = [] self.max_row_width = 0 self.active = None self.last_content = "" @@ -2433,7 +2451,7 @@ self.active = tag if tag == "th": self.is_last_row_header = True - for (key, value) in attrs: + for key, value in attrs: if key == "colspan": self.colspan = int(value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/tests/test_prettytable.py new/prettytable-3.7.0/tests/test_prettytable.py --- old/prettytable-3.5.0/tests/test_prettytable.py 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/tests/test_prettytable.py 2020-02-02 01:00:00.000000000 +0100 @@ -555,6 +555,13 @@ city_data_prettytable.title = "My table" self._test_all_length_equal(city_data_prettytable) + def test_all_lengths_equal_with_long_title( + self, city_data_prettytable: PrettyTable + ): + """All lines in a table should be of the same length, even with a long title.""" + city_data_prettytable.title = "My table (75 characters wide) " + "=" * 45 + self._test_all_length_equal(city_data_prettytable) + def test_no_blank_lines_without_border(self, city_data_prettytable: PrettyTable): """No table should ever have blank lines in it.""" city_data_prettytable.border = False @@ -1731,7 +1738,6 @@ def test_autoindex(): - """Testing that a table with a custom index row is equal to the one produced by the function .add_autoindex() @@ -1905,6 +1911,59 @@ assert row_prettytable._repr_html_() == row_prettytable.get_html_string() +class TestMinTableWidth: + @pytest.mark.parametrize( + "loops, fields, desired_width, border, internal_border", + [ + (15, ["Test table"], 20, True, False), + (16, ["Test table"], 21, True, False), + (18, ["Test table", "Test table 2"], 40, True, False), + (19, ["Test table", "Test table 2"], 41, True, False), + (21, ["Test table", "Test col 2", "Test col 3"], 50, True, False), + (22, ["Test table", "Test col 2", "Test col 3"], 51, True, False), + (19, ["Test table"], 20, False, False), + (20, ["Test table"], 21, False, False), + (25, ["Test table", "Test table 2"], 40, False, False), + (26, ["Test table", "Test table 2"], 41, False, False), + (25, ["Test table", "Test col 2", "Test col 3"], 50, False, False), + (26, ["Test table", "Test col 2", "Test col 3"], 51, False, False), + (18, ["Test table"], 20, False, True), + (19, ["Test table"], 21, False, True), + (23, ["Test table", "Test table 2"], 40, False, True), + (24, ["Test table", "Test table 2"], 41, False, True), + (22, ["Test table", "Test col 2", "Test col 3"], 50, False, True), + (23, ["Test table", "Test col 2", "Test col 3"], 51, False, True), + ], + ) + def test_min_table_width( + self, loops, fields, desired_width, border, internal_border + ): + for col_width in range(loops): + x = prettytable.PrettyTable() + x.border = border + x.preserve_internal_border = internal_border + x.field_names = fields + x.add_row(["X" * col_width] + ["" for _ in range(len(fields) - 1)]) + x.min_table_width = desired_width + t = x.get_string() + if border is False and internal_border is False: + assert [len(x) for x in t.split("\n")] == [desired_width, desired_width] + elif border is False and internal_border is True: + assert [len(x) for x in t.split("\n")] == [ + desired_width, + desired_width - 1, + desired_width, + ] + else: + assert [len(x) for x in t.split("\n")] == [ + desired_width, + desired_width, + desired_width, + desired_width, + desired_width, + ] + + class TestMaxTableWidth: def test_max_table_width(self): pt = PrettyTable() @@ -1923,6 +1982,50 @@ ) +class TestRowEndSection: + def test_row_end_section(self): + pt = PrettyTable() + v = 1 + for row in range(4): + if row % 2 == 0: + pt.add_row([f"value {v}", f"value{v+1}", f"value{v+2}"], divider=True) + else: + pt.add_row([f"value {v}", f"value{v+1}", f"value{v+2}"], divider=False) + v += 3 + pt.del_row(0) + assert ( + pt.get_string().strip() + == """ ++----------+---------+---------+ +| Field 1 | Field 2 | Field 3 | ++----------+---------+---------+ +| value 4 | value5 | value6 | +| value 7 | value8 | value9 | ++----------+---------+---------+ +| value 10 | value11 | value12 | ++----------+---------+---------+ +""".strip() + ) + + +class TestClearing: + def test_clear_rows(self, row_prettytable: PrettyTable): + t = helper_table() + t.add_row(["a", "b", "c"], divider=True) + t.clear_rows() + assert t.rows == [] + assert t.dividers == [] + assert t.field_names == ["Field 1", "Field 2", "Field 3"] + + def test_clear(self, row_prettytable: PrettyTable): + t = helper_table() + t.add_row(["a", "b", "c"], divider=True) + t.clear() + assert t.rows == [] + assert t.dividers == [] + assert t.field_names == [] + + class TestPreservingInternalBorders: def test_internal_border_preserved(self): pt = helper_table(3) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.5.0/tox.ini new/prettytable-3.7.0/tox.ini --- old/prettytable-3.5.0/tox.ini 2020-02-02 01:00:00.000000000 +0100 +++ new/prettytable-3.7.0/tox.ini 2020-02-02 01:00:00.000000000 +0100 @@ -1,14 +1,14 @@ [tox] envlist = lint - py{py3, 311, 310, 39, 38, 37} + py{py3, 312, 311, 310, 39, 38, 37} isolated_build = true [testenv] -passenv = - FORCE_COLOR extras = tests +passenv = + FORCE_COLOR commands = {envpython} -m pytest \ --cov prettytable \ @@ -17,10 +17,10 @@ coverage report [testenv:lint] -passenv = - PRE_COMMIT_COLOR skip_install = true deps = pre-commit +passenv = + PRE_COMMIT_COLOR commands = pre-commit run --all-files --show-diff-on-failure
