aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prettytable
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-07-27 08:03:29 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-07-27 08:12:05 +0300
commitfe1a7ca8bcac9c41fe972d15f5aebce436b681de (patch)
tree3b28fcdc54dbd8cc24534991a660a56f8cd068c5 /contrib/python/prettytable
parent58ee0112394bf094049e31802f591067f96a4ed9 (diff)
downloadydb-fe1a7ca8bcac9c41fe972d15f5aebce436b681de.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/prettytable')
-rw-r--r--contrib/python/prettytable/py3/.dist-info/METADATA56
-rw-r--r--contrib/python/prettytable/py3/README.md52
-rw-r--r--contrib/python/prettytable/py3/prettytable/prettytable.py62
-rw-r--r--contrib/python/prettytable/py3/tests/test_colortable.py63
-rw-r--r--contrib/python/prettytable/py3/tests/test_prettytable.py413
-rw-r--r--contrib/python/prettytable/py3/ya.make2
6 files changed, 444 insertions, 204 deletions
diff --git a/contrib/python/prettytable/py3/.dist-info/METADATA b/contrib/python/prettytable/py3/.dist-info/METADATA
index 6b15eb6252..47a7f8e093 100644
--- a/contrib/python/prettytable/py3/.dist-info/METADATA
+++ b/contrib/python/prettytable/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.3
Name: prettytable
-Version: 3.10.0
+Version: 3.10.2
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
@@ -497,32 +497,32 @@ whatever you prefer. The `set_style` method just does this automatically for you
The options are:
-| Option | Details |
-| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `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`. |
-| `HEADER`, `ALL`, `NONE` | 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: `\|`. |
-| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
-| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
-| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
-| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
-| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
-| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
-| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
-| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
-| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
-| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
-| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
+| Option | Details |
+| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `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`. |
+| `HEADER`, `ALL`, `NONE` | 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 is `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: `\|`. |
+| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
+| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
+| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
+| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
+| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
+| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
+| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
+| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
+| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
+| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
+| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
You can set the style options to your own settings in two ways:
diff --git a/contrib/python/prettytable/py3/README.md b/contrib/python/prettytable/py3/README.md
index cc32e6e2e4..aa442709f4 100644
--- a/contrib/python/prettytable/py3/README.md
+++ b/contrib/python/prettytable/py3/README.md
@@ -465,32 +465,32 @@ whatever you prefer. The `set_style` method just does this automatically for you
The options are:
-| Option | Details |
-| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `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`. |
-| `HEADER`, `ALL`, `NONE` | 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: `\|`. |
-| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
-| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
-| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
-| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
-| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
-| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
-| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
-| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
-| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
-| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
-| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
+| Option | Details |
+| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `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`. |
+| `HEADER`, `ALL`, `NONE` | 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 is `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: `\|`. |
+| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
+| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
+| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
+| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
+| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
+| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
+| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
+| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
+| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
+| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
+| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
You can set the style options to your own settings in two ways:
diff --git a/contrib/python/prettytable/py3/prettytable/prettytable.py b/contrib/python/prettytable/py3/prettytable/prettytable.py
index df1cb86ab3..62a1df1df2 100644
--- a/contrib/python/prettytable/py3/prettytable/prettytable.py
+++ b/contrib/python/prettytable/py3/prettytable/prettytable.py
@@ -135,6 +135,7 @@ class PrettyTable:
self.int_format = {}
self.float_format = {}
self.custom_format = {}
+ self._style = None
if field_names:
self.field_names = field_names
@@ -1270,6 +1271,7 @@ class PrettyTable:
##############################
def set_style(self, style) -> None:
+ self._style = style
if style == DEFAULT:
self._set_default_style()
elif style == MSWORD_FRIENDLY:
@@ -1550,21 +1552,26 @@ class PrettyTable:
def _format_value(self, field, value):
if isinstance(value, int) and field in self._int_format:
- return ("%%%sd" % self._int_format[field]) % value
+ return (f"%{self._int_format[field]}d") % value
elif isinstance(value, float) and field in self._float_format:
- return ("%%%sf" % self._float_format[field]) % value
+ return (f"%{self._float_format[field]}f") % value
formatter = self._custom_format.get(field, (lambda f, v: str(v)))
return formatter(field, value)
def _compute_table_width(self, options):
- table_width = 2 if options["vrules"] in (FRAME, ALL) else 0
+ if options["vrules"] == FRAME:
+ table_width = 2
+ if options["vrules"] == ALL:
+ table_width = 1
+ else:
+ table_width = 0
per_col_padding = sum(self._get_padding_widths(options))
for index, fieldname in enumerate(self.field_names):
if not options["fields"] or (
options["fields"] and fieldname in options["fields"]
):
- table_width += self._widths[index] + per_col_padding
+ table_width += self._widths[index] + per_col_padding + 1
return table_width
def _compute_widths(self, rows, options) -> None:
@@ -1588,23 +1595,33 @@ class PrettyTable:
widths[index] = max(widths[index], _get_size(value)[0])
if fieldname in self.min_width:
widths[index] = max(widths[index], self.min_width[fieldname])
+
+ if self._style == MARKDOWN:
+ # Markdown needs at least one hyphen in the divider
+ if self._align[fieldname] in ("l", "r"):
+ min_width = 1
+ else: # "c"
+ min_width = 3
+ widths[index] = max(min_width, widths[index])
+
self._widths = widths
+ per_col_padding = sum(self._get_padding_widths(options))
# Are we exceeding max_table_width?
if self._max_table_width:
table_width = self._compute_table_width(options)
if table_width > self._max_table_width:
# Shrink widths in proportion
- scale = 1.0 * self._max_table_width / table_width
- widths = [int(w * scale) for w in widths]
- self._widths = widths
+ markup_chars = per_col_padding * len(widths) + len(widths) - 1
+ scale = (self._max_table_width - markup_chars) / (
+ table_width - markup_chars
+ )
+ self._widths = [max(1, int(w * scale)) for w in widths]
# Are we under min_table_width or title width?
if self._min_table_width or options["title"]:
if options["title"]:
- title_width = len(options["title"]) + sum(
- self._get_padding_widths(options)
- )
+ title_width = len(options["title"]) + per_col_padding
if options["vrules"] in (FRAME, ALL):
title_width += 2
else:
@@ -1619,9 +1636,7 @@ class PrettyTable:
borders = 0
# Subtract padding for each column and borders
- min_width -= (
- sum([sum(self._get_padding_widths(options)) for _ in widths]) + borders
- )
+ min_width -= sum([per_col_padding for _ in widths]) + borders
# What is being scaled is content so we sum column widths
content_width = sum(widths) or 1
@@ -1872,7 +1887,10 @@ class PrettyTable:
)
bits.append(endpoint)
title = " " * lpad + title + " " * rpad
- bits.append(self._justify(title, len(self._hrule) - 2, "c"))
+ lpad, rpad = self._get_padding_widths(options)
+ sum_widths = sum([n + lpad + rpad + 1 for n in self._widths])
+
+ bits.append(self._justify(title, sum_widths - 1, "c"))
bits.append(endpoint)
lines.append("".join(bits))
return "\n".join(lines)
@@ -1884,9 +1902,11 @@ class PrettyTable:
if options["hrules"] in (ALL, FRAME):
bits.append(self._stringify_hrule(options, "top_"))
if options["title"] and options["vrules"] in (ALL, FRAME):
+ left_j_len = len(self.left_junction_char)
+ right_j_len = len(self.right_junction_char)
bits[-1] = (
self.left_junction_char
- + bits[-1][1:-1]
+ + bits[-1][left_j_len:-right_j_len]
+ self.right_junction_char
)
bits.append("\n")
@@ -2178,7 +2198,9 @@ class PrettyTable:
if options["fields"] and field not in options["fields"]:
continue
lines.append(
- " <th>%s</th>" % escape(field).replace("\n", linebreak)
+ " <th>{}</th>".format(
+ escape(field).replace("\n", linebreak)
+ )
)
lines.append(" </tr>")
lines.append(" </thead>")
@@ -2193,7 +2215,9 @@ class PrettyTable:
if options["fields"] and field not in options["fields"]:
continue
lines.append(
- " <td>%s</td>" % escape(datum).replace("\n", linebreak)
+ " <td>{}</td>".format(
+ escape(datum).replace("\n", linebreak)
+ )
)
lines.append(" </tr>")
lines.append(" </tbody>")
@@ -2341,7 +2365,7 @@ class PrettyTable:
alignments = "".join([self._align[field] for field in wanted_fields])
- begin_cmd = "\\begin{tabular}{%s}" % alignments
+ begin_cmd = f"\\begin{{tabular}}{{{alignments}}}"
lines.append(begin_cmd)
# Headers
@@ -2383,7 +2407,7 @@ class PrettyTable:
if options["border"] and options["vrules"] in [ALL, FRAME]:
alignment_str = "|" + alignment_str + "|"
- begin_cmd = "\\begin{tabular}{%s}" % alignment_str
+ begin_cmd = f"\\begin{{tabular}}{{{alignment_str}}}"
lines.append(begin_cmd)
if options["border"] and options["hrules"] in [ALL, FRAME]:
lines.append("\\hline")
diff --git a/contrib/python/prettytable/py3/tests/test_colortable.py b/contrib/python/prettytable/py3/tests/test_colortable.py
index 1e057e2afc..4668ed54dd 100644
--- a/contrib/python/prettytable/py3/tests/test_colortable.py
+++ b/contrib/python/prettytable/py3/tests/test_colortable.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import pytest
from prettytable import PrettyTable
-from prettytable.colortable import RESET_CODE, ColorTable, Theme
+from prettytable.colortable import RESET_CODE, ColorTable, Theme, Themes
@pytest.fixture
@@ -94,3 +94,64 @@ class TestFormatCode:
def test_multiple(self) -> None:
assert Theme.format_code("30;42") == "\x1b[30;42m"
assert Theme.format_code("\x1b[30;42m") == "\x1b[30;42m"
+
+
+class TestColorTableRendering:
+ """Tests for the rendering of the color table
+
+ Methods
+ -------
+ test_color_table_rendering
+ Tests the color table rendering using the default alignment (`'c'`)
+ """
+
+ def test_color_table_rendering(self) -> None:
+ """Tests the color table rendering using the default alignment (`'c'`)"""
+ chars = {
+ "+": "\x1b[36m+\x1b[0m\x1b[96m",
+ "-": "\x1b[34m-\x1b[0m\x1b[96m",
+ "|": "\x1b[34m|\x1b[0m\x1b[96m",
+ " ": " ",
+ }
+
+ plus = chars.get("+")
+ minus = chars.get("-")
+ pipe = chars.get("|")
+ space = chars.get(" ")
+
+ # +-----------------------+
+ # | Efforts |
+ # +---+---+---+---+---+---+
+ # | A | B | C | D | E | f |
+ # +---+---+---+---+---+---+
+ # | 1 | 2 | 3 | 4 | 5 | 6 |
+ # +---+---+---+---+---+---+
+
+ header = (
+ plus + minus * 23 + plus,
+ pipe + space * 8 + "Efforts" + space * 8 + pipe,
+ (plus + minus * 3) * 6 + plus,
+ )
+
+ body = (
+ "".join(pipe + space + char + space for char in "ABCDEF") + pipe,
+ (plus + minus * 3) * 6 + plus,
+ "".join(pipe + space + char + space for char in "123456") + pipe,
+ (plus + minus * 3) * 6 + plus,
+ )
+
+ header_str = str("\n".join(header))
+ body_str = str("\n".join(body))
+
+ table = ColorTable(
+ ("A", "B", "C", "D", "E", "F"),
+ theme=Themes.OCEAN,
+ )
+
+ table.title = "Efforts"
+ table.add_row([1, 2, 3, 4, 5, 6])
+
+ expected = header_str + "\n" + body_str + "\x1b[0m"
+ result = str(table)
+
+ assert expected == result
diff --git a/contrib/python/prettytable/py3/tests/test_prettytable.py b/contrib/python/prettytable/py3/tests/test_prettytable.py
index 214c5c084e..9b51e4a2ce 100644
--- a/contrib/python/prettytable/py3/tests/test_prettytable.py
+++ b/contrib/python/prettytable/py3/tests/test_prettytable.py
@@ -41,11 +41,11 @@ def test_version() -> None:
def helper_table(rows: int = 3) -> PrettyTable:
- table = PrettyTable(["Field 1", "Field 2", "Field 3"])
+ table = PrettyTable(["", "Field 1", "Field 2", "Field 3"])
v = 1
for row in range(rows):
# Some have spaces, some not, to help test padding columns of different widths
- table.add_row([f"value {v}", f"value{v+1}", f"value{v+2}"])
+ table.add_row([v, f"value {v}", f"value{v+1}", f"value{v+2}"])
v += 3
return table
@@ -998,21 +998,25 @@ class TestJSONOutput:
== """
[
[
+ "",
"Field 1",
"Field 2",
"Field 3"
],
{
+ "": 1,
"Field 1": "value 1",
"Field 2": "value2",
"Field 3": "value3"
},
{
+ "": 4,
"Field 1": "value 4",
"Field 2": "value5",
"Field 3": "value6"
},
{
+ "": 7,
"Field 1": "value 7",
"Field 2": "value8",
"Field 3": "value9"
@@ -1025,9 +1029,9 @@ class TestJSONOutput:
result = t.get_json_string(header=False, indent=None, separators=(",", ":"))
assert (
result
- == """[{"Field 1":"value 1","Field 2":"value2","Field 3":"value3"},"""
- """{"Field 1":"value 4","Field 2":"value5","Field 3":"value6"},"""
- """{"Field 1":"value 7","Field 2":"value8","Field 3":"value9"}]"""
+ == """[{"":1,"Field 1":"value 1","Field 2":"value2","Field 3":"value3"},"""
+ """{"":4,"Field 1":"value 4","Field 2":"value5","Field 3":"value6"},"""
+ """{"":7,"Field 1":"value 7","Field 2":"value8","Field 3":"value9"}]"""
)
@@ -1041,6 +1045,7 @@ class TestHtmlOutput:
<table>
<thead>
<tr>
+ <th></th>
<th>Field 1</th>
<th>Field 2</th>
<th>Field 3</th>
@@ -1048,16 +1053,19 @@ class TestHtmlOutput:
</thead>
<tbody>
<tr>
+ <td>1</td>
<td>value 1</td>
<td>value2</td>
<td>value3</td>
</tr>
<tr>
+ <td>4</td>
<td>value 4</td>
<td>value5</td>
<td>value6</td>
</tr>
<tr>
+ <td>7</td>
<td>value 7</td>
<td>value8</td>
<td>value9</td>
@@ -1076,6 +1084,7 @@ class TestHtmlOutput:
<table frame="box" rules="cols">
<thead>
<tr>
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 2</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 3</th>
@@ -1083,16 +1092,19 @@ class TestHtmlOutput:
</thead>
<tbody>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value2</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value3</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value5</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value6</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value8</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value9</td>
@@ -1113,6 +1125,7 @@ class TestHtmlOutput:
<caption>Title &amp; Title</caption>
<thead>
<tr>
+ <th></th>
<th>Field 1</th>
<th>Field 2</th>
<th>Field 3</th>
@@ -1120,16 +1133,19 @@ class TestHtmlOutput:
</thead>
<tbody>
<tr>
+ <td>1</td>
<td>value 1</td>
<td>value2</td>
<td>value3</td>
</tr>
<tr>
+ <td>4</td>
<td>value 4</td>
<td>value5</td>
<td>value6</td>
</tr>
<tr>
+ <td>7</td>
<td>value 7</td>
<td>value8</td>
<td>value9</td>
@@ -1152,6 +1168,7 @@ class TestHtmlOutput:
<caption>Title &amp; Title</caption>
<thead>
<tr>
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 2</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 3</th>
@@ -1159,16 +1176,19 @@ class TestHtmlOutput:
</thead>
<tbody>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value2</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value3</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value5</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value6</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value8</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value9</td>
@@ -1337,93 +1357,95 @@ class TestStyle:
pytest.param(
DEFAULT,
"""
-+---------+---------+---------+
-| Field 1 | Field 2 | Field 3 |
-+---------+---------+---------+
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
-+---------+---------+---------+
++---+---------+---------+---------+
+| | Field 1 | Field 2 | Field 3 |
++---+---------+---------+---------+
+| 1 | value 1 | value2 | value3 |
+| 4 | value 4 | value5 | value6 |
+| 7 | value 7 | value8 | value9 |
++---+---------+---------+---------+
""",
id="DEFAULT",
),
pytest.param(
- MARKDOWN,
+ MARKDOWN, # TODO fix
"""
-| Field 1 | Field 2 | Field 3 |
-| :-----: | :-----: | :-----: |
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
+| | Field 1 | Field 2 | Field 3 |
+| :-: | :-----: | :-----: | :-----: |
+| 1 | value 1 | value2 | value3 |
+| 4 | value 4 | value5 | value6 |
+| 7 | value 7 | value8 | value9 |
""",
id="MARKDOWN",
),
pytest.param(
MSWORD_FRIENDLY,
"""
-| Field 1 | Field 2 | Field 3 |
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
+| | Field 1 | Field 2 | Field 3 |
+| 1 | value 1 | value2 | value3 |
+| 4 | value 4 | value5 | value6 |
+| 7 | value 7 | value8 | value9 |
""",
id="MSWORD_FRIENDLY",
),
pytest.param(
ORGMODE,
"""
-|---------+---------+---------|
-| Field 1 | Field 2 | Field 3 |
-|---------+---------+---------|
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
-|---------+---------+---------|
+|---+---------+---------+---------|
+| | Field 1 | Field 2 | Field 3 |
+|---+---------+---------+---------|
+| 1 | value 1 | value2 | value3 |
+| 4 | value 4 | value5 | value6 |
+| 7 | value 7 | value8 | value9 |
+|---+---------+---------+---------|
""",
id="ORGMODE",
),
pytest.param(
PLAIN_COLUMNS,
- "Field 1 Field 2 Field 3 \n"
- "value 1 value2 value3 \n"
- "value 4 value5 value6 \n"
- "value 7 value8 value9",
+ """
+ Field 1 Field 2 Field 3
+1 value 1 value2 value3
+4 value 4 value5 value6
+7 value 7 value8 value9
+""", # noqa: W291
id="PLAIN_COLUMNS",
),
pytest.param(
RANDOM,
"""
-'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
-% value 1% value2% value3%
-'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
-% value 4% value5% value6%
-'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
-% value 7% value8% value9%
-'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
+'^^^^^'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
+% 1% value 1% value2% value3%
+'^^^^^'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
+% 4% value 4% value5% value6%
+'^^^^^'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
+% 7% value 7% value8% value9%
+'^^^^^'^^^^^^^^^^^'^^^^^^^^^^'^^^^^^^^^^'
""",
id="RANDOM",
),
pytest.param(
DOUBLE_BORDER,
"""
-╔═════════╦═════════╦═════════╗
-║ Field 1 ║ Field 2 ║ Field 3 ║
-╠═════════╬═════════╬═════════╣
-║ value 1 ║ value2 ║ value3 ║
-║ value 4 ║ value5 ║ value6 ║
-║ value 7 ║ value8 ║ value9 ║
-╚═════════╩═════════╩═════════╝
+╔═══╦═════════╦═════════╦═════════╗
+║ ║ Field 1 ║ Field 2 ║ Field 3 ║
+╠═══╬═════════╬═════════╬═════════╣
+║ 1 ║ value 1 ║ value2 ║ value3 ║
+║ 4 ║ value 4 ║ value5 ║ value6 ║
+║ 7 ║ value 7 ║ value8 ║ value9 ║
+╚═══╩═════════╩═════════╩═════════╝
""",
),
pytest.param(
SINGLE_BORDER,
"""
-┌─────────┬─────────┬─────────┐
-│ Field 1 │ Field 2 │ Field 3 │
-├─────────┼─────────┼─────────┤
-│ value 1 │ value2 │ value3 │
-│ value 4 │ value5 │ value6 │
-│ value 7 │ value8 │ value9 │
-└─────────┴─────────┴─────────┘
+┌───┬─────────┬─────────┬─────────┐
+│ │ Field 1 │ Field 2 │ Field 3 │
+├───┼─────────┼─────────┼─────────┤
+│ 1 │ value 1 │ value2 │ value3 │
+│ 4 │ value 4 │ value5 │ value6 │
+│ 7 │ value 7 │ value8 │ value9 │
+└───┴─────────┴─────────┴─────────┘
""",
),
],
@@ -1455,11 +1477,11 @@ class TestStyle:
pytest.param(
MARKDOWN,
"""
-| Align left | Align centre | Align right |
-| :----------| :----------: |-----------: |
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
+| l | c | r | Align left | Align centre | Align right |
+| :-| :-: |-: | :----------| :----------: |-----------: |
+| 1 | 2 | 3 | value 1 | value2 | value3 |
+| 4 | 5 | 6 | value 4 | value5 | value6 |
+| 7 | 8 | 9 | value 7 | value8 | value9 |
""",
id="MARKDOWN",
),
@@ -1467,14 +1489,19 @@ class TestStyle:
)
def test_style_align(self, style, expected) -> None:
# Arrange
- t = helper_table()
- t.field_names = ["Align left", "Align centre", "Align right"]
+ t = PrettyTable(["l", "c", "r", "Align left", "Align centre", "Align right"])
+ v = 1
+ for row in range(3):
+ # Some have spaces, some not, to help test padding columns of
+ # different widths
+ t.add_row([v, v + 1, v + 2, f"value {v}", f"value{v + 1}", f"value{v + 2}"])
+ v += 3
# Act
t.set_style(style)
- t.align["Align left"] = "l"
- t.align["Align centre"] = "c"
- t.align["Align right"] = "r"
+ t.align["l"] = t.align["Align left"] = "l"
+ t.align["c"] = t.align["Align centre"] = "c"
+ t.align["r"] = t.align["Align right"] = "r"
# Assert
result = t.get_string()
@@ -1485,15 +1512,15 @@ class TestCsvOutput:
def test_csv_output(self) -> None:
t = helper_table()
assert t.get_csv_string(delimiter="\t", header=False) == (
- "value 1\tvalue2\tvalue3\r\n"
- "value 4\tvalue5\tvalue6\r\n"
- "value 7\tvalue8\tvalue9\r\n"
+ "1\tvalue 1\tvalue2\tvalue3\r\n"
+ "4\tvalue 4\tvalue5\tvalue6\r\n"
+ "7\tvalue 7\tvalue8\tvalue9\r\n"
)
assert t.get_csv_string() == (
- "Field 1,Field 2,Field 3\r\n"
- "value 1,value2,value3\r\n"
- "value 4,value5,value6\r\n"
- "value 7,value8,value9\r\n"
+ ",Field 1,Field 2,Field 3\r\n"
+ "1,value 1,value2,value3\r\n"
+ "4,value 4,value5,value6\r\n"
+ "7,value 7,value8,value9\r\n"
)
@@ -1501,11 +1528,11 @@ class TestLatexOutput:
def test_latex_output(self) -> None:
t = helper_table()
assert t.get_latex_string() == (
- "\\begin{tabular}{ccc}\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ "\\begin{tabular}{cccc}\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\end{tabular}"
)
options = {"fields": ["Field 1", "Field 3"]}
@@ -1521,12 +1548,12 @@ class TestLatexOutput:
def test_latex_output_formatted(self) -> None:
t = helper_table()
assert t.get_latex_string(format=True) == (
- "\\begin{tabular}{|c|c|c|}\r\n"
+ "\\begin{tabular}{|c|c|c|c|}\r\n"
"\\hline\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\hline\r\n"
"\\end{tabular}"
)
@@ -1545,27 +1572,27 @@ class TestLatexOutput:
options = {"vrules": FRAME}
assert t.get_latex_string(format=True, **options) == (
- "\\begin{tabular}{|ccc|}\r\n"
+ "\\begin{tabular}{|cccc|}\r\n"
"\\hline\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\hline\r\n"
"\\end{tabular}"
)
options = {"hrules": ALL}
assert t.get_latex_string(format=True, **options) == (
- "\\begin{tabular}{|c|c|c|}\r\n"
+ "\\begin{tabular}{|c|c|c|c|}\r\n"
"\\hline\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
"\\hline\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
"\\hline\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
"\\hline\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\hline\r\n"
"\\end{tabular}"
)
@@ -1573,12 +1600,12 @@ class TestLatexOutput:
def test_latex_output_header(self) -> None:
t = helper_table()
assert t.get_latex_string(format=True, hrules=HEADER) == (
- "\\begin{tabular}{|c|c|c|}\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
+ "\\begin{tabular}{|c|c|c|c|}\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
"\\hline\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\end{tabular}"
)
@@ -1716,23 +1743,23 @@ def test_paginate() -> None:
# Arrange
t = helper_table(rows=7)
expected_page_1 = """
-+----------+---------+---------+
-| Field 1 | Field 2 | Field 3 |
-+----------+---------+---------+
-| value 1 | value2 | value3 |
-| value 4 | value5 | value6 |
-| value 7 | value8 | value9 |
-| value 10 | value11 | value12 |
-+----------+---------+---------+
++----+----------+---------+---------+
+| | Field 1 | Field 2 | Field 3 |
++----+----------+---------+---------+
+| 1 | value 1 | value2 | value3 |
+| 4 | value 4 | value5 | value6 |
+| 7 | value 7 | value8 | value9 |
+| 10 | value 10 | value11 | value12 |
++----+----------+---------+---------+
""".strip()
expected_page_2 = """
-+----------+---------+---------+
-| Field 1 | Field 2 | Field 3 |
-+----------+---------+---------+
-| value 13 | value14 | value15 |
-| value 16 | value17 | value18 |
-| value 19 | value20 | value21 |
-+----------+---------+---------+
++----+----------+---------+---------+
+| | Field 1 | Field 2 | Field 3 |
++----+----------+---------+---------+
+| 13 | value 13 | value14 | value15 |
+| 16 | value 16 | value17 | value18 |
+| 19 | value 19 | value20 | value21 |
++----+----------+---------+---------+
""".strip()
# Act
@@ -2008,17 +2035,141 @@ class TestMaxTableWidth:
table.max_table_width = 5
table.add_row([0])
+ # FIXME: Table is wider than table.max_table_width
assert (
table.get_string().strip()
== """
-+-----+
-| Fie |
-+-----+
-| 0 |
-+-----+
++----+
+| Fi |
++----+
+| 0 |
++----+
""".strip()
)
+ def test_max_table_width_wide(self) -> None:
+ table = PrettyTable()
+ table.max_table_width = 52
+ table.add_row(
+ [
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
+ "nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam "
+ "erat, sed diam voluptua",
+ ]
+ )
+
+ assert (
+ table.get_string().strip()
+ == """
++---+---+---+---+---+------------------------------+
+| F | F | F | F | F | Field 6 |
++---+---+---+---+---+------------------------------+
+| 0 | 0 | 0 | 0 | 0 | Lorem ipsum dolor sit amet, |
+| | | | | | consetetur sadipscing elitr, |
+| | | | | | sed diam nonumy eirmod |
+| | | | | | tempor invidunt ut labore et |
+| | | | | | dolore magna aliquyam erat, |
+| | | | | | sed diam voluptua |
++---+---+---+---+---+------------------------------+""".strip()
+ )
+
+ def test_max_table_width_wide2(self) -> None:
+ table = PrettyTable()
+ table.max_table_width = 70
+ table.add_row(
+ [
+ "Lorem",
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ",
+ "ipsum",
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ",
+ "dolor",
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ",
+ ]
+ )
+
+ assert (
+ table.get_string().strip()
+ == """
++---+-----------------+---+-----------------+---+-----------------+
+| F | Field 2 | F | Field 4 | F | Field 6 |
++---+-----------------+---+-----------------+---+-----------------+
+| L | Lorem ipsum | i | Lorem ipsum | d | Lorem ipsum |
+| o | dolor sit amet, | p | dolor sit amet, | o | dolor sit amet, |
+| r | consetetur | s | consetetur | l | consetetur |
+| e | sadipscing | u | sadipscing | o | sadipscing |
+| m | elitr, sed diam | m | elitr, sed diam | r | elitr, sed diam |
++---+-----------------+---+-----------------+---+-----------------+""".strip()
+ )
+
+ def test_max_table_width_wide_vrules_frame(self) -> None:
+ table = PrettyTable()
+ table.max_table_width = 52
+ table.vrules = FRAME
+ table.add_row(
+ [
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
+ "nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam "
+ "erat, sed diam voluptua",
+ ]
+ )
+
+ assert (
+ table.get_string().strip()
+ == """
++--------------------------------------------------+
+| F F F F F Field 6 |
++--------------------------------------------------+
+| 0 0 0 0 0 Lorem ipsum dolor sit amet, |
+| consetetur sadipscing elitr, |
+| sed diam nonumy eirmod |
+| tempor invidunt ut labore et |
+| dolore magna aliquyam erat, |
+| sed diam voluptua |
++--------------------------------------------------+""".strip()
+ )
+
+ def test_max_table_width_wide_vrules_none(self) -> None:
+ table = PrettyTable()
+ table.max_table_width = 52
+ table.vrules = NONE
+ table.add_row(
+ [
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
+ "nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam "
+ "erat, sed diam voluptua",
+ ]
+ )
+
+ assert (
+ table.get_string().strip()
+ == """
+----------------------------------------------------
+ F F F F F Field 6
+----------------------------------------------------
+ 0 0 0 0 0 Lorem ipsum dolor sit amet,
+ consetetur sadipscing elitr,
+ sed diam nonumy eirmod
+ tempor invidunt ut labore et
+ dolore magna aliquyam erat,
+ sed diam voluptua
+----------------------------------------------------""".strip() # noqa: W291
+ )
+
class TestRowEndSection:
def test_row_end_section(self) -> None:
@@ -2053,15 +2204,15 @@ class TestRowEndSection:
class TestClearing:
def test_clear_rows(self, row_prettytable: PrettyTable) -> None:
t = helper_table()
- t.add_row(["a", "b", "c"], divider=True)
+ t.add_row([0, "a", "b", "c"], divider=True)
t.clear_rows()
assert t.rows == []
assert t.dividers == []
- assert t.field_names == ["Field 1", "Field 2", "Field 3"]
+ assert t.field_names == ["", "Field 1", "Field 2", "Field 3"]
def test_clear(self, row_prettytable: PrettyTable) -> None:
t = helper_table()
- t.add_row(["a", "b", "c"], divider=True)
+ t.add_row([0, "a", "b", "c"], divider=True)
t.clear()
assert t.rows == []
assert t.dividers == []
@@ -2077,11 +2228,11 @@ class TestPreservingInternalBorders:
assert (
pt.get_string().strip()
== """
- Field 1 | Field 2 | Field 3
----------+---------+---------
- value 1 | value2 | value3
- value 4 | value5 | value6
- value 7 | value8 | value9
+ | Field 1 | Field 2 | Field 3
+---+---------+---------+---------
+ 1 | value 1 | value2 | value3
+ 4 | value 4 | value5 | value6
+ 7 | value 7 | value8 | value9
""".strip() # noqa: W291
)
@@ -2092,11 +2243,11 @@ class TestPreservingInternalBorders:
pt.preserve_internal_border = True
assert pt.get_latex_string().strip() == (
- "\\begin{tabular}{c|c|c}\r\n"
- "Field 1 & Field 2 & Field 3 \\\\\r\n"
- "value 1 & value2 & value3 \\\\\r\n"
- "value 4 & value5 & value6 \\\\\r\n"
- "value 7 & value8 & value9 \\\\\r\n"
+ "\\begin{tabular}{c|c|c|c}\r\n"
+ " & Field 1 & Field 2 & Field 3 \\\\\r\n"
+ "1 & value 1 & value2 & value3 \\\\\r\n"
+ "4 & value 4 & value5 & value6 \\\\\r\n"
+ "7 & value 7 & value8 & value9 \\\\\r\n"
"\\end{tabular}"
)
@@ -2112,6 +2263,7 @@ class TestPreservingInternalBorders:
<table rules="cols">
<thead>
<tr>
+ <th style="padding-left: 1em; padding-right: 1em; text-align: center"></th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 1</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 2</th>
<th style="padding-left: 1em; padding-right: 1em; text-align: center">Field 3</th>
@@ -2119,16 +2271,19 @@ class TestPreservingInternalBorders:
</thead>
<tbody>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 1</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value2</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value3</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 4</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value5</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value6</td>
</tr>
<tr>
+ <td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value 7</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value8</td>
<td style="padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top">value9</td>
diff --git a/contrib/python/prettytable/py3/ya.make b/contrib/python/prettytable/py3/ya.make
index 50b394fc53..c44b0c331b 100644
--- a/contrib/python/prettytable/py3/ya.make
+++ b/contrib/python/prettytable/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(3.10.0)
+VERSION(3.10.2)
LICENSE(BSD-3-Clause)