diff --git a/make_tree.py b/make_tree.py index 414f556..a10eea2 100644 --- a/make_tree.py +++ b/make_tree.py @@ -4,7 +4,7 @@ from anytree.exporter import JsonExporter def print_ingredients(): for i, node in ingredients.items(): - print(f" {i}.) {node.name}") + print(f" {i}.) {node.result}") ingredients = {} @@ -17,7 +17,7 @@ while ingredient: ingredient = input("Add ingredient: ") if ingredient: - ingredients[i] = Node(ingredient) + ingredients[i] = Node(ingredient, result=ingredient) i += 1 task = "start" @@ -28,8 +28,10 @@ while task: if task: needs = input("List needs (comma-separated): ") + description = input("Detailed description: ") + result = input("Result of task (e.g. chopped carrots): ") - new_task = Node(task) + new_task = Node(task, description=description, result=result) ingredients[i] = new_task i += 1 diff --git a/output_html.py b/output_html.py index 8bf1d6b..90d62bb 100644 --- a/output_html.py +++ b/output_html.py @@ -5,7 +5,7 @@ from sys import argv def build_rows_depth_first(node, rows, leaf_count=0): - for child in sorted(node.children, key=lambda x: x.size, reverse=True): + for child in sorted(node.children, key=lambda x: x.height, reverse=True): leaf_count = build_rows_depth_first(child, rows, leaf_count) if node.is_leaf: @@ -15,7 +15,7 @@ def build_rows_depth_first(node, rows, leaf_count=0): else: child_leaves = len(node.leaves) cur_row = leaf_count - child_leaves - rows[cur_row].append(f'{node.name}') + rows[cur_row].append(f'{node.name}') return leaf_count