From 278785209f64ee585687d3553ffe9ba445711479 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:54:37 -0600 Subject: [PATCH 01/11] [pre-commit.ci] pre-commit autoupdate (#110) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cea686..b669533 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black name: Running black in all files. From c6735c13799cbab3edabd7915f8313221476b681 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:36:05 -0600 Subject: [PATCH 02/11] [pre-commit.ci] pre-commit autoupdate (#111) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b669533..66571a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: name: Running isort in all files. - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-ast name: Check if python files are valid syntax for the ast parser From 32a7b6f2cf985bfcb7c774fa3c12f479b4a08016 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 20 Oct 2023 10:37:09 -0600 Subject: [PATCH 03/11] fix: Prevent text wrapping when already within width (#113) --- table2ascii/table_to_ascii.py | 19 ++++++++++++------- tests/test_convert.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/table2ascii/table_to_ascii.py b/table2ascii/table_to_ascii.py index dd092e2..65dfb8d 100644 --- a/table2ascii/table_to_ascii.py +++ b/table2ascii/table_to_ascii.py @@ -130,6 +130,11 @@ def __determine_alignments( return list(alignments) + def __widest_line(self, value: SupportsStr) -> int: + """Returns the width of the longest line in a multi-line string""" + text = str(value) + return max(self.__str_width(line) for line in text.splitlines()) if len(text) else 0 + def __auto_column_widths(self) -> list[int]: """Get the minimum number of characters needed for the values in each column in the table with 1 space of padding on each side. @@ -138,18 +143,13 @@ def __auto_column_widths(self) -> list[int]: The minimum number of characters needed for each column """ - def widest_line(value: SupportsStr) -> int: - """Returns the width of the longest line in a multi-line string""" - text = str(value) - return max(self.__str_width(line) for line in text.splitlines()) if len(text) else 0 - def get_column_width(row: Sequence[SupportsStr], column: int) -> int: """Get the width of a cell in a column""" value = row[column] next_value = row[column + 1] if column < self.__columns - 1 else None if value is Merge.LEFT or next_value is Merge.LEFT: return 0 - return widest_line(value) + return self.__widest_line(value) column_widths = [] # get the width necessary for each column @@ -306,7 +306,12 @@ def __wrap_long_lines_in_merged_cells( if row[other_col_index] is not Merge.LEFT: break merged_width += self.__column_widths[other_col_index] + len(column_separator) - cell = textwrap.fill(str(cell), merged_width - self.__cell_padding * 2) + cell = str(cell) + # if the text is too wide, wrap it + inner_cell_width = merged_width - self.__cell_padding * 2 + if self.__widest_line(cell) > inner_cell_width: + cell = textwrap.fill(cell, inner_cell_width) + # add the wrapped cell to the row wrapped_row.append(cell) return wrapped_row diff --git a/tests/test_convert.py b/tests/test_convert.py index 3030cd6..d510a1a 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -305,3 +305,22 @@ def test_east_asian_wide_characters_and_zero_width_no_wcwidth(): "╚════╩═══════════════╝" ) assert text == expected + + +def test_multiline_cells_with_wrappable_lines(): + text = t2a( + header=["Test"], + body=[["Line One...\nSecond Line...\nLineNumThree\nLineFour\nFive FinalLine"]], + ) + expected = ( + "╔════════════════╗\n" + "║ Test ║\n" + "╟────────────────╢\n" + "║ Line One... ║\n" + "║ Second Line... ║\n" + "║ LineNumThree ║\n" + "║ LineFour ║\n" + "║ Five FinalLine ║\n" + "╚════════════════╝" + ) + assert text == expected From 3fe8b5c732eb65047c9547ee2ce4361701480091 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Fri, 20 Oct 2023 10:42:54 -0600 Subject: [PATCH 04/11] chore: bump to version 1.1.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e7343bd..267f35a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "table2ascii" -version = "1.1.2" +version = "1.1.3" authors = [{name = "Jonah Lawrence", email = "jonah@freshidea.com"}] description = "Convert 2D Python lists into Unicode/ASCII tables" readme = "README.md" From ed3f1425282b1e431a3381f5c6e87b7503276d30 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 23:43:38 -0600 Subject: [PATCH 05/11] [pre-commit.ci] pre-commit autoupdate (#114) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66571a9..0c735a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black name: Running black in all files. From d2107a1065eee960ea1a9c5f386c3bf5def2a367 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:40:15 -0800 Subject: [PATCH 06/11] [pre-commit.ci] pre-commit autoupdate (#115) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c735a2..9421020 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black name: Running black in all files. From a0d5d1fe0d56f3f4e6eaac284d434bc5b79b519d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:27:34 +0200 Subject: [PATCH 07/11] [pre-commit.ci] pre-commit autoupdate (#116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.11.0 → 23.12.1](https://github.com/psf/black/compare/23.11.0...23.12.1) - [github.com/pycqa/isort: 5.12.0 → 5.13.2](https://github.com/pycqa/isort/compare/5.12.0...5.13.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9421020..0a4da44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,13 +6,13 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black name: Running black in all files. - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["--profile", "black", "--extend-skip", "table2ascii"] From 66ecd7f3423179754890f3c77ff9bc8c272243d3 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Wed, 7 Aug 2024 15:13:26 +0300 Subject: [PATCH 08/11] docs: Lock <5 dependent sphinx extension versions (#119) --- pyproject.toml | 7 ++++++- table2ascii/exceptions.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 267f35a..c76ef8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,12 +46,17 @@ dependencies = [ [project.optional-dependencies] docs = [ "enum-tools", - "sphinx", + "sphinx>=4.0.0,<5", "sphinx-autobuild", "sphinx-toolbox", "sphinxcontrib_trio", "sphinxext-opengraph", "sphinx-book-theme==0.3.3", + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", ] dev = [ "mypy>=0.982,<2", diff --git a/table2ascii/exceptions.py b/table2ascii/exceptions.py index b4b6314..cefecf9 100644 --- a/table2ascii/exceptions.py +++ b/table2ascii/exceptions.py @@ -40,7 +40,7 @@ class FooterColumnCountMismatchError(ColumnCountMismatchError): This class is a subclass of :class:`ColumnCountMismatchError`. Attributes: - footer (:class:`Sequence `\ [:class:`SupportsStr`]): + footer (:class:`Sequence ` [:class:`SupportsStr`]): The footer that caused the error expected_columns (:class:`int`): The number of columns that were expected """ @@ -64,10 +64,10 @@ class BodyColumnCountMismatchError(ColumnCountMismatchError): This class is a subclass of :class:`ColumnCountMismatchError`. Attributes: - body (:class:`Sequence `\ [\ :class:`Sequence `\ [:class:`SupportsStr`]]): + body (:class:`Sequence ` [ :class:`Sequence ` [:class:`SupportsStr`]]): The body that caused the error expected_columns (:class:`int`): The number of columns that were expected - first_invalid_row (:class:`Sequence `\ [:class:`SupportsStr`]): + first_invalid_row (:class:`Sequence ` [:class:`SupportsStr`]): The first row with an invalid column count """ @@ -93,7 +93,7 @@ class AlignmentCountMismatchError(ColumnCountMismatchError): This class is a subclass of :class:`ColumnCountMismatchError`. Attributes: - alignments (:class:`Sequence `\ [:class:`Alignment`]): + alignments (:class:`Sequence ` [:class:`Alignment`]): The alignments that caused the error expected_columns (:class:`int`): The number of columns that were expected """ @@ -117,7 +117,7 @@ class ColumnWidthsCountMismatchError(ColumnCountMismatchError): This class is a subclass of :class:`ColumnCountMismatchError`. Attributes: - column_widths (:class:`Sequence `\ [:data:`Optional `\ [:class:`int`]]): + column_widths (:class:`Sequence ` [:data:`Optional ` [:class:`int`]]): The column widths that caused the error expected_columns (:class:`int`): The number of columns that were expected """ From eab1097778f565b81a8c35d2aac3f8835463ea39 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:15:14 +0300 Subject: [PATCH 09/11] [pre-commit.ci] pre-commit autoupdate (#118) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jonah Lawrence --- .pre-commit-config.yaml | 4 ++-- table2ascii/__init__.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a4da44..f7bfe56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.8.0 hooks: - id: black name: Running black in all files. @@ -19,7 +19,7 @@ repos: name: Running isort in all files. - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-ast name: Check if python files are valid syntax for the ast parser diff --git a/table2ascii/__init__.py b/table2ascii/__init__.py index bc53a37..f521f0e 100644 --- a/table2ascii/__init__.py +++ b/table2ascii/__init__.py @@ -1,6 +1,7 @@ """ table2ascii - Library for converting 2D Python lists to fancy ASCII/Unicode tables """ + import sys from typing import TYPE_CHECKING From 1b016d6638e37a43270222f442da772078ecec22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:16:22 +0300 Subject: [PATCH 10/11] chore(deps-dev): update pytest requirement from <8,>=6.0.0 to >=6.0.0,<9 (#117) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c76ef8f..f98d644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ dev = [ "mypy>=0.982,<2", "pre-commit>=2.0.0,<4", "pyright>=1.0.0,<2", - "pytest>=6.0.0,<8", + "pytest>=6.0.0,<9", "slotscheck>=0.1.0,<1", "taskipy>=1.0.0,<2", "tox>=3.0.0,<5", From fb4f33c868974798df90d199d0495fe2ab72d428 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:25:23 +0300 Subject: [PATCH 11/11] chore(deps): update pre-commit requirement from <4,>=2.0.0 to >=2.0.0,<5 (#126) Updates the requirements on [pre-commit](https://github.com/pre-commit/pre-commit) to permit the latest version. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v2.0.0...v4.0.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f98d644..132658f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ docs = [ ] dev = [ "mypy>=0.982,<2", - "pre-commit>=2.0.0,<4", + "pre-commit>=2.0.0,<5", "pyright>=1.0.0,<2", "pytest>=6.0.0,<9", "slotscheck>=0.1.0,<1", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy