lxtree
Package to draw tree structures (tree linux command style)
Basic usage
Build the tree structure using TreeNodes. A TreeNode can contain other TreeNodes
to represent the tree. When builded you car get a string representation of it,
or get string of a sub-tree using some child as root.
Code samples
from lxtree import TreeNode
# Creating root
root = TreeNode('root')
# Adding a list of nodes
root.children = [TreeNode('branch1'), TreeNode('branch3')]
# Insert node
root.insert_child(TreeNode('branch2'), 1)
# Appending to a branch 1 by index
root[0].append_child(TreeNode('branch11'))
# Using index to assign children to branch11
root[0][0] = [TreeNode('leaf111'), TreeNode('leaf112')]
# Use `set_children` to add nodes as argv
root[1].set_children(TreeNode('leaf21'), TreeNode('leaf22'), TreeNode('leaf23'))
# Print tree
print(root)
Creating all structure at once
root = TreeNode('root').set_children(
TreeNode('branch1').append_child(
TreeNode('branch11').set_children(
TreeNode('leaf111'),
TreeNode('leaf112')
)
),
TreeNode('branch2').set_children(
TreeNode('leaf21'),
TreeNode('leaf22'),
TreeNode('leaf23')
),
TreeNode('branch3')
)
print(root)
Creating the tree from a dict
tree_data = {
'root': {
'branch1': {
'branch11': {
'leaf111': None,
'leaf112': None
}
},
'branch2': {
'leaf21': None,
'leaf22': None,
'leaf23': None
},
'branch3': None
}
}
print(TreeNode.tree_from_dict(tree_data))
Output
Metadata
Release files for lxtree 1.0.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 | |
|---|---|---|---|---|
| lxtree-1.0.0.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lxtree-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / lxtree-1.0.0.tar.gz
| Download URL | lxtree-1.0.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cd9ea4e2e7aa3731d38518249b04e8de5654d0838efc8a0c49c9b0a7be7d395
|
|
BLAKE2b-256 checksum How to use checksums |
ec7bde45d3969a0ce94646014901ce0e5ce23a187af188f352dfa384e3a7e172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.12
|
Release files / lxtree-1.0.0-py3-none-any.whl
| Download URL | lxtree-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfcbaa2850f2ad5f6cf3ace6248ab7af7f952485a8b888608a0046edf97c99d8
|
|
BLAKE2b-256 checksum How to use checksums |
a759ce5e6b846614c3bb8f4872a671d66cb506f5025b32e569816c03d7e58963
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.12
|
Security for lxtree 1.0.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.