prettytable 3.16.0__tar.gz → 3.17.0__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.16.0 → prettytable-3.17.0}/.github/workflows/labels.yml +1 -1
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/lint.yml +6 -6
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/release.yml +3 -3
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/test.yml +21 -7
- prettytable-3.17.0/.github/zizmor.yml +7 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.pre-commit-config.yaml +10 -10
- {prettytable-3.16.0 → prettytable-3.17.0}/PKG-INFO +62 -47
- {prettytable-3.16.0 → prettytable-3.17.0}/README.md +59 -44
- {prettytable-3.16.0 → prettytable-3.17.0}/pyproject.toml +9 -4
- prettytable-3.17.0/requirements-mypy.txt +3 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/_version.py +16 -3
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/prettytable.py +88 -49
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_prettytable.py +189 -1
- {prettytable-3.16.0 → prettytable-3.17.0}/tox.ini +3 -7
- prettytable-3.16.0/.coveragerc +0 -15
- prettytable-3.16.0/requirements-mypy.txt +0 -2
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/FUNDING.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/SECURITY.md +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/dependabot.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/labels.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/release-drafter.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/release-drafter.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/require-pr-label.yml +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/.gitignore +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/CHANGELOG.md +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/LICENSE +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/RELEASING.md +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/__init__.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/__main__.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/colortable.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/py.typed +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/conftest.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_colortable.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_html.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_json.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_latex.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_mediawiki.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_sections.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_sorting.py +0 -0
- {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_style.py +0 -0
|
@@ -13,25 +13,25 @@ jobs:
|
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
17
|
with:
|
|
18
18
|
persist-credentials: false
|
|
19
|
-
- uses: actions/setup-python@
|
|
19
|
+
- uses: actions/setup-python@v6
|
|
20
20
|
with:
|
|
21
21
|
python-version: "3.x"
|
|
22
|
-
- uses:
|
|
22
|
+
- uses: j178/prek-action@v1
|
|
23
23
|
|
|
24
24
|
mypy:
|
|
25
25
|
runs-on: ubuntu-latest
|
|
26
26
|
|
|
27
27
|
steps:
|
|
28
|
-
- uses: actions/checkout@
|
|
28
|
+
- uses: actions/checkout@v5
|
|
29
29
|
with:
|
|
30
30
|
persist-credentials: false
|
|
31
|
-
- uses: actions/setup-python@
|
|
31
|
+
- uses: actions/setup-python@v6
|
|
32
32
|
with:
|
|
33
33
|
python-version: "3.x"
|
|
34
34
|
- name: Install uv
|
|
35
|
-
uses: astral-sh/setup-uv@
|
|
35
|
+
uses: astral-sh/setup-uv@v7
|
|
36
36
|
- name: Mypy
|
|
37
37
|
run: uvx --with tox-uv tox -e mypy
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
|
|
22
22
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
23
|
+
- uses: actions/checkout@v5
|
|
24
24
|
with:
|
|
25
25
|
fetch-depth: 0
|
|
26
26
|
persist-credentials: false
|
|
@@ -42,7 +42,7 @@ jobs:
|
|
|
42
42
|
|
|
43
43
|
steps:
|
|
44
44
|
- name: Download packages built by build-and-inspect-python-package
|
|
45
|
-
uses: actions/download-artifact@
|
|
45
|
+
uses: actions/download-artifact@v6
|
|
46
46
|
with:
|
|
47
47
|
name: Packages
|
|
48
48
|
path: dist
|
|
@@ -67,7 +67,7 @@ jobs:
|
|
|
67
67
|
|
|
68
68
|
steps:
|
|
69
69
|
- name: Download packages built by build-and-inspect-python-package
|
|
70
|
-
uses: actions/download-artifact@
|
|
70
|
+
uses: actions/download-artifact@v6
|
|
71
71
|
with:
|
|
72
72
|
name: Packages
|
|
73
73
|
path: dist
|
|
@@ -6,6 +6,7 @@ permissions: {}
|
|
|
6
6
|
|
|
7
7
|
env:
|
|
8
8
|
FORCE_COLOR: 1
|
|
9
|
+
PIP_DISABLE_PIP_VERSION_CHECK: 1
|
|
9
10
|
|
|
10
11
|
jobs:
|
|
11
12
|
test:
|
|
@@ -13,28 +14,41 @@ jobs:
|
|
|
13
14
|
strategy:
|
|
14
15
|
fail-fast: false
|
|
15
16
|
matrix:
|
|
16
|
-
python-version:
|
|
17
|
+
python-version:
|
|
18
|
+
- "pypy3.11"
|
|
19
|
+
- "3.15t"
|
|
20
|
+
- "3.15"
|
|
21
|
+
- "3.14t"
|
|
22
|
+
- "3.14"
|
|
23
|
+
- "3.13t"
|
|
24
|
+
- "3.13"
|
|
25
|
+
- "3.12"
|
|
26
|
+
- "3.11"
|
|
27
|
+
- "3.10"
|
|
17
28
|
os: [windows-latest, macos-latest, ubuntu-latest]
|
|
18
29
|
|
|
19
30
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
31
|
+
- uses: actions/checkout@v5
|
|
21
32
|
with:
|
|
22
33
|
persist-credentials: false
|
|
23
34
|
|
|
24
35
|
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
-
uses: actions/setup-python@
|
|
36
|
+
uses: actions/setup-python@v6
|
|
26
37
|
with:
|
|
27
38
|
python-version: ${{ matrix.python-version }}
|
|
28
39
|
allow-prereleases: true
|
|
29
40
|
|
|
41
|
+
- name: Set PYTHON_GIL
|
|
42
|
+
if: endsWith(matrix.python-version, 't')
|
|
43
|
+
run: |
|
|
44
|
+
echo "PYTHON_GIL=0" >> "$GITHUB_ENV"
|
|
45
|
+
|
|
30
46
|
- name: Install uv
|
|
31
|
-
uses: astral-sh/setup-uv@
|
|
32
|
-
with:
|
|
33
|
-
cache-dependency-glob: "**/pyproject.toml"
|
|
47
|
+
uses: astral-sh/setup-uv@v7
|
|
34
48
|
|
|
35
49
|
- name: Tox tests
|
|
36
50
|
run: |
|
|
37
|
-
uvx --with tox-uv tox -e py
|
|
51
|
+
uvx --python ${{ matrix.python-version }} --with tox-uv tox -e py
|
|
38
52
|
|
|
39
53
|
- name: Upload coverage
|
|
40
54
|
uses: codecov/codecov-action@v5
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
repos:
|
|
2
2
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
-
rev: v0.
|
|
3
|
+
rev: v0.13.3
|
|
4
4
|
hooks:
|
|
5
|
-
- id: ruff
|
|
5
|
+
- id: ruff-check
|
|
6
6
|
args: [--exit-non-zero-on-fix]
|
|
7
7
|
|
|
8
8
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
|
9
|
-
rev:
|
|
9
|
+
rev: 25.9.0
|
|
10
10
|
hooks:
|
|
11
11
|
- id: black
|
|
12
12
|
|
|
13
13
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
14
|
-
rev:
|
|
14
|
+
rev: v6.0.0
|
|
15
15
|
hooks:
|
|
16
16
|
- id: check-added-large-files
|
|
17
17
|
- id: check-case-conflict
|
|
@@ -26,7 +26,7 @@ repos:
|
|
|
26
26
|
exclude: .github/ISSUE_TEMPLATE/bug_report.md|tests/test_style.py|tests/test_prettytable.py
|
|
27
27
|
|
|
28
28
|
- repo: https://github.com/python-jsonschema/check-jsonschema
|
|
29
|
-
rev: 0.
|
|
29
|
+
rev: 0.34.0
|
|
30
30
|
hooks:
|
|
31
31
|
- id: check-dependabot
|
|
32
32
|
- id: check-github-workflows
|
|
@@ -37,27 +37,27 @@ repos:
|
|
|
37
37
|
- id: actionlint
|
|
38
38
|
|
|
39
39
|
- repo: https://github.com/woodruffw/zizmor-pre-commit
|
|
40
|
-
rev: v1.
|
|
40
|
+
rev: v1.14.2
|
|
41
41
|
hooks:
|
|
42
42
|
- id: zizmor
|
|
43
43
|
|
|
44
44
|
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
45
|
-
rev: v2.
|
|
45
|
+
rev: v2.7.0
|
|
46
46
|
hooks:
|
|
47
47
|
- id: pyproject-fmt
|
|
48
48
|
|
|
49
49
|
- repo: https://github.com/abravalheri/validate-pyproject
|
|
50
|
-
rev: v0.
|
|
50
|
+
rev: v0.24.1
|
|
51
51
|
hooks:
|
|
52
52
|
- id: validate-pyproject
|
|
53
53
|
|
|
54
54
|
- repo: https://github.com/tox-dev/tox-ini-fmt
|
|
55
|
-
rev: 1.
|
|
55
|
+
rev: 1.6.0
|
|
56
56
|
hooks:
|
|
57
57
|
- id: tox-ini-fmt
|
|
58
58
|
|
|
59
59
|
- repo: https://github.com/rbubley/mirrors-prettier
|
|
60
|
-
rev: v3.
|
|
60
|
+
rev: v3.6.2
|
|
61
61
|
hooks:
|
|
62
62
|
- id: prettier
|
|
63
63
|
args: [--prose-wrap=always, --print-width=88]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prettytable
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.17.0
|
|
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/prettytable/prettytable/releases
|
|
6
6
|
Project-URL: Funding, https://tidelift.com/subscription/pkg/pypi-prettytable?utm_source=pypi-prettytable&utm_medium=pypi
|
|
@@ -12,17 +12,17 @@ License-Expression: BSD-3-Clause
|
|
|
12
12
|
License-File: LICENSE
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
21
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
22
22
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
23
23
|
Classifier: Topic :: Text Processing
|
|
24
24
|
Classifier: Typing :: Typed
|
|
25
|
-
Requires-Python: >=3.
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
26
|
Requires-Dist: wcwidth
|
|
27
27
|
Provides-Extra: tests
|
|
28
28
|
Requires-Dist: pytest; extra == 'tests'
|
|
@@ -310,11 +310,11 @@ keyword argument, which must be a function with one argument `row` returning a B
|
|
|
310
310
|
value. The `row` is the list of fields in a row.
|
|
311
311
|
|
|
312
312
|
For example, to print the example table we built earlier of Australian capital city
|
|
313
|
-
data, so that cities with a population
|
|
313
|
+
data, so that cities with a population of at least 1,000,000, we can do this:
|
|
314
314
|
|
|
315
315
|
```python
|
|
316
|
-
def filter_function(
|
|
317
|
-
return
|
|
316
|
+
def filter_function(row: list[str]) -> bool:
|
|
317
|
+
return row[2] > 999999
|
|
318
318
|
|
|
319
319
|
print(table.get_string(row_filter=filter_function))
|
|
320
320
|
```
|
|
@@ -444,13 +444,15 @@ table.sortby = None
|
|
|
444
444
|
```
|
|
445
445
|
|
|
446
446
|
If you want to specify a custom sorting function, you can use the `sort_key` keyword
|
|
447
|
-
argument
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
447
|
+
argument as Pythons `sorted()` `key` parameter. The value of the `sort_key` parameter
|
|
448
|
+
should be a function (or other callable) that takes a single argument and returns a key
|
|
449
|
+
to use for sorting purposes.
|
|
450
|
+
|
|
451
|
+
If your table has n columns, each list will have n+1 elements. Each list corresponds to
|
|
452
|
+
one row of the table. The first element will be whatever data is in the relevant row, in
|
|
453
|
+
the column specified by the `sort_by` argument. The remaining n elements are the data in
|
|
454
|
+
each of the table's columns, in order, including a repeated instance of the data in the
|
|
455
|
+
`sort_by` column.
|
|
454
456
|
|
|
455
457
|
#### Adding sections to a table
|
|
456
458
|
|
|
@@ -541,40 +543,53 @@ PrettyTable has a number of style options which control various aspects of how t
|
|
|
541
543
|
are displayed. You have the freedom to set each of these options individually to
|
|
542
544
|
whatever you prefer. The `set_style` method just does this automatically for you.
|
|
543
545
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
| Option | Details
|
|
547
|
-
| ---------------------------- |
|
|
548
|
-
| `
|
|
549
|
-
| `
|
|
550
|
-
| `
|
|
551
|
-
| `
|
|
552
|
-
| `
|
|
553
|
-
| `
|
|
554
|
-
| `
|
|
555
|
-
| `
|
|
556
|
-
| `
|
|
557
|
-
| `
|
|
558
|
-
| `
|
|
559
|
-
| `
|
|
560
|
-
| `
|
|
561
|
-
| `
|
|
562
|
-
| `
|
|
563
|
-
| `
|
|
564
|
-
| `
|
|
565
|
-
| `
|
|
566
|
-
| `
|
|
567
|
-
| `
|
|
568
|
-
| `
|
|
569
|
-
| `
|
|
570
|
-
| `
|
|
571
|
-
| `
|
|
572
|
-
| `
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
546
|
+
Table-specific options are:
|
|
547
|
+
|
|
548
|
+
| Option | Details |
|
|
549
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
550
|
+
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
|
|
551
|
+
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
|
|
552
|
+
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
|
|
553
|
+
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
|
|
554
|
+
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
|
|
555
|
+
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
|
|
556
|
+
| `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
|
|
557
|
+
| `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. |
|
|
558
|
+
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
|
|
559
|
+
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
|
|
560
|
+
| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
|
|
561
|
+
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
|
|
562
|
+
| `left_padding_width` | Number of spaces on left-hand side of column data. |
|
|
563
|
+
| `max_table_width` | Number of characters used for the maximum total table width. |
|
|
564
|
+
| `min_table_width` | Number of characters used for the minimum total table width. |
|
|
565
|
+
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
|
|
566
|
+
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
|
|
567
|
+
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
|
|
568
|
+
| `right_padding_width` | Number of spaces on right-hand side of column data. |
|
|
569
|
+
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
|
|
570
|
+
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
|
|
571
|
+
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
|
|
572
|
+
| `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
|
|
573
|
+
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
|
|
574
|
+
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
|
|
575
|
+
|
|
576
|
+
For options that can be set individually for each column (`align`, `valign`,
|
|
577
|
+
`custom_format`, `max_width`, `min_width`, `int_format`, `float_format`, `none_format`)
|
|
578
|
+
you can either set a value, that applies to all columns or set a dict with column names
|
|
579
|
+
and individual values.
|
|
580
|
+
|
|
581
|
+
Column-specific options are:
|
|
582
|
+
|
|
583
|
+
| Option | Details |
|
|
584
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
585
|
+
| `align` | Controls alignment of fields, one of "l", "c", or "r" or a dictionary with column and value. |
|
|
586
|
+
| `custom_format` | Set any format, by setting a function that gets the original value,the formatted representation and returns the new string. E.g. `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]`. This also takes a dictionary with column and function. |
|
|
587
|
+
| `float_format` | A string which controls the way floating point data is printed or a dictionary with column and value. This works like: `print("%<float_format>f" % data)`. |
|
|
588
|
+
| `int_format` | A string which controls the way integer data is printed or a dictionary with column and value. This works like: `print("%<int_format>d" % data)`. |
|
|
589
|
+
| `max_width` | Number of characters used for maximum width of a column or a dictionary with column and value. |
|
|
590
|
+
| `min_width` | Number of characters used for minimum width of a column or a dictionary with column and value. |
|
|
591
|
+
| `none_format` | Representation of None values or a dictionary with column and value. |
|
|
592
|
+
| `valign` | Controls vertical alignment of fields, one of "t", "m", or "b" or a dictionary with column and value. |
|
|
578
593
|
|
|
579
594
|
You can set the style options to your own settings in two ways:
|
|
580
595
|
|
|
@@ -278,11 +278,11 @@ keyword argument, which must be a function with one argument `row` returning a B
|
|
|
278
278
|
value. The `row` is the list of fields in a row.
|
|
279
279
|
|
|
280
280
|
For example, to print the example table we built earlier of Australian capital city
|
|
281
|
-
data, so that cities with a population
|
|
281
|
+
data, so that cities with a population of at least 1,000,000, we can do this:
|
|
282
282
|
|
|
283
283
|
```python
|
|
284
|
-
def filter_function(
|
|
285
|
-
return
|
|
284
|
+
def filter_function(row: list[str]) -> bool:
|
|
285
|
+
return row[2] > 999999
|
|
286
286
|
|
|
287
287
|
print(table.get_string(row_filter=filter_function))
|
|
288
288
|
```
|
|
@@ -412,13 +412,15 @@ table.sortby = None
|
|
|
412
412
|
```
|
|
413
413
|
|
|
414
414
|
If you want to specify a custom sorting function, you can use the `sort_key` keyword
|
|
415
|
-
argument
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
415
|
+
argument as Pythons `sorted()` `key` parameter. The value of the `sort_key` parameter
|
|
416
|
+
should be a function (or other callable) that takes a single argument and returns a key
|
|
417
|
+
to use for sorting purposes.
|
|
418
|
+
|
|
419
|
+
If your table has n columns, each list will have n+1 elements. Each list corresponds to
|
|
420
|
+
one row of the table. The first element will be whatever data is in the relevant row, in
|
|
421
|
+
the column specified by the `sort_by` argument. The remaining n elements are the data in
|
|
422
|
+
each of the table's columns, in order, including a repeated instance of the data in the
|
|
423
|
+
`sort_by` column.
|
|
422
424
|
|
|
423
425
|
#### Adding sections to a table
|
|
424
426
|
|
|
@@ -509,40 +511,53 @@ PrettyTable has a number of style options which control various aspects of how t
|
|
|
509
511
|
are displayed. You have the freedom to set each of these options individually to
|
|
510
512
|
whatever you prefer. The `set_style` method just does this automatically for you.
|
|
511
513
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
| Option | Details
|
|
515
|
-
| ---------------------------- |
|
|
516
|
-
| `
|
|
517
|
-
| `
|
|
518
|
-
| `
|
|
519
|
-
| `
|
|
520
|
-
| `
|
|
521
|
-
| `
|
|
522
|
-
| `
|
|
523
|
-
| `
|
|
524
|
-
| `
|
|
525
|
-
| `
|
|
526
|
-
| `
|
|
527
|
-
| `
|
|
528
|
-
| `
|
|
529
|
-
| `
|
|
530
|
-
| `
|
|
531
|
-
| `
|
|
532
|
-
| `
|
|
533
|
-
| `
|
|
534
|
-
| `
|
|
535
|
-
| `
|
|
536
|
-
| `
|
|
537
|
-
| `
|
|
538
|
-
| `
|
|
539
|
-
| `
|
|
540
|
-
| `
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
514
|
+
Table-specific options are:
|
|
515
|
+
|
|
516
|
+
| Option | Details |
|
|
517
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
518
|
+
| `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
|
|
519
|
+
| `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
|
|
520
|
+
| `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
|
|
521
|
+
| `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
|
|
522
|
+
| `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
|
|
523
|
+
| `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
|
|
524
|
+
| `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
|
|
525
|
+
| `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. |
|
|
526
|
+
| `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
|
|
527
|
+
| `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
|
|
528
|
+
| `junction_char` | Single character string used to draw line junctions. Default: `+`. |
|
|
529
|
+
| `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
|
|
530
|
+
| `left_padding_width` | Number of spaces on left-hand side of column data. |
|
|
531
|
+
| `max_table_width` | Number of characters used for the maximum total table width. |
|
|
532
|
+
| `min_table_width` | Number of characters used for the minimum total table width. |
|
|
533
|
+
| `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
|
|
534
|
+
| `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
|
|
535
|
+
| `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
|
|
536
|
+
| `right_padding_width` | Number of spaces on right-hand side of column data. |
|
|
537
|
+
| `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
|
|
538
|
+
| `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
|
|
539
|
+
| `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
|
|
540
|
+
| `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
|
|
541
|
+
| `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
|
|
542
|
+
| `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
|
|
543
|
+
|
|
544
|
+
For options that can be set individually for each column (`align`, `valign`,
|
|
545
|
+
`custom_format`, `max_width`, `min_width`, `int_format`, `float_format`, `none_format`)
|
|
546
|
+
you can either set a value, that applies to all columns or set a dict with column names
|
|
547
|
+
and individual values.
|
|
548
|
+
|
|
549
|
+
Column-specific options are:
|
|
550
|
+
|
|
551
|
+
| Option | Details |
|
|
552
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
553
|
+
| `align` | Controls alignment of fields, one of "l", "c", or "r" or a dictionary with column and value. |
|
|
554
|
+
| `custom_format` | Set any format, by setting a function that gets the original value,the formatted representation and returns the new string. E.g. `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]`. This also takes a dictionary with column and function. |
|
|
555
|
+
| `float_format` | A string which controls the way floating point data is printed or a dictionary with column and value. This works like: `print("%<float_format>f" % data)`. |
|
|
556
|
+
| `int_format` | A string which controls the way integer data is printed or a dictionary with column and value. This works like: `print("%<int_format>d" % data)`. |
|
|
557
|
+
| `max_width` | Number of characters used for maximum width of a column or a dictionary with column and value. |
|
|
558
|
+
| `min_width` | Number of characters used for minimum width of a column or a dictionary with column and value. |
|
|
559
|
+
| `none_format` | Representation of None values or a dictionary with column and value. |
|
|
560
|
+
| `valign` | Controls vertical alignment of fields, one of "t", "m", or "b" or a dictionary with column and value. |
|
|
546
561
|
|
|
547
562
|
You can set the style options to your own settings in two ways:
|
|
548
563
|
|
|
@@ -13,16 +13,16 @@ license = "BSD-3-Clause"
|
|
|
13
13
|
license-files = [ "LICENSE" ]
|
|
14
14
|
maintainers = [ { name = "Hugo van Kemenade" } ]
|
|
15
15
|
authors = [ { name = "Luke Maurits", email = "luke@maurits.id.au" } ]
|
|
16
|
-
requires-python = ">=3.
|
|
16
|
+
requires-python = ">=3.10"
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Programming Language :: Python",
|
|
19
19
|
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
-
"Programming Language :: Python :: 3.9",
|
|
21
20
|
"Programming Language :: Python :: 3.10",
|
|
22
21
|
"Programming Language :: Python :: 3.11",
|
|
23
22
|
"Programming Language :: Python :: 3.12",
|
|
24
23
|
"Programming Language :: Python :: 3.13",
|
|
25
24
|
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Programming Language :: Python :: 3.15",
|
|
26
26
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
27
27
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
28
28
|
"Topic :: Text Processing",
|
|
@@ -86,7 +86,7 @@ lint.isort.known-first-party = [ "prettytable" ]
|
|
|
86
86
|
lint.isort.required-imports = [ "from __future__ import annotations" ]
|
|
87
87
|
|
|
88
88
|
[tool.pyproject-fmt]
|
|
89
|
-
max_supported_python = "3.
|
|
89
|
+
max_supported_python = "3.15"
|
|
90
90
|
|
|
91
91
|
[tool.pytest.ini_options]
|
|
92
92
|
filterwarnings = [
|
|
@@ -94,8 +94,13 @@ filterwarnings = [
|
|
|
94
94
|
]
|
|
95
95
|
testpaths = [ "tests" ]
|
|
96
96
|
|
|
97
|
+
[tool.coverage.run]
|
|
98
|
+
omit = [
|
|
99
|
+
"**/__main__.py",
|
|
100
|
+
]
|
|
101
|
+
|
|
97
102
|
[tool.mypy]
|
|
98
|
-
python_version = "3.
|
|
103
|
+
python_version = "3.10"
|
|
99
104
|
pretty = true
|
|
100
105
|
disallow_any_generics = true
|
|
101
106
|
enable_error_code = "ignore-without-code"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
5
12
|
|
|
6
13
|
TYPE_CHECKING = False
|
|
7
14
|
if TYPE_CHECKING:
|
|
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
|
|
|
9
16
|
from typing import Union
|
|
10
17
|
|
|
11
18
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
12
20
|
else:
|
|
13
21
|
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
14
23
|
|
|
15
24
|
version: str
|
|
16
25
|
__version__: str
|
|
17
26
|
__version_tuple__: VERSION_TUPLE
|
|
18
27
|
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
19
30
|
|
|
20
|
-
__version__ = version = '3.
|
|
21
|
-
__version_tuple__ = version_tuple = (3,
|
|
31
|
+
__version__ = version = '3.17.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (3, 17, 0)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|