Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sslivkoff/toolstr
https://github.com/sslivkoff/toolstr
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sslivkoff/toolstr
- Owner: sslivkoff
- License: mit
- Created: 2021-10-01T23:33:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T17:44:40.000Z (6 months ago)
- Last Synced: 2024-10-29T20:54:19.642Z (20 days ago)
- Language: Rust
- Size: 253 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```bash
pip install toolstr
```## Contents
- [Formatting Examples](#formatting)
- [Charting Examples](#charting)
- [Tables Examples](#tables)
- [FAQ](#faq)## 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](https://github.com/Textualize/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