Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jml/tree-format
Python library for printing trees on the console
https://github.com/jml/tree-format
Last synced: about 1 month ago
JSON representation
Python library for printing trees on the console
- Host: GitHub
- URL: https://github.com/jml/tree-format
- Owner: jml
- License: apache-2.0
- Created: 2015-06-14T08:07:34.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-12-31T11:20:44.000Z (12 months ago)
- Last Synced: 2024-11-10T01:02:43.076Z (about 1 month ago)
- Language: Python
- Size: 24.4 KB
- Stars: 39
- Watchers: 6
- Forks: 17
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Python library to generate nicely formatted trees, like the UNIX `tree`
command.## Example
Produce output like this:
```
foo
├── bar
│ ├── a
│ └── b
├── baz
└── qux
└── c⏎
d
```using code like this:
```python
from operator import itemgetterfrom tree_format import format_tree
tree = (
'foo', [
('bar', [
('a', []),
('b', []),
]),
('baz', []),
('qux', [
('c\nd', []),
]),
],
)print format_tree(
tree, format_node=itemgetter(0), get_children=itemgetter(1))
```## License
This is made available under the Apache Software License, version 2.0.
Copyright (c) 2015 - Jonathan M. Lange
## Testing
Run tests with:
```
python -m testtools.run discover
```