")
return leaf_count
def generate_steps_depth_first(node, steps=[]):
for child in sorted(node.children, key=lambda x: x.height, reverse=True):
steps = generate_steps_depth_first(child, steps)
if not node.is_leaf:
steps.append(node.description if node.description else node.name)
return steps
if len(argv) < 2:
print(f"usage: {argv[0]} ")
exit()
with open(argv[1], 'r') as f:
recipe = json.loads(f.read())
recipe_name = recipe.get("name")
recipe_desc = recipe.get("description")
importer = DictImporter()
sub_recipes = [importer.import_(data) for data in recipe["sub_recipes"]]
print("")
print("")
print(f"{recipe_name}")
print("")
print("")
print("")
print("")
print("")
print("
")
print(f"
{recipe_name}
")
print("
")
print("
")
print(f"
{recipe_desc}
")
print("
")
print("")
print("")
print("
")
print("
Needs
")
print("
")
for sub_recipe in sub_recipes:
for ingredient in sub_recipe.leaves:
if ingredient.description:
print(f"
{ingredient.name} -- {ingredient.description}
")
else:
print(f"
{ingredient.name}
")
print("
")
print("
")
print("
")
print("
Preparation
")
print("")
for sub_recipe in sub_recipes:
tasks = generate_steps_depth_first(sub_recipe, steps=[])
for task in tasks:
print(f"
{task}
")
print("")
print("
")
print("")
print("")
print("
Tabular Layout
")
for sub_recipe in sub_recipes:
print("
")
print("
")
output_rows = []
for i in range(len(sub_recipe.leaves)):
output_rows.append([])
build_table_depth_first(sub_recipe, output_rows)
for row in output_rows:
print("