import sys
sys.path.append("wrappers")
from modelverse import *

init()
login("admin", "admin")
model_add("formalisms/MvK_rules_MM", "formalisms/SimpleClassDiagrams", open("kernel/rules/MvK_rules_MM.mvc", 'r').read())
model_add("formalisms/Files", "formalisms/SimpleClassDiagrams", open("kernel/rules/files.mvc", 'r').read())
model_add("models/MvK_rules", "formalisms/MvK_rules_MM", open("kernel/rules/MvK_rules.mvc", 'r').read())
transformation_add_AL({"Rules": "formalisms/MvK_rules_MM"}, {"Files": "formalisms/Files"}, "models/to_python", open("kernel/rules/to_python.alc", 'r').read())
transformation_add_AL({"Rules": "formalisms/MvK_rules_MM"}, {"Files": "formalisms/Files"}, "models/to_graphviz", open("kernel/rules/to_graphviz.alc", 'r').read())
transformation_add_AL({"Files": "formalisms/Files"}, {}, "models/write_files", open("kernel/rules/write_files.alc", 'r').read())

print("Writing to Python...")
transformation_execute_AL("models/to_python", {"Rules": "models/MvK_rules"}, {"Files": "models/py_files"})
print("Writing to Graphviz...")
transformation_execute_AL("models/to_graphviz", {"Rules": "models/MvK_rules"}, {"Files": "models/dot_files"})
print("Writing to file...")
transformation_execute_AL("models/write_files", {"Files": "models/py_files"}, {})
transformation_execute_AL("models/write_files", {"Files": "models/dot_files"}, {})
print("DONE")
