toolstr is a suite of str processing tools, including formatting and drawing
Project description
toolstr
toolstr
makes it easy to create precise str
representations of many different datatypes
toolstr
has functionality for:
- formatting: convert numbers, timestamps, and bytecounts to str
- charting: create data charts using Unicode and other character sets
- tables: create highly-configurable table representations
toolstr
uses many Unicode characters, but can also fallback to ascii when needed.
Install
pip install toolstr
Contents
Formatting
Charting
Tables
Each of the parameters shown below can be mixed and matched to achieve a particular style.
By default numbers in tables are converted to str
using toolstr.format_number()
.
There are also some options visible in a terminal but not visible on github, including:
- color cells by column or by value
- separate color control of inner border vs outer border vs header border
- other rich styles including: bold, italic, and hyperlinks
Table Examples
toolstr.print_tables
{'add_row_index': True}
│ Name │ Era │ Age
─────┼────────────┼──────────────────────────┼─────────────────
1 │ Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
2 │ Gondwana │ Ediacaran-Jurassic │ 550,000,000
3 │ Pangea │ Carboniferous-Jurassic │ 336,000,000
{'border': 'thick'}
Name ┃ Era ┃ Age
━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━
Vaalbara ┃ Eoarchean-Mesoarchean ┃ 3,636,000,000
Gondwana ┃ Ediacaran-Jurassic ┃ 550,000,000
Pangea ┃ Carboniferous-Jurassic ┃ 336,000,000
{'border': 'double'}
Name ║ Era ║ Age
════════════╬══════════════════════════╬═════════════════
Vaalbara ║ Eoarchean-Mesoarchean ║ 3,636,000,000
Gondwana ║ Ediacaran-Jurassic ║ 550,000,000
Pangea ║ Carboniferous-Jurassic ║ 336,000,000
{'border': 'ascii'}
Name | Era | Age
------------+--------------------------+-----------------
Vaalbara | Eoarchean-Mesoarchean | 3,636,000,000
Gondwana | Ediacaran-Jurassic | 550,000,000
Pangea | Carboniferous-Jurassic | 336,000,000
{'outer_border': True}
┌────────────┬──────────────────────────┬─────────────────┐
│ Name │ Era │ Age │
├────────────┼──────────────────────────┼─────────────────┤
│ Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000 │
│ Gondwana │ Ediacaran-Jurassic │ 550,000,000 │
│ Pangea │ Carboniferous-Jurassic │ 336,000,000 │
└────────────┴──────────────────────────┴─────────────────┘
{'outer_border': 'thick'}
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Name │ Era │ Age ┃
┃────────────┼──────────────────────────┼─────────────────┃
┃ Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000 ┃
┃ Gondwana │ Ediacaran-Jurassic │ 550,000,000 ┃
┃ Pangea │ Carboniferous-Jurassic │ 336,000,000 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
{'header_location': 'bottom'}
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
Gondwana │ Ediacaran-Jurassic │ 550,000,000
Pangea │ Carboniferous-Jurassic │ 336,000,000
────────────┼──────────────────────────┼─────────────────
Name │ Era │ Age
{'header_location': []}
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
Gondwana │ Ediacaran-Jurassic │ 550,000,000
Pangea │ Carboniferous-Jurassic │ 336,000,000
{'header_location': ['top', 'bottom']}
Name │ Era │ Age
────────────┼──────────────────────────┼─────────────────
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
Gondwana │ Ediacaran-Jurassic │ 550,000,000
Pangea │ Carboniferous-Jurassic │ 336,000,000
────────────┼──────────────────────────┼─────────────────
Name │ Era │ Age
{'separate_all_rows': True}
Name │ Era │ Age
────────────┼──────────────────────────┼─────────────────
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
────────────┼──────────────────────────┼─────────────────
Gondwana │ Ediacaran-Jurassic │ 550,000,000
────────────┼──────────────────────────┼─────────────────
Pangea │ Carboniferous-Jurassic │ 336,000,000
{'compact': True}
Name Era Age
─────────────────────────────────────────────
Vaalbara Eoarchean-Mesoarchean 3,636,000,000
Gondwana Ediacaran-Jurassic 550,000,000
Pangea Carboniferous-Jurassic 336,000,000
{'header_border': 'thick'}
Name ┃ Era ┃ Age
━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
Gondwana │ Ediacaran-Jurassic │ 550,000,000
Pangea │ Carboniferous-Jurassic │ 336,000,000
{'header_style': 'bold'}
Name │ Era │ Age
────────────┼──────────────────────────┼─────────────────
Vaalbara │ Eoarchean-Mesoarchean │ 3,636,000,000
Gondwana │ Ediacaran-Jurassic │ 550,000,000
Pangea │ Carboniferous-Jurassic │ 336,000,000
FAQ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file toolstr-0.9.9.tar.gz
.
File metadata
- Download URL: toolstr-0.9.9.tar.gz
- Upload date:
- Size: 93.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.29.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 935917c0479e182483011d586aacc7bdd5657150de5deb8d784e9becfccab6d4 |
|
MD5 | bfa883860dd2d7145bae20d1c8eee9e3 |
|
BLAKE2b-256 | fdfcaaece76465a20c361f606aa1e2de869b122daf7a8e63f78d497f1e7dfd36 |
File details
Details for the file toolstr-0.9.9-py3-none-any.whl
.
File metadata
- Download URL: toolstr-0.9.9-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.29.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a6fe3500f96c055880baab96d76f16184d4fd5f413045508bf828d16f8afc02 |
|
MD5 | f2e4c48985a6f87573e9ca70ed9d30ff |
|
BLAKE2b-256 | fc6a5ec5a629c5f459961cbe4be4821040e95e0cb22ec82c99047d2c4e70664b |