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 2022-11-08 10:53:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-prettytable (Old) and /work/SRC/openSUSE:Factory/.python-prettytable.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-prettytable" Tue Nov 8 10:53:17 2022 rev:6 rq:1034129 version:3.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-prettytable/python-prettytable.changes 2022-09-18 17:31:49.893702459 +0200 +++ /work/SRC/openSUSE:Factory/.python-prettytable.new.1597/python-prettytable.changes 2022-11-08 10:53:21.773388979 +0100 @@ -1,0 +2,8 @@ +Sun Nov 6 10:05:26 UTC 2022 - John Vandenberg <[email protected]> + +- Update to v3.5.0 + * Add py.typed and update setup.cfg + * Add type hints from typeshed + * Convert from setuptools to hatchling + +------------------------------------------------------------------- Old: ---- prettytable-3.4.1.tar.gz New: ---- prettytable-3.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-prettytable.spec ++++++ --- /var/tmp/diff_new_pack.j7pbO8/_old 2022-11-08 10:53:22.301392121 +0100 +++ /var/tmp/diff_new_pack.j7pbO8/_new 2022-11-08 10:53:22.309392169 +0100 @@ -17,10 +17,9 @@ # -%{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-prettytable -Version: 3.4.1 +Version: 3.5.0 Release: 0 Summary: Library for displaying tabular data in formatted fashion License: BSD-2-Clause @@ -28,10 +27,11 @@ Source0: https://files.pythonhosted.org/packages/source/p/prettytable/prettytable-%{version}.tar.gz BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module importlib-metadata if %python-base < 3.8} +BuildRequires: %{python_module hatchling} +BuildRequires: %{python_module hatch_vcs} +BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest-lazy-fixture} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module setuptools_scm} -BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wcwidth} BuildRequires: %{pythons} BuildRequires: fdupes @@ -57,10 +57,10 @@ sed -i '1 {/env python/d}' src/prettytable/prettytable.py %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check ++++++ prettytable-3.4.1.tar.gz -> prettytable-3.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/.flake8 new/prettytable-3.5.0/.flake8 --- old/prettytable-3.4.1/.flake8 1970-01-01 01:00:00.000000000 +0100 +++ new/prettytable-3.5.0/.flake8 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,3 @@ +[flake8] +extend-ignore = E203 +max-line-length = 88 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/.github/workflows/release.yml new/prettytable-3.5.0/.github/workflows/release.yml --- old/prettytable-3.4.1/.github/workflows/release.yml 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/.github/workflows/release.yml 2020-02-02 01:00:00.000000000 +0100 @@ -22,9 +22,9 @@ - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.x" cache: pip - cache-dependency-path: "setup.py" + cache-dependency-path: pyproject.toml - name: Install dependencies run: | @@ -33,7 +33,6 @@ - name: Build package run: | - python setup.py --version python -m build twine check --strict dist/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/.github/workflows/test.yml new/prettytable-3.5.0/.github/workflows/test.yml --- old/prettytable-3.4.1/.github/workflows/test.yml 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.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-dev"] + python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10", "3.11"] os: [windows-latest, macos-latest, ubuntu-latest] steps: @@ -22,7 +22,7 @@ with: python-version: ${{ matrix.python-version }} cache: pip - cache-dependency-path: setup.cfg + cache-dependency-path: pyproject.toml - name: Install dependencies run: | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/.pre-commit-config.yaml new/prettytable-3.5.0/.pre-commit-config.yaml --- old/prettytable-3.4.1/.pre-commit-config.yaml 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -1,12 +1,12 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.37.3 + rev: v3.1.0 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.10.0 hooks: - id: black args: [--target-version=py37] @@ -15,6 +15,7 @@ rev: 5.10.1 hooks: - id: isort + args: [--add-import=from __future__ import annotations] - repo: https://github.com/PyCQA/flake8 rev: 5.0.4 @@ -31,13 +32,18 @@ rev: v4.3.0 hooks: - id: check-merge-conflict + - id: check-toml - id: check-yaml - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.0.0 + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.3.5 hooks: - - id: setup-cfg-fmt - args: [--max-py-version=3.11, --include-version-classifiers] + - id: pyproject-fmt + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.10.1 + hooks: + - id: validate-pyproject - repo: https://github.com/tox-dev/tox-ini-fmt rev: 0.5.2 @@ -45,7 +51,7 @@ - id: tox-ini-fmt - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.0 + rev: v3.0.0-alpha.4 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/PKG-INFO new/prettytable-3.5.0/PKG-INFO --- old/prettytable-3.4.1/PKG-INFO 2022-09-02 15:33:03.599464400 +0200 +++ new/prettytable-3.5.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,13 +1,13 @@ Metadata-Version: 2.1 Name: prettytable -Version: 3.4.1 +Version: 3.5.0 Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format -Home-page: https://github.com/jazzband/prettytable -Author: Luke Maurits -Author-email: [email protected] +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) -Project-URL: Source, https://github.com/jazzband/prettytable +License-File: COPYING Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 @@ -20,10 +20,15 @@ Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Text Processing +Classifier: Typing :: Typed Requires-Python: >=3.7 -Description-Content-Type: text/markdown +Requires-Dist: importlib-metadata; python_version < '3.8' +Requires-Dist: wcwidth Provides-Extra: tests -License-File: COPYING +Requires-Dist: pytest; extra == 'tests' +Requires-Dist: pytest-cov; extra == 'tests' +Requires-Dist: pytest-lazy-fixture; extra == 'tests' +Description-Content-Type: text/markdown # PrettyTable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/pyproject.toml new/prettytable-3.5.0/pyproject.toml --- old/prettytable-3.4.1/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/prettytable-3.5.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,57 @@ +[build-system] +build-backend = "hatchling.build" +requires = [ + "hatch-vcs", + "hatchling", +] + +[project] +name = "prettytable" +description = "A simple Python library for easily displaying tabular data in a visually appealing ASCII table format" +readme = "README.md" +license = {text = "BSD (3 clause)"} +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", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Text Processing", + "Typing :: Typed", +] +[project.optional-dependencies] +tests = [ + "pytest", + "pytest-cov", + "pytest-lazy-fixture", +] + +[project.urls] +Homepage = "https://github.com/jazzband/prettytable" +Source = "https://github.com/jazzband/prettytable" + + +[tool.hatch] +version.source = "vcs" + +[tool.hatch.version.raw-options] +local_scheme = "no-local-version" + +[tool.isort] +profile = "black" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/setup.cfg new/prettytable-3.5.0/setup.cfg --- old/prettytable-3.4.1/setup.cfg 2022-09-02 15:33:03.603464400 +0200 +++ new/prettytable-3.5.0/setup.cfg 1970-01-01 01:00:00.000000000 +0100 @@ -1,56 +0,0 @@ -[metadata] -name = prettytable -description = A simple Python library for easily displaying tabular data in a visually appealing ASCII table format -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/jazzband/prettytable -author = Luke Maurits -author_email = [email protected] -maintainer = Jazzband -license = BSD (3 clause) -classifiers = - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Text Processing -project_urls = - Source=https://github.com/jazzband/prettytable - -[options] -packages = find: -install_requires = - wcwidth - importlib-metadata;python_version < '3.8' -python_requires = >=3.7 -package_dir = =src -setup_requires = - setuptools-scm - -[options.packages.find] -where = src - -[options.extras_require] -tests = - pytest - pytest-cov - pytest-lazy-fixture - -[flake8] -extend-ignore = E203 -max_line_length = 88 - -[tool:isort] -profile = black - -[egg_info] -tag_build = -tag_date = 0 - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/setup.py new/prettytable-3.5.0/setup.py --- old/prettytable-3.4.1/setup.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/setup.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,12 +0,0 @@ -from setuptools import setup - - -def local_scheme(version: str) -> str: - """Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2) - to be able to upload to Test PyPI""" - return "" - - -setup( - use_scm_version={"local_scheme": local_scheme}, -) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable/__init__.py new/prettytable-3.5.0/src/prettytable/__init__.py --- old/prettytable-3.4.1/src/prettytable/__init__.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable/__init__.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + from .prettytable import ( ALL, DEFAULT, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable/colortable.py new/prettytable-3.5.0/src/prettytable/colortable.py --- old/prettytable-3.4.1/src/prettytable/colortable.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable/colortable.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + from .prettytable import PrettyTable try: @@ -68,7 +70,7 @@ self._theme = value self.update_theme() - def update_theme(self): + def update_theme(self) -> None: theme = self._theme self._vertical_char = ( @@ -92,5 +94,5 @@ + theme.default_color ) - def get_string(self, **kwargs): + def get_string(self, **kwargs) -> str: return super().get_string(**kwargs) + RESET_CODE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable/prettytable.py new/prettytable-3.5.0/src/prettytable/prettytable.py --- old/prettytable-3.4.1/src/prettytable/prettytable.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable/prettytable.py 2020-02-02 01:00:00.000000000 +0100 @@ -31,6 +31,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +from __future__ import annotations + import copy import csv import io @@ -41,6 +43,7 @@ import textwrap from html import escape from html.parser import HTMLParser +from typing import Any import wcwidth @@ -558,11 +561,11 @@ # ATTRIBUTE MANAGEMENT # ############################## @property - def rows(self): + def rows(self) -> list[Any]: return self._rows[:] @property - def xhtml(self): + def xhtml(self) -> bool: """Print <br/> tags if True, <br> tags if False""" return self._xhtml @@ -1265,7 +1268,7 @@ # PRESET STYLE LOGIC # ############################## - def set_style(self, style): + def set_style(self, style) -> None: if style == DEFAULT: self._set_default_style() @@ -1385,7 +1388,7 @@ # DATA INPUT METHODS # ############################## - def add_rows(self, rows): + def add_rows(self, rows) -> None: """Add rows to the table @@ -1396,7 +1399,7 @@ for row in rows: self.add_row(row) - def add_row(self, row): + def add_row(self, row) -> None: """Add a row to the table @@ -1414,7 +1417,7 @@ self.field_names = [f"Field {n + 1}" for n in range(0, len(row))] self._rows.append(list(row)) - def del_row(self, row_index): + def del_row(self, row_index) -> None: """Delete a row from the table @@ -1429,7 +1432,9 @@ ) del self._rows[row_index] - def add_column(self, fieldname, column, align="c", valign="t"): + def add_column( + self, fieldname, column, align: str = "c", valign: str = "t" + ) -> None: """Add a column to the table. @@ -1459,7 +1464,7 @@ f"{len(self._rows)}" ) - def add_autoindex(self, fieldname="Index"): + def add_autoindex(self, fieldname: str = "Index"): """Add an auto-incrementing index column to the table. Arguments: fieldname - name of the field to contain the new column of data""" @@ -1469,7 +1474,7 @@ for i, row in enumerate(self._rows): row.insert(0, i + 1) - def del_column(self, fieldname): + def del_column(self, fieldname) -> None: """Delete a column from the table @@ -1489,13 +1494,13 @@ for row in self._rows: del row[col_index] - def clear_rows(self): + def clear_rows(self) -> None: """Delete all rows from the table but keep the current field names""" self._rows = [] - def clear(self): + def clear(self) -> None: """Delete all rows and field names from the table, maintaining nothing but styling options""" @@ -1639,7 +1644,7 @@ # PLAIN TEXT STRING METHODS # ############################## - def get_string(self, **kwargs): + def get_string(self, **kwargs) -> str: """Return string representation of table in current state. @@ -1967,7 +1972,7 @@ return "\n".join(bits) - def paginate(self, page_length=58, line_break="\f", **kwargs): + def paginate(self, page_length: int = 58, line_break: str = "\f", **kwargs): pages = [] kwargs["start"] = kwargs.get("start", 0) @@ -1983,7 +1988,7 @@ ############################## # CSV STRING METHODS # ############################## - def get_csv_string(self, **kwargs): + def get_csv_string(self, **kwargs) -> str: """Return string representation of CSV formatted table in the current state @@ -2011,7 +2016,7 @@ ############################## # JSON STRING METHODS # ############################## - def get_json_string(self, **kwargs): + def get_json_string(self, **kwargs) -> str: """Return string representation of JSON formatted table in the current state @@ -2040,7 +2045,7 @@ # HTML STRING METHODS # ############################## - def get_html_string(self, **kwargs): + def get_html_string(self, **kwargs) -> str: """Return string representation of HTML formatted version of table in current state. @@ -2225,7 +2230,7 @@ # LATEX STRING METHODS # ############################## - def get_latex_string(self, **kwargs): + def get_latex_string(self, **kwargs) -> str: """Return string representation of LaTex formatted version of table in current state. @@ -2359,7 +2364,7 @@ ############################## -def from_csv(fp, field_names=None, **kwargs): +def from_csv(fp, field_names: Any | None = None, **kwargs): fmtparams = {} for param in [ "delimiter", @@ -2424,7 +2429,7 @@ self.is_last_row_header = False self.colspan = 0 - def handle_starttag(self, tag, attrs): + def handle_starttag(self, tag, attrs) -> None: self.active = tag if tag == "th": self.is_last_row_header = True @@ -2432,7 +2437,7 @@ if key == "colspan": self.colspan = int(value) - def handle_endtag(self, tag): + def handle_endtag(self, tag) -> None: if tag in ["th", "td"]: stripped_content = self.last_content.strip() self.last_row.append(stripped_content) @@ -2453,7 +2458,7 @@ self.last_content = " " self.active = None - def handle_data(self, data): + def handle_data(self, data) -> None: self.last_content += data def generate_table(self, rows): @@ -2474,7 +2479,7 @@ table.add_row(row[0]) return table - def make_fields_unique(self, fields): + def make_fields_unique(self, fields) -> None: """ iterates over the row and make each field unique """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable.egg-info/PKG-INFO new/prettytable-3.5.0/src/prettytable.egg-info/PKG-INFO --- old/prettytable-3.4.1/src/prettytable.egg-info/PKG-INFO 2022-09-02 15:33:03.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,681 +0,0 @@ -Metadata-Version: 2.1 -Name: prettytable -Version: 3.4.1 -Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format -Home-page: https://github.com/jazzband/prettytable -Author: Luke Maurits -Author-email: [email protected] -Maintainer: Jazzband -License: BSD (3 clause) -Project-URL: Source, https://github.com/jazzband/prettytable -Classifier: License :: OSI Approved :: BSD License -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3 :: Only -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: 3.10 -Classifier: Programming Language :: Python :: 3.11 -Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy -Classifier: Topic :: Text Processing -Requires-Python: >=3.7 -Description-Content-Type: text/markdown -Provides-Extra: tests -License-File: COPYING - -# PrettyTable - -[](https://jazzband.co/) -[](https://pypi.org/project/prettytable/) -[](https://pypi.org/project/prettytable/) -[](https://pypistats.org/packages/prettytable) -[](https://github.com/jazzband/prettytable/actions) -[](https://codecov.io/gh/jazzband/prettytable) -[](https://github.com/psf/black) - -## Installation - -Install via pip: - - python -m pip install -U prettytable - -Install latest development version: - - python -m pip install -U git+https://github.com/jazzband/prettytable - -Or from `requirements.txt`: - - -e git://github.com/jazzband/prettytable.git#egg=prettytable - -## Tutorial on how to use the PrettyTable API - -### Getting your data into (and out of) the table - -Let's suppose you have a shiny new PrettyTable: - -```python -from prettytable import PrettyTable -x = PrettyTable() -``` - -and you want to put some data into it. You have a few options. - -#### Row by row - -You can add data one row at a time. To do this you can set the field names first using -the `field_names` attribute, and then add the rows one at a time using the `add_row` -method: - -```python -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]) -x.add_row(["Sydney", 2058, 4336374, 1214.8]) -x.add_row(["Melbourne", 1566, 3806092, 646.9]) -x.add_row(["Perth", 5386, 1554769, 869.4]) -``` - -#### All rows at once - -When you have a list of rows, you can add them in one go with `add_rows`: - -```python -x.field_names = ["City name", "Area", "Population", "Annual Rainfall"] -x.add_rows( - [ - ["Adelaide", 1295, 1158259, 600.5], - ["Brisbane", 5905, 1857594, 1146.4], - ["Darwin", 112, 120900, 1714.7], - ["Hobart", 1357, 205556, 619.5], - ["Sydney", 2058, 4336374, 1214.8], - ["Melbourne", 1566, 3806092, 646.9], - ["Perth", 5386, 1554769, 869.4], - ] -) -``` - -#### Column by column - -You can add data one column at a time as well. To do this you use the `add_column` -method, which takes two arguments - a string which is the name for the field the column -you are adding corresponds to, and a list or tuple which contains the column data: - -```python -x.add_column("City name", -["Adelaide","Brisbane","Darwin","Hobart","Sydney","Melbourne","Perth"]) -x.add_column("Area", [1295, 5905, 112, 1357, 2058, 1566, 5386]) -x.add_column("Population", [1158259, 1857594, 120900, 205556, 4336374, 3806092, -1554769]) -x.add_column("Annual Rainfall",[600.5, 1146.4, 1714.7, 619.5, 1214.8, 646.9, -869.4]) -``` - -#### Mixing and matching - -If you really want to, you can even mix and match `add_row` and `add_column` and build -some of your table in one way and some of it in the other. Tables built this way are -kind of confusing for other people to read, though, so don't do this unless you have a -good reason. - -#### Importing data from a CSV file - -If you have your table data in a comma-separated values file (.csv), you can read this -data into a PrettyTable like this: - -```python -from prettytable import from_csv -with open("myfile.csv") as fp: - mytable = from_csv(fp) -``` - -#### Importing data from a database cursor - -If you have your table data in a database which you can access using a library which -confirms to the Python DB-API (e.g. an SQLite database accessible using the `sqlite` -module), then you can build a PrettyTable using a cursor object, like this: - -```python -import sqlite3 -from prettytable import from_db_cursor - -connection = sqlite3.connect("mydb.db") -cursor = connection.cursor() -cursor.execute("SELECT field1, field2, field3 FROM my_table") -mytable = from_db_cursor(cursor) -``` - -#### Getting data out - -There are three ways to get data out of a PrettyTable, in increasing order of -completeness: - -- The `del_row` method takes an integer index of a single row to delete. -- The `del_column` method takes a field name of a single column to delete. -- The `clear_rows` method takes no arguments and deletes all the rows in the table - but - keeps the field names as they were so you that you can repopulate it with the same - kind of data. -- The `clear` method takes no arguments and deletes all rows and all field names. It's - not quite the same as creating a fresh table instance, though - style related - settings, discussed later, are maintained. - -### Displaying your table in ASCII form - -PrettyTable's main goal is to let you print tables in an attractive ASCII form, 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 | -+-----------+------+------------+-----------------+ -``` - -You can print tables like this to `stdout` or get string representations of them. - -#### Printing - -To print a table in ASCII form, you can just do this: - -```python -print(x) -``` - -The old `x.printt()` method from versions 0.5 and earlier has been removed. - -To pass options changing the look of the table, use the `get_string()` method documented -below: - -```python -print(x.get_string()) -``` - -#### Stringing - -If you don't want to actually print your table in ASCII form but just get a string -containing what _would_ be printed if you use `print(x)`, you can use the `get_string` -method: - -```python -mystring = x.get_string() -``` - -This string is guaranteed to look exactly the same as what would be printed by doing -`print(x)`. You can now do all the usual things you can do with a string, like write -your table to a file or insert it into a GUI. - -#### Controlling which data gets displayed - -If you like, you can restrict the output of `print(x)` or `x.get_string` to only the -fields or rows you like. - -The `fields` argument to these methods takes a list of field names to be printed: - -```python -print(x.get_string(fields=["City name", "Population"])) -``` - -gives: - -``` -+-----------+------------+ -| City name | Population | -+-----------+------------+ -| Adelaide | 1158259 | -| Brisbane | 1857594 | -| Darwin | 120900 | -| Hobart | 205556 | -| Melbourne | 3806092 | -| Perth | 1554769 | -| Sydney | 4336374 | -+-----------+------------+ -``` - -The `start` and `end` arguments take the index of the first and last row to print -respectively. Note that the indexing works like Python list slicing - to print the 2nd, -3rd and 4th rows of the table, set `start` to 1 (the first row is row 0, so the second -is row 1) and set `end` to 4 (the index of the 4th row, plus 1): - -```python -print(x.get_string(start=1, end=4)) -``` - -prints: - -``` -+-----------+------+------------+-----------------+ -| City name | Area | Population | Annual Rainfall | -+-----------+------+------------+-----------------+ -| Brisbane | 5905 | 1857594 | 1146.4 | -| Darwin | 112 | 120900 | 1714.7 | -| Hobart | 1357 | 205556 | 619.5 | -+-----------+------+------------+-----------------+ -``` - -#### Changing the alignment of columns - -By default, all columns in a table are centre aligned. - -##### All columns at once - -You can change the alignment of all the columns in a table at once by assigning a one -character string to the `align` attribute. The allowed strings are `"l"`, `"r"` and -`"c"` for left, right and centre alignment, respectively: - -```python -x.align = "r" -print(x) -``` - -gives: - -``` -+-----------+------+------------+-----------------+ -| 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 | -+-----------+------+------------+-----------------+ -``` - -##### One column at a time - -You can also change the alignment of individual columns based on the corresponding field -name by treating the `align` attribute as if it were a dictionary. - -```python -x.align["City name"] = "l" -x.align["Area"] = "c" -x.align["Population"] = "r" -x.align["Annual Rainfall"] = "c" -print(x) -``` - -gives: - -``` -+-----------+------+------------+-----------------+ -| 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 | -+-----------+------+------------+-----------------+ -``` - -##### Sorting your table by a field - -You can make sure that your ASCII tables are produced with the data sorted by one -particular field by giving `get_string` a `sortby` keyword argument, which must be a -string containing the name of one field. - -For example, to print the example table we built earlier of Australian capital city -data, so that the most populated city comes last, we can do this: - -```python -print(x.get_string(sortby="Population")) -``` - -to get: - -``` -+-----------+------+------------+-----------------+ -| City name | Area | Population | Annual Rainfall | -+-----------+------+------------+-----------------+ -| Darwin | 112 | 120900 | 1714.7 | -| Hobart | 1357 | 205556 | 619.5 | -| Adelaide | 1295 | 1158259 | 600.5 | -| Perth | 5386 | 1554769 | 869.4 | -| Brisbane | 5905 | 1857594 | 1146.4 | -| Melbourne | 1566 | 3806092 | 646.9 | -| Sydney | 2058 | 4336374 | 1214.8 | -+-----------+------+------------+-----------------+ -``` - -If we want the most populated city to come _first_, we can also give a -`reversesort=True` argument. - -If you _always_ want your tables to be sorted in a certain way, you can make the setting -long-term like this: - -```python -x.sortby = "Population" -print(x) -print(x) -print(x) -``` - -All three tables printed by this code will be sorted by population (you could do -`x.reversesort = True` as well, if you wanted). The behaviour will persist until you -turn it off: - -```python -x.sortby = None -``` - -If you want to specify a custom sorting function, you can use the `sort_key` keyword -argument. Pass this a function which accepts two lists of values and returns a negative -or positive value depending on whether the first list should appear before or after the -second one. If your table has n columns, each list will have n+1 elements. Each list -corresponds to one row of the table. The first element will be whatever data is in the -relevant row, in the column specified by the `sort_by` argument. The remaining n -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. - -### Changing the appearance of your table - the easy way - -By default, PrettyTable produces ASCII tables that look like the ones used in SQL -database shells. But it can print them in a variety of other formats as well. If the -format you want to use is common, PrettyTable makes this easy for you to do using the -`set_style` method. If you want to produce an uncommon table, you'll have to do things -slightly harder (see later). - -#### Setting a table style - -You can set the style for your table using the `set_style` method before any calls to -`print` or `get_string`. Here's how to print a table in a format which works nicely with -Microsoft Word's "Convert to table" feature: - -```python -from prettytable import MSWORD_FRIENDLY -x.set_style(MSWORD_FRIENDLY) -print(x) -``` - -In addition to `MSWORD_FRIENDLY` you can use these in-built styles for your tables: - -- `DEFAULT` - The default look, used to undo any style changes you may have made -- `PLAIN_COLUMNS` - A borderless style that works well with command line programs for - columnar data -- `MARKDOWN` - A style that follows Markdown syntax -- `ORGMODE` - A table style that fits [Org mode](https://orgmode.org/) syntax -- `SINGLE_BORDER` and `DOUBLE_BORDER` - Styles that use continuous single/double border - lines with Box drawing characters for a fancier display on terminal - -Other styles are likely to appear in future releases. - -### Changing the appearance of your table - the hard way - -If you want to display your table in a style other than one of the in-built styles -listed above, you'll have to set things up the hard way. - -Don't worry, it's not really that hard! - -#### Style options - -PrettyTable has a number of style options which control various aspects of how tables -are displayed. You have the freedom to set each of these options individually to -whatever you prefer. The `set_style` method just does this automatically for you. - -The options are these: - -- `border` - A boolean option (must be `True` or `False`). Controls whether a border is - drawn inside and around the table. -- `preserve_internal_border` - A boolean option (must be `True` or `False`). Controls - whether borders are still drawn within the table even when `border=False`. -- `header` - A boolean option (must be `True` or `False`). Controls whether the first - row of the table is a header showing the names of all the fields. -- `hrules` - Controls printing of horizontal rules after rows. Allowed values: `FRAME`, - `HEADER`, `ALL`, `NONE` - note that these are variables defined inside the - `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. -- `vrules` - Controls printing of vertical rules between columns. Allowed values: - `FRAME`, `ALL`, `NONE`. -- `int_format` - A string which controls the way integer data is printed. This works - like: `print("%<int_format>d" % data)` -- `float_format` - A string which controls the way floating point data is printed. This - works like: `print("%<float_format>f" % data)` -- `custom_format` - A Dictionary of field and callable. This allows you to set any - format you want `pf.custom_format["my_col_int"] = ()lambda f, v: f"{v:,}"`. The type - of the callable if `callable[[str, Any], str]` -- `padding_width` - Number of spaces on either side of column data (only used if left - and right paddings are `None`). -- `left_padding_width` - Number of spaces on left-hand side of column data. -- `right_padding_width` - Number of spaces on right-hand side of column data. -- `vertical_char` - Single character string used to draw vertical lines. Default is `|`. -- `horizontal_char` - Single character string used to draw horizontal lines. Default is - `-`. -- `_horizontal_align_char` - single character string used to indicate column alignment - in horizontal lines. Default is `:` for Markdown, otherwise `None`. -- `junction_char` - Single character string used to draw line junctions. Default is `+`. -- `top_junction_char` - single character string used to draw top line junctions. Default - is `junction_char`. -- `bottom_junction_char` - single character string used to draw bottom line junctions. - Default is `junction_char`. -- `right_junction_char` - single character string used to draw right line junctions. - Default is `junction_char`. -- `left_junction_char` - single character string used to draw left line junctions. - Default is `junction_char`. -- `top_right_junction_char` - single character string used to draw top-right line - junctions. Default is `junction_char`. -- `top_left_junction_char` - single character string used to draw top-left line - junctions. Default is `junction_char`. -- `bottom_right_junction_char` - single character string used to draw bottom-right line - junctions. Default is `junction_char` -- `bottom_left_junction_char` - single character string used to draw bottom-left line - junctions. Default is `junction_char`. - -You can set the style options to your own settings in two ways: - -#### Setting style options for the long term - -If you want to print your table with a different style several times, you can set your -option for the long term just by changing the appropriate attributes. If you never want -your tables to have borders you can do this: - -```python -x.border = False -print(x) -print(x) -print(x) -``` - -Neither of the 3 tables printed by this will have borders, even if you do things like -add extra rows in between them. The lack of borders will last until you do: - -```python -x.border = True -``` - -to turn them on again. This sort of long-term setting is exactly how `set_style` works. -`set_style` just sets a bunch of attributes to pre-set values for you. - -Note that if you know what style options you want at the moment you are creating your -table, you can specify them using keyword arguments to the constructor. For example, the -following two code blocks are equivalent: - -```python -x = PrettyTable() -x.border = False -x.header = False -x.padding_width = 5 - -x = PrettyTable(border=False, header=False, padding_width=5) -``` - -#### Changing style options just once - -If you don't want to make long-term style changes by changing an attribute like in the -previous section, you can make changes that last for just one `get_string` by giving -those methods keyword arguments. To print two "normal" tables with one borderless table -between them, you could do this: - -```python -print(x) -print(x.get_string(border=False)) -print(x) -``` - -### Changing the appearance of your table - with _colors_! - -PrettyTable has the functionality of printing your table with ANSI color codes. This -includes support for most Windows versions through -[Colorama](https://pypi.org/project/colorama/). To get started, import the `ColorTable` -class instead of `PrettyTable`. - -```diff --from prettytable import PrettyTable -+from prettytable.colortable import ColorTable -``` - -The `ColorTable` class can be used the same as `PrettyTable`, but it adds an extra -property. You can now specify a custom _theme_ that will format your table with colors. - -```python -from prettytable.colortable import ColorTable, Themes - -x = ColorTable(theme=Themes.OCEAN) - -print(x) -``` - -#### Creating a custom theme - -The `Theme` class allows you to customize both the characters and colors used in your -table. - -| Argument | Description | -| ---------------------------------------------------------- | --------------------------------------------------------- | -| `default_color` | The color to use as default | -| `vertical_char`, `horizontal_char`, and `junction_char` | The characters used for creating the outline of the table | -| `vertical_color`, `horizontal_color`, and `junction_color` | The colors used to style each character. | - -> **Note:** Colors are formatted with the `Theme.format_code(s: str)` function. It -> accepts a string. If the string starts with an escape code (like `\x1b`) then it will -> return the given string. If the string is just whitespace, it will return `""`. If the -> string is a number (like `"34"`), it will automatically format it into an escape code. -> I recommend you look into the source code for more information. - -### Displaying your table in JSON - -PrettyTable will also print your tables in JSON, as a list of fields and an array of -rows. Just like in ASCII form, you can actually get a string representation - just use -`get_json_string()`. - -### Displaying your table in HTML form - -PrettyTable will also print your tables in HTML form, as `<table>`s. Just like in ASCII -form, you can actually get a string representation - just use `get_html_string()`. HTML -printing supports the `fields`, `start`, `end`, `sortby` and `reversesort` arguments in -exactly the same way as ASCII printing. - -#### Styling HTML tables - -By default, PrettyTable outputs HTML for "vanilla" tables. The HTML code is quite -simple. It looks like this: - -```html -<table> - <thead> - <tr> - <th>City name</th> - <th>Area</th> - <th>Population</th> - <th>Annual Rainfall</th> - </tr> - </thead> - <tbody> - <tr> - <td>Adelaide</td> - <td>1295</td> - <td>1158259</td> - <td>600.5</td> - </tr> - <tr> - <td>Brisbane</td> - <td>5905</td> - <td>1857594</td> - <td>1146.4</td> - ... - </tr> - </tbody> -</table> -``` - -If you like, you can ask PrettyTable to do its best to mimic the style options that your -table has set using inline CSS. This is done by giving a `format=True` keyword argument -to `get_html_string` method. Note that if you _always_ want to print formatted HTML you -can do: - -```python -x.format = True -``` - -and the setting will persist until you turn it off. - -Just like with ASCII tables, if you want to change the table's style for just one -`get_html_string` you can pass those methods' keyword arguments - exactly like `print` -and `get_string`. - -#### Setting HTML attributes - -You can provide a dictionary of HTML attribute name/value pairs to the `get_html_string` -method using the `attributes` keyword argument. This lets you specify common HTML -attributes like `id` and `class` that can be used for linking to your tables or -customising their appearance using CSS. For example: - -```python -print(x.get_html_string(attributes={"id":"my_table", "class":"red_table"})) -``` - -will print: - -```html -<table id="my_table" class="red_table"> - <thead> - <tr> - <th>City name</th> - <th>Area</th> - <th>Population</th> - <th>Annual Rainfall</th> - </tr> - </thead> - <tbody> - <tr> - ... ... ... - </tr> - </tbody> -</table> -``` - -### Miscellaneous things - -#### Copying a table - -You can call the `copy` method on a PrettyTable object without arguments to return an -identical independent copy of the table. - -If you want a copy of a PrettyTable object with just a subset of the rows, you can use -list slicing notation: - -```python -new_table = old_table[0:5] -``` - -## Contributing - -After editing files, use the [Black](https://github.com/psf/black) linter to auto-format -changed lines. - -```sh -python -m pip install black -black prettytable*.py -``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable.egg-info/SOURCES.txt new/prettytable-3.5.0/src/prettytable.egg-info/SOURCES.txt --- old/prettytable-3.4.1/src/prettytable.egg-info/SOURCES.txt 2022-09-02 15:33:03.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,33 +0,0 @@ -.coveragerc -.gitignore -.pre-commit-config.yaml -CHANGELOG.md -CODE_OF_CONDUCT.md -CONTRIBUTING.md -COPYING -README.md -RELEASING.md -setup.cfg -setup.py -tox.ini -.github/dependabot.yml -.github/labels.yml -.github/release-drafter.yml -.github/ISSUE_TEMPLATE/bug_report.md -.github/ISSUE_TEMPLATE/feature_request.md -.github/workflows/labels.yml -.github/workflows/lint.yml -.github/workflows/release-drafter.yml -.github/workflows/release.yml -.github/workflows/require-pr-label.yml -.github/workflows/test.yml -src/prettytable/__init__.py -src/prettytable/colortable.py -src/prettytable/prettytable.py -src/prettytable.egg-info/PKG-INFO -src/prettytable.egg-info/SOURCES.txt -src/prettytable.egg-info/dependency_links.txt -src/prettytable.egg-info/requires.txt -src/prettytable.egg-info/top_level.txt -tests/test_colortable.py -tests/test_prettytable.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable.egg-info/dependency_links.txt new/prettytable-3.5.0/src/prettytable.egg-info/dependency_links.txt --- old/prettytable-3.4.1/src/prettytable.egg-info/dependency_links.txt 2022-09-02 15:33:03.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable.egg-info/requires.txt new/prettytable-3.5.0/src/prettytable.egg-info/requires.txt --- old/prettytable-3.4.1/src/prettytable.egg-info/requires.txt 2022-09-02 15:33:03.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable.egg-info/requires.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,9 +0,0 @@ -wcwidth - -[:python_version < "3.8"] -importlib-metadata - -[tests] -pytest -pytest-cov -pytest-lazy-fixture diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/src/prettytable.egg-info/top_level.txt new/prettytable-3.5.0/src/prettytable.egg-info/top_level.txt --- old/prettytable-3.4.1/src/prettytable.egg-info/top_level.txt 2022-09-02 15:33:03.000000000 +0200 +++ new/prettytable-3.5.0/src/prettytable.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -prettytable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/tests/test_colortable.py new/prettytable-3.5.0/tests/test_colortable.py --- old/prettytable-3.4.1/tests/test_colortable.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/tests/test_colortable.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from prettytable import PrettyTable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/tests/test_prettytable.py new/prettytable-3.5.0/tests/test_prettytable.py --- old/prettytable-3.4.1/tests/test_prettytable.py 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/tests/test_prettytable.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,9 +1,11 @@ +from __future__ import annotations + import datetime as dt import io import random import sqlite3 from math import e, pi, sqrt -from typing import Any, List +from typing import Any import pytest @@ -861,7 +863,7 @@ ], ) def test_break_line_ASCII( - self, rows: List[List[Any]], hrule: int, expected_result: str + self, rows: list[list[Any]], hrule: int, expected_result: str ): t = PrettyTable(["Field 1", "Field 2"]) for row in rows: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prettytable-3.4.1/tox.ini new/prettytable-3.5.0/tox.ini --- old/prettytable-3.4.1/tox.ini 2022-09-02 15:32:45.000000000 +0200 +++ new/prettytable-3.5.0/tox.ini 2020-02-02 01:00:00.000000000 +0100 @@ -2,6 +2,7 @@ envlist = lint py{py3, 311, 310, 39, 38, 37} +isolated_build = true [testenv] passenv =
