Přesunuto na GitHub https://github.com/ksp/kurz
https://ksp.mff.cuni.cz/kurz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
593 B
30 lines
593 B
4 years ago
|
import sys
|
||
|
import json
|
||
|
|
||
|
# pokus se naimportovat graphviz
|
||
|
try:
|
||
|
from graphviz import Digraph
|
||
|
except ModuleNotFoundError as e:
|
||
|
print("ERROR: Nainstaluj si graphviz - `pip install graphviz`", file=sys.stderr)
|
||
|
exit(1)
|
||
|
|
||
|
# nacist definici grafu
|
||
|
with open("tasks.json", "r") as f:
|
||
|
definition = json.load(f)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
dot = Digraph(comment='The Round Table')
|
||
|
|
||
|
# nodes
|
||
|
for task in definition["tasks"]:
|
||
|
dot.node(task["id"], task["id"])
|
||
|
|
||
|
# edges
|
||
|
for task in definition["tasks"]:
|
||
|
for req in task["requires"]:
|
||
|
dot.edge(req, task['id'])
|
||
|
|
||
|
dot.render('out/round-table.gv', view=True)
|