jonathanj / tree-format

Python library for printing trees on the console

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python library to generate nicely formatted trees, like the UNIX tree command.

Example

Produce output like this:

foo
├── bar
│   ├── a
│   └── b
├── baz
└── qux
    └── c

using code like this:

import operator

from tree_format import print_tree

tree = (
    'foo', [
        ('bar', [
            ('a', []),
            ('b', []),
        ]),
        ('baz', []),
        ('qux', [
            ('c', []),
        ]),
    ],
)

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

About

Python library for printing trees on the console

License:Apache License 2.0


Languages

Language:Python 100.0%