Updating make tree so you can add ingredients later in the process.
Cette révision appartient à :
Parent
ba6d5f4255
révision
dd9f0f80d3
38
make_tree.py
38
make_tree.py
@ -8,38 +8,30 @@ def print_ingredients():
|
|||||||
|
|
||||||
|
|
||||||
ingredients = {}
|
ingredients = {}
|
||||||
|
|
||||||
ingredient = "start"
|
|
||||||
i = 0
|
i = 0
|
||||||
while ingredient:
|
node = "start"
|
||||||
|
while node:
|
||||||
print_ingredients()
|
print_ingredients()
|
||||||
|
|
||||||
ingredient = input("Add ingredient: ")
|
node = input("Add node: ")
|
||||||
|
|
||||||
if ingredient:
|
if node:
|
||||||
ingredients[i] = Node(ingredient, result=ingredient)
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
task = "start"
|
|
||||||
while task:
|
|
||||||
print_ingredients()
|
|
||||||
|
|
||||||
task = input("Add task: ")
|
|
||||||
|
|
||||||
if task:
|
|
||||||
needs = input("List needs (comma-separated): ")
|
needs = input("List needs (comma-separated): ")
|
||||||
description = input("Detailed description: ")
|
description = input("Detailed description: ")
|
||||||
result = input("Result of task (e.g. chopped carrots): ")
|
|
||||||
|
|
||||||
new_task = Node(task, description=description, result=result)
|
if needs:
|
||||||
|
result = input("Result of node (e.g. chopped carrots): ")
|
||||||
|
new_node = Node(node, description=description, result=result)
|
||||||
|
|
||||||
ingredients[i] = new_task
|
for e in [int(key.strip()) for key in needs.split(",")]:
|
||||||
|
ingredients.pop(e).parent = new_node
|
||||||
|
else:
|
||||||
|
new_node = Node(node, description=description, result=node)
|
||||||
|
|
||||||
|
ingredients[i] = new_node
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
for e in [int(key.strip()) for key in needs.split(",")]:
|
for pre, _, node in RenderTree(new_node):
|
||||||
ingredients.pop(e).parent = new_task
|
|
||||||
|
|
||||||
for pre, _, node in RenderTree(new_task):
|
|
||||||
print(f"{pre}{node.name}")
|
print(f"{pre}{node.name}")
|
||||||
|
|
||||||
name = input("Recipe name: ")
|
name = input("Recipe name: ")
|
||||||
@ -48,5 +40,5 @@ if name:
|
|||||||
name = name.replace(" ", "_")
|
name = name.replace(" ", "_")
|
||||||
|
|
||||||
with open(f"{name}.json", 'w') as f:
|
with open(f"{name}.json", 'w') as f:
|
||||||
JsonExporter(indent=2).write(new_task, f)
|
JsonExporter(indent=2).write(new_node, f)
|
||||||
|
|
||||||
|
Chargement…
x
Référencer dans un nouveau ticket
Bloquer un utilisateur