-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript_example.py
More file actions
26 lines (21 loc) · 782 Bytes
/
script_example.py
File metadata and controls
26 lines (21 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import treesource as ts
# Generate the tree
root_path='./example_folder'
tree = ts.generate_tree(root_path)
# Render as pure text
rendered = ts.render.as_text(tree, use_unicode=False)
print(rendered)
# Render as specific format
# The rendering FORMATS use special tokens which are replaced by the values:
# pre: the ASCII chars that represent the tree
# icon: an icon displayed is use_unicode is true
# name: the file/directory name
# doc: the documentation string
rendered = ts.render.engine.render_tree(
tree,
folder_icon='D', file_icon='F',
doc_folder_format="{pre}[{icon}]/{name}/ --> {doc}",
no_doc_folder_format="{pre}[{icon}][{name}]",
doc_file_format="{pre}[{icon}][{name}] --> {doc}",
no_doc_file_format="{pre}[{icon}][{name}]")
print(rendered)