graph: avoid variable shadowing and typing warnings

This commit is contained in:
Danny Robson 2019-04-28 08:26:43 +10:00
parent 0f5b1d01ec
commit bd7f7dd743

View File

@ -1,23 +1,21 @@
#!/usr/bin/env python3
import json
import typing
import os
from typing import Dict
def as_graphviz(recipes: dict):
def graph_all(recipes: dict) -> None:
print("digraph G {")
for result, method in recipes.items():
for variation in method:
for input in variation["input"]:
print(f"{input} -> {result}")
for i in variation["input"]:
print(f"{i} -> {result}")
print("}")
if __name__ == '__main__':
root = os.path.dirname(__file__)
recipe_root = os.path.join(root, 'data', 'recipes')
def load_recipes(recipe_root: str) -> dict:
recipes = dict()
for dirname, dirs, files in os.walk(recipe_root):
@ -29,4 +27,10 @@ if __name__ == '__main__':
recipes[name] = variations
as_graphviz(recipes)
return recipes
if __name__ == '__main__':
root = os.path.dirname(__file__)
recipe_root = os.path.join(root, 'data', 'recipes')
graph_all(load_recipes(recipe_root))