treeviz
Visualize tree structure in bash manner using python
install
pip install treeviz
Structure
.
├── MANIFEST
├── MANIFEST.in
├── README.md
├── setup.py
├── test.py
└── treeviz
├── __init__.py
└── treeviz.py
# showcases of usage
python test.py
Usage
Create Your tree structure
from treeviz.treeviz import Node
root = Node("Jason")
child1 = Node("Mary")
child2 = Node("John")
grandson1 = Node("Kevin")
grandson2 = Node("Doris")
grandson3 = Node("James")
grandson4 = Node("Momo")
grandgrandson1 = Node("Baby")
root.add_child(child1)
root.add_child(child2)
child1.add_child(grandson1)
child1.add_child(grandson2)
child2.add_child(grandson3)
child2.add_child(grandson4)
grandson1.add_child(grandgrandson1)
root.visualize()
Jason
├── Mary
│ ├── Kevin
│ │ └── Baby
│ └── Doris
└── John
├── James
└── Momo
You can also print the sub-tree structure
child1.visualize()
Mary
├── Kevin
│ └── Baby
└── Doris
Two options are provided, to print in terminal or print to file
# print to file
# Giving path as the first parameter
root.visualize(".")
# If path is empty, then print to terminal
root.visualize()
# Default name is treeviz.txt, if the filename already exists, a number will be appended to it.
New Features
(2019.11.1) Adding max_len parameter to visualize(), which splits the message into multiple lines.
from treeviz.treeviz import Node
root = Node("Jason is our grandfather")
child1 = Node("Mary is Kevin's mother")
child2 = Node("John is James and Momo's father")
grandson1 = Node("Kevin")
grandson2 = Node("Doris")
grandson3 = Node("James")
grandson4 = Node("Momo")
grandgrandson1 = Node("Baby")
root.add_child(child1)
root.add_child(child2)
child1.add_child(grandson1)
child1.add_child(grandson2)
child2.add_child(grandson3)
child2.add_child(grandson4)
grandson1.add_child(grandgrandson1)
root.visualize(max_len=10)
Jason is our grandfather
├── Mary is Ke
│ vin's moth
│ er
│ ├── Kevin
│ │ └── Baby
│ └── Doris
└── John is Ja
mes and Mo
mo's fathe
r
├── James
└── Momo
(2019.11.2) Adding line_space parameter to visualize(), which enables to set space between each branch
root.visualize(line_space=2)
Jason is our grandfather
├── Mary is Kevin's mother
│ │
│ │
│ ├── Kevin
│ │ │
│ │ │
│ │ └── Baby
│ │
│ │
│ └── Doris
│
│
└── John is James and Momo's father
│
│
├── James
│
│
└── Momo
(2019.11.4) Adding 'filename' parameter to visualize, which enables users to defince own filename
Metadata
Release files for treeviz 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treeviz-1.1.tar.gz | 3.3 kB | Without provenance | Details for treeviz-1.1.tar.gz |
Release files / treeviz-1.1.tar.gz
| Download URL | treeviz-1.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34616c9f1b5b811bebbd33af2239de1fc044da26c913f0faf53ff9e6a2d5fe83
|
|
BLAKE2b-256 checksum How to use checksums |
765f8f4373d3d5a312f28735d08c2ebbfc30631f077f6c1bbd4c7dbeeaa42902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7
|
Security for treeviz 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.