You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
617 B
Python

from bigtree import Node, print_tree, get_subtree
from exquisite_branch.db import get_db, dict_factory
def make_tree(branches):
nodes = {}
nodes["NEW"] = Node("NEW")
for branch in branches:
try:
id = branch["branch"]
parent_id = branch["parent"]
content = branch["content"]
username = branch["username"]
nodes[id] = Node(
id, parent=nodes[parent_id], content=content, username=username
)
except Exception as e:
print(e)
nodes["NEW"].hshow(style="rounded")
return nodes["NEW"]