prettytable 3.10.1__tar.gz → 3.10.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prettytable-3.10.1 → prettytable-3.10.2}/.pre-commit-config.yaml +6 -7
- {prettytable-3.10.1 → prettytable-3.10.2}/PKG-INFO +27 -27
- {prettytable-3.10.1 → prettytable-3.10.2}/README.md +26 -26
- {prettytable-3.10.1 → prettytable-3.10.2}/pyproject.toml +32 -26
- {prettytable-3.10.1 → prettytable-3.10.2}/src/prettytable/prettytable.py +17 -8
- {prettytable-3.10.1 → prettytable-3.10.2}/tests/test_colortable.py +62 -1
- {prettytable-3.10.1 → prettytable-3.10.2}/.coveragerc +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/dependabot.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/labels.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/release-drafter.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/labels.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/lint.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/release-drafter.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/release.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/require-pr-label.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.github/workflows/test.yml +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/.gitignore +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/CHANGELOG.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/CODE_OF_CONDUCT.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/CONTRIBUTING.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/LICENSE +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/RELEASING.md +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/src/prettytable/__init__.py +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/src/prettytable/colortable.py +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/src/prettytable/py.typed +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/tests/test_prettytable.py +0 -0
- {prettytable-3.10.1 → prettytable-3.10.2}/tox.ini +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
repos:
|
|
2
2
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
-
rev: v0.
|
|
3
|
+
rev: v0.5.0
|
|
4
4
|
hooks:
|
|
5
5
|
- id: ruff
|
|
6
6
|
args: [--exit-non-zero-on-fix]
|
|
7
7
|
|
|
8
8
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
|
9
|
-
rev: 24.
|
|
9
|
+
rev: 24.4.2
|
|
10
10
|
hooks:
|
|
11
11
|
- id: black
|
|
12
12
|
|
|
13
13
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
14
|
-
rev: v4.
|
|
14
|
+
rev: v4.6.0
|
|
15
15
|
hooks:
|
|
16
16
|
- id: check-case-conflict
|
|
17
17
|
- id: check-merge-conflict
|
|
@@ -23,7 +23,7 @@ repos:
|
|
|
23
23
|
exclude: .github/ISSUE_TEMPLATE/bug_report.md|tests/test_prettytable.py
|
|
24
24
|
|
|
25
25
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
26
|
-
rev: v1.
|
|
26
|
+
rev: v1.10.1
|
|
27
27
|
hooks:
|
|
28
28
|
- id: mypy
|
|
29
29
|
additional_dependencies: [types-colorama, types-setuptools]
|
|
@@ -31,13 +31,12 @@ repos:
|
|
|
31
31
|
exclude: ^tests/
|
|
32
32
|
|
|
33
33
|
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
34
|
-
rev: 1.
|
|
34
|
+
rev: 2.1.3
|
|
35
35
|
hooks:
|
|
36
36
|
- id: pyproject-fmt
|
|
37
|
-
additional_dependencies: [tox]
|
|
38
37
|
|
|
39
38
|
- repo: https://github.com/abravalheri/validate-pyproject
|
|
40
|
-
rev: v0.
|
|
39
|
+
rev: v0.18
|
|
41
40
|
hooks:
|
|
42
41
|
- id: validate-pyproject
|
|
43
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: prettytable
|
|
3
|
-
Version: 3.10.
|
|
3
|
+
Version: 3.10.2
|
|
4
4
|
Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
|
|
5
5
|
Project-URL: Changelog, https://github.com/jazzband/prettytable/releases
|
|
6
6
|
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
|
|
|
497
497
|
|
|
498
498
|
The options are:
|
|
499
499
|
|
|
500
|
-
| Option | Details
|
|
501
|
-
| ---------------------------- |
|
|
502
|
-
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table.
|
|
503
|
-
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`.
|
|
504
|
-
| `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.
|
|
505
|
-
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`.
|
|
506
|
-
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc.
|
|
507
|
-
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`.
|
|
508
|
-
| `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`.
|
|
509
|
-
| `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`.
|
|
510
|
-
| `custom_format` | A dictionary of field and callable. This allows you to set any format you want `pf.custom_format["my_col_int"] =
|
|
511
|
-
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`).
|
|
512
|
-
| `left_padding_width` | Number of spaces on left-hand side of column data.
|
|
513
|
-
| `right_padding_width` | Number of spaces on right-hand side of column data.
|
|
514
|
-
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`.
|
|
515
|
-
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`.
|
|
516
|
-
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`.
|
|
517
|
-
| `junction_char` | Single character string used to draw line junctions. Default: `+`.
|
|
518
|
-
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`.
|
|
519
|
-
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`.
|
|
520
|
-
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`.
|
|
521
|
-
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`.
|
|
522
|
-
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`.
|
|
523
|
-
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`.
|
|
524
|
-
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`.
|
|
525
|
-
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`.
|
|
500
|
+
| Option | Details |
|
|
501
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
502
|
+
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
|
|
503
|
+
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
|
|
504
|
+
| `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. |
|
|
505
|
+
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
|
|
506
|
+
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
|
|
507
|
+
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
|
|
508
|
+
| `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`. |
|
|
509
|
+
| `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`. |
|
|
510
|
+
| `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]` |
|
|
511
|
+
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
|
|
512
|
+
| `left_padding_width` | Number of spaces on left-hand side of column data. |
|
|
513
|
+
| `right_padding_width` | Number of spaces on right-hand side of column data. |
|
|
514
|
+
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
|
|
515
|
+
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
|
|
516
|
+
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
|
|
517
|
+
| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
|
|
518
|
+
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
|
|
519
|
+
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
|
|
520
|
+
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
|
|
521
|
+
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
|
|
522
|
+
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
|
|
523
|
+
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
|
|
524
|
+
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
|
|
525
|
+
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
|
|
526
526
|
|
|
527
527
|
You can set the style options to your own settings in two ways:
|
|
528
528
|
|
|
@@ -465,32 +465,32 @@ whatever you prefer. The `set_style` method just does this automatically for you
|
|
|
465
465
|
|
|
466
466
|
The options are:
|
|
467
467
|
|
|
468
|
-
| Option | Details
|
|
469
|
-
| ---------------------------- |
|
|
470
|
-
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table.
|
|
471
|
-
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`.
|
|
472
|
-
| `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.
|
|
473
|
-
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`.
|
|
474
|
-
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc.
|
|
475
|
-
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`.
|
|
476
|
-
| `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`.
|
|
477
|
-
| `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`.
|
|
478
|
-
| `custom_format` | A dictionary of field and callable. This allows you to set any format you want `pf.custom_format["my_col_int"] =
|
|
479
|
-
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`).
|
|
480
|
-
| `left_padding_width` | Number of spaces on left-hand side of column data.
|
|
481
|
-
| `right_padding_width` | Number of spaces on right-hand side of column data.
|
|
482
|
-
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`.
|
|
483
|
-
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`.
|
|
484
|
-
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`.
|
|
485
|
-
| `junction_char` | Single character string used to draw line junctions. Default: `+`.
|
|
486
|
-
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`.
|
|
487
|
-
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`.
|
|
488
|
-
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`.
|
|
489
|
-
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`.
|
|
490
|
-
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`.
|
|
491
|
-
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`.
|
|
492
|
-
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`.
|
|
493
|
-
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`.
|
|
468
|
+
| Option | Details |
|
|
469
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
470
|
+
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
|
|
471
|
+
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
|
|
472
|
+
| `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. |
|
|
473
|
+
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
|
|
474
|
+
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
|
|
475
|
+
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
|
|
476
|
+
| `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`. |
|
|
477
|
+
| `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`. |
|
|
478
|
+
| `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]` |
|
|
479
|
+
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
|
|
480
|
+
| `left_padding_width` | Number of spaces on left-hand side of column data. |
|
|
481
|
+
| `right_padding_width` | Number of spaces on right-hand side of column data. |
|
|
482
|
+
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
|
|
483
|
+
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
|
|
484
|
+
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
|
|
485
|
+
| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
|
|
486
|
+
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
|
|
487
|
+
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
|
|
488
|
+
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
|
|
489
|
+
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
|
|
490
|
+
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
|
|
491
|
+
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
|
|
492
|
+
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
|
|
493
|
+
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
|
|
494
494
|
|
|
495
495
|
You can set the style options to your own settings in two ways:
|
|
496
496
|
|
|
@@ -9,9 +9,13 @@ requires = [
|
|
|
9
9
|
name = "prettytable"
|
|
10
10
|
description = "A simple Python library for easily displaying tabular data in a visually appealing ASCII table format"
|
|
11
11
|
readme = "README.md"
|
|
12
|
-
license = {text = "BSD (3 clause)"}
|
|
13
|
-
maintainers = [
|
|
14
|
-
|
|
12
|
+
license = { text = "BSD (3 clause)" }
|
|
13
|
+
maintainers = [
|
|
14
|
+
{ name = "Jazzband" },
|
|
15
|
+
]
|
|
16
|
+
authors = [
|
|
17
|
+
{ name = "Luke Maurits", email = "luke@maurits.id.au" },
|
|
18
|
+
]
|
|
15
19
|
requires-python = ">=3.8"
|
|
16
20
|
classifiers = [
|
|
17
21
|
"License :: OSI Approved :: BSD License",
|
|
@@ -34,16 +38,14 @@ dynamic = [
|
|
|
34
38
|
dependencies = [
|
|
35
39
|
"wcwidth",
|
|
36
40
|
]
|
|
37
|
-
|
|
38
|
-
tests = [
|
|
41
|
+
optional-dependencies.tests = [
|
|
39
42
|
"pytest",
|
|
40
43
|
"pytest-cov",
|
|
41
44
|
"pytest-lazy-fixtures",
|
|
42
45
|
]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Source = "https://github.com/jazzband/prettytable"
|
|
46
|
+
urls.Changelog = "https://github.com/jazzband/prettytable/releases"
|
|
47
|
+
urls.Homepage = "https://github.com/jazzband/prettytable"
|
|
48
|
+
urls.Source = "https://github.com/jazzband/prettytable"
|
|
47
49
|
|
|
48
50
|
[tool.hatch]
|
|
49
51
|
version.source = "vcs"
|
|
@@ -54,28 +56,32 @@ local_scheme = "no-local-version"
|
|
|
54
56
|
[tool.ruff]
|
|
55
57
|
fix = true
|
|
56
58
|
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"PGH", # pygrep-hooks
|
|
59
|
+
lint.select = [
|
|
60
|
+
"C4", # flake8-comprehensions
|
|
61
|
+
"E", # pycodestyle errors
|
|
62
|
+
"EM", # flake8-errmsg
|
|
63
|
+
"F", # pyflakes errors
|
|
64
|
+
"I", # isort
|
|
65
|
+
"ISC", # flake8-implicit-str-concat
|
|
66
|
+
"LOG", # flake8-logging
|
|
67
|
+
"PGH", # pygrep-hooks
|
|
67
68
|
"RUF100", # unused noqa (yesqa)
|
|
68
|
-
"UP",
|
|
69
|
-
"W",
|
|
70
|
-
"YTT",
|
|
69
|
+
"UP", # pyupgrade
|
|
70
|
+
"W", # pycodestyle warnings
|
|
71
|
+
"YTT", # flake8-2020
|
|
71
72
|
]
|
|
72
|
-
extend-ignore = [
|
|
73
|
+
lint.extend-ignore = [
|
|
73
74
|
"E203", # Whitespace before ':'
|
|
74
75
|
"E221", # Multiple spaces before operator
|
|
75
76
|
"E226", # Missing whitespace around arithmetic operator
|
|
76
77
|
"E241", # Multiple spaces after ','
|
|
77
78
|
]
|
|
79
|
+
lint.isort.known-first-party = [
|
|
80
|
+
"prettytable",
|
|
81
|
+
]
|
|
82
|
+
lint.isort.required-imports = [
|
|
83
|
+
"from __future__ import annotations",
|
|
84
|
+
]
|
|
78
85
|
|
|
79
|
-
[tool.
|
|
80
|
-
|
|
81
|
-
required-imports = ["from __future__ import annotations"]
|
|
86
|
+
[tool.pyproject-fmt]
|
|
87
|
+
max_supported_python = "3.13"
|
|
@@ -1552,9 +1552,9 @@ class PrettyTable:
|
|
|
1552
1552
|
|
|
1553
1553
|
def _format_value(self, field, value):
|
|
1554
1554
|
if isinstance(value, int) and field in self._int_format:
|
|
1555
|
-
return ("
|
|
1555
|
+
return (f"%{self._int_format[field]}d") % value
|
|
1556
1556
|
elif isinstance(value, float) and field in self._float_format:
|
|
1557
|
-
return ("
|
|
1557
|
+
return (f"%{self._float_format[field]}f") % value
|
|
1558
1558
|
|
|
1559
1559
|
formatter = self._custom_format.get(field, (lambda f, v: str(v)))
|
|
1560
1560
|
return formatter(field, value)
|
|
@@ -1887,7 +1887,10 @@ class PrettyTable:
|
|
|
1887
1887
|
)
|
|
1888
1888
|
bits.append(endpoint)
|
|
1889
1889
|
title = " " * lpad + title + " " * rpad
|
|
1890
|
-
|
|
1890
|
+
lpad, rpad = self._get_padding_widths(options)
|
|
1891
|
+
sum_widths = sum([n + lpad + rpad + 1 for n in self._widths])
|
|
1892
|
+
|
|
1893
|
+
bits.append(self._justify(title, sum_widths - 1, "c"))
|
|
1891
1894
|
bits.append(endpoint)
|
|
1892
1895
|
lines.append("".join(bits))
|
|
1893
1896
|
return "\n".join(lines)
|
|
@@ -1899,9 +1902,11 @@ class PrettyTable:
|
|
|
1899
1902
|
if options["hrules"] in (ALL, FRAME):
|
|
1900
1903
|
bits.append(self._stringify_hrule(options, "top_"))
|
|
1901
1904
|
if options["title"] and options["vrules"] in (ALL, FRAME):
|
|
1905
|
+
left_j_len = len(self.left_junction_char)
|
|
1906
|
+
right_j_len = len(self.right_junction_char)
|
|
1902
1907
|
bits[-1] = (
|
|
1903
1908
|
self.left_junction_char
|
|
1904
|
-
+ bits[-1][
|
|
1909
|
+
+ bits[-1][left_j_len:-right_j_len]
|
|
1905
1910
|
+ self.right_junction_char
|
|
1906
1911
|
)
|
|
1907
1912
|
bits.append("\n")
|
|
@@ -2193,7 +2198,9 @@ class PrettyTable:
|
|
|
2193
2198
|
if options["fields"] and field not in options["fields"]:
|
|
2194
2199
|
continue
|
|
2195
2200
|
lines.append(
|
|
2196
|
-
" <th
|
|
2201
|
+
" <th>{}</th>".format(
|
|
2202
|
+
escape(field).replace("\n", linebreak)
|
|
2203
|
+
)
|
|
2197
2204
|
)
|
|
2198
2205
|
lines.append(" </tr>")
|
|
2199
2206
|
lines.append(" </thead>")
|
|
@@ -2208,7 +2215,9 @@ class PrettyTable:
|
|
|
2208
2215
|
if options["fields"] and field not in options["fields"]:
|
|
2209
2216
|
continue
|
|
2210
2217
|
lines.append(
|
|
2211
|
-
" <td
|
|
2218
|
+
" <td>{}</td>".format(
|
|
2219
|
+
escape(datum).replace("\n", linebreak)
|
|
2220
|
+
)
|
|
2212
2221
|
)
|
|
2213
2222
|
lines.append(" </tr>")
|
|
2214
2223
|
lines.append(" </tbody>")
|
|
@@ -2356,7 +2365,7 @@ class PrettyTable:
|
|
|
2356
2365
|
|
|
2357
2366
|
alignments = "".join([self._align[field] for field in wanted_fields])
|
|
2358
2367
|
|
|
2359
|
-
begin_cmd = "\\begin{tabular}{
|
|
2368
|
+
begin_cmd = f"\\begin{{tabular}}{{{alignments}}}"
|
|
2360
2369
|
lines.append(begin_cmd)
|
|
2361
2370
|
|
|
2362
2371
|
# Headers
|
|
@@ -2398,7 +2407,7 @@ class PrettyTable:
|
|
|
2398
2407
|
if options["border"] and options["vrules"] in [ALL, FRAME]:
|
|
2399
2408
|
alignment_str = "|" + alignment_str + "|"
|
|
2400
2409
|
|
|
2401
|
-
begin_cmd = "\\begin{tabular}{
|
|
2410
|
+
begin_cmd = f"\\begin{{tabular}}{{{alignment_str}}}"
|
|
2402
2411
|
lines.append(begin_cmd)
|
|
2403
2412
|
if options["border"] and options["hrules"] in [ALL, FRAME]:
|
|
2404
2413
|
lines.append("\\hline")
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
5
|
from prettytable import PrettyTable
|
|
6
|
-
from prettytable.colortable import RESET_CODE, ColorTable, Theme
|
|
6
|
+
from prettytable.colortable import RESET_CODE, ColorTable, Theme, Themes
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@pytest.fixture
|
|
@@ -94,3 +94,64 @@ class TestFormatCode:
|
|
|
94
94
|
def test_multiple(self) -> None:
|
|
95
95
|
assert Theme.format_code("30;42") == "\x1b[30;42m"
|
|
96
96
|
assert Theme.format_code("\x1b[30;42m") == "\x1b[30;42m"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class TestColorTableRendering:
|
|
100
|
+
"""Tests for the rendering of the color table
|
|
101
|
+
|
|
102
|
+
Methods
|
|
103
|
+
-------
|
|
104
|
+
test_color_table_rendering
|
|
105
|
+
Tests the color table rendering using the default alignment (`'c'`)
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
def test_color_table_rendering(self) -> None:
|
|
109
|
+
"""Tests the color table rendering using the default alignment (`'c'`)"""
|
|
110
|
+
chars = {
|
|
111
|
+
"+": "\x1b[36m+\x1b[0m\x1b[96m",
|
|
112
|
+
"-": "\x1b[34m-\x1b[0m\x1b[96m",
|
|
113
|
+
"|": "\x1b[34m|\x1b[0m\x1b[96m",
|
|
114
|
+
" ": " ",
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
plus = chars.get("+")
|
|
118
|
+
minus = chars.get("-")
|
|
119
|
+
pipe = chars.get("|")
|
|
120
|
+
space = chars.get(" ")
|
|
121
|
+
|
|
122
|
+
# +-----------------------+
|
|
123
|
+
# | Efforts |
|
|
124
|
+
# +---+---+---+---+---+---+
|
|
125
|
+
# | A | B | C | D | E | f |
|
|
126
|
+
# +---+---+---+---+---+---+
|
|
127
|
+
# | 1 | 2 | 3 | 4 | 5 | 6 |
|
|
128
|
+
# +---+---+---+---+---+---+
|
|
129
|
+
|
|
130
|
+
header = (
|
|
131
|
+
plus + minus * 23 + plus,
|
|
132
|
+
pipe + space * 8 + "Efforts" + space * 8 + pipe,
|
|
133
|
+
(plus + minus * 3) * 6 + plus,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
body = (
|
|
137
|
+
"".join(pipe + space + char + space for char in "ABCDEF") + pipe,
|
|
138
|
+
(plus + minus * 3) * 6 + plus,
|
|
139
|
+
"".join(pipe + space + char + space for char in "123456") + pipe,
|
|
140
|
+
(plus + minus * 3) * 6 + plus,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
header_str = str("\n".join(header))
|
|
144
|
+
body_str = str("\n".join(body))
|
|
145
|
+
|
|
146
|
+
table = ColorTable(
|
|
147
|
+
("A", "B", "C", "D", "E", "F"),
|
|
148
|
+
theme=Themes.OCEAN,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
table.title = "Efforts"
|
|
152
|
+
table.add_row([1, 2, 3, 4, 5, 6])
|
|
153
|
+
|
|
154
|
+
expected = header_str + "\n" + body_str + "\x1b[0m"
|
|
155
|
+
result = str(table)
|
|
156
|
+
|
|
157
|
+
assert expected == result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|