CliTree
clitree is a library to draw tree structures like the CLI utility tree does.
Install it with:
pip install clitree
Example usage:
>>> from clitree import tree
>>>
>>> data = {
... "name": "root",
... "children": [
... {"name": "docs", "children": [
... {"name": "api.md", "children": []},
... {"name": "guide.md", "children": []}
... ]},
... {"name": "src", "children": [
... {"name": "main.py", "children": []},
... {"name": "utils", "children": [
... {"name": "helpers.py", "children": []},
... {"name": "config.py", "children": []}
... ]}
... ]},
... {"name": "tests", "children": []}
... ]
... }
>>>
>>> print(tree(data))
root
├── docs
│ ├── api.md
│ └── guide.md
├── src
│ ├── main.py
│ └── utils
│ ├── helpers.py
│ └── config.py
└── tests
Parameters
name: How to extract the name of a node. Can be:- A string key (uses
node.get(name)orgetattr(node, name)) - A callable that returns a string
- A string key (uses
children: How to obtain the children of a node. Can be:- A string key (uses
node.get(children)orgetattr(node, children)) - A callable that returns an iterable of nodes (including generators)
- Returns
Noneor empty iterable for leaf nodes
- A string key (uses
Node Structure
When using string keys for name and children, nodes are typically:
- Dictionaries with a
getmethod, or - Objects with attributes accessible via
getattr
However, since name and children can be callables, nodes can be of any type, as the callables are responsible for extracting the required information.
Requirements:
- The name must resolve to a string value
- Children must be iterable or None
Error Handling
ValueError: Raised when a node's name resolves to NoneTypeError: Raised when children are not iterable
Metadata
Release files for clitree 0.1.0
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 |
|---|---|---|---|---|
| clitree-0.1.0.tar.gz | 16.1 kB | Without provenance | Details for clitree-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clitree-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for clitree-0.1.0-py3-none-any.whl |
Total release size: 20.1 kB
Release files / clitree-0.1.0.tar.gz
| Download URL | clitree-0.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9174bcb71bd18e2601770903dcae89753b271cc425424ae3b124815b86d4dff6
|
|
BLAKE2b-256 checksum How to use checksums |
b8901cda0dd9ce23cffcaab78abf1c260a42af1a91c1bfdd253e19ce0d5b9991
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / clitree-0.1.0-py3-none-any.whl
| Download URL | clitree-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a62bda59ffe29e81effd22f6765a999eda6289592709db73d9c9e6596017c91d
|
|
BLAKE2b-256 checksum How to use checksums |
d3152fcd3573014aa5124d7c7a149b365a3cb6d74e0b917641abb6f2d7f33b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for clitree 0.1.0
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.