Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolstr-0.6.3.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toolstr-0.6.3-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file toolstr-0.6.3.tar.gz.

File metadata

  • Download URL: toolstr-0.6.3.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for toolstr-0.6.3.tar.gz
Algorithm Hash digest
SHA256 2631084d41750adb72dd0a0df245acf298a90c6e69c283005f49d27a6c5ebbd3
MD5 476e6115c11acb40106e736cc8f020c3
BLAKE2b-256 5bd5ddfdc6cec39d75091b6d75ebdb792359641edf505c49f9ea69c749b41acf

See more details on using hashes here.

File details

Details for the file toolstr-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: toolstr-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for toolstr-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0ded0beb6c615b58d5e02088988c27d1f62af68c35c5c08b0bca89e0f41baf59
MD5 9d19ed0698e2af1e6cc15527e1c555ca
BLAKE2b-256 51f4df96fdca6283c538c86a4be665815527f2fdc31632cc9d2951fcf3301385

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page