|
@@ -21,7 +21,7 @@ from hutn_compiler.compiler import main as do_compile
|
|
|
class ModelverseException(Exception):
|
|
|
pass
|
|
|
|
|
|
-class UnknownException(ModelverseException):
|
|
|
+class UnknownError(ModelverseException):
|
|
|
pass
|
|
|
|
|
|
class UnknownIdentifier(ModelverseException):
|
|
@@ -265,15 +265,15 @@ def model_list():
|
|
|
_input("model_list")
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
|
|
|
- lst = []
|
|
|
+ lst = set([])
|
|
|
value = output.strip().split("\n")
|
|
|
for v in value:
|
|
|
m, mm = v.split(":")
|
|
|
m = m.strip()
|
|
|
mm = mm.strip()
|
|
|
- lst.append((m, mm))
|
|
|
+ lst.add((m, mm))
|
|
|
|
|
|
return lst
|
|
|
|
|
@@ -284,14 +284,19 @@ def model_list_full():
|
|
|
if mode != MODE_MODELLING:
|
|
|
raise InvalidMode()
|
|
|
_input("model_list_full")
|
|
|
- lst = []
|
|
|
- value = _output().strip().split("\n")
|
|
|
+ output = _handle_output("Success: ", split=" ")
|
|
|
+ if output == "":
|
|
|
+ return set([])
|
|
|
+
|
|
|
+ lst = set([])
|
|
|
+ value = output.strip().split("\n")
|
|
|
for v in value:
|
|
|
+ print("READ " + v)
|
|
|
m, mm = v.split(":")
|
|
|
m = m.strip()
|
|
|
mm = mm.strip()
|
|
|
perm, own, grp, m = m.split(" ")
|
|
|
- lst.append((m, mm, own, grp, perm))
|
|
|
+ lst.add((m, mm, own, grp, perm))
|
|
|
|
|
|
return lst
|
|
|
|
|
@@ -331,7 +336,7 @@ def model_overwrite(model_name, new_model=None):
|
|
|
def user_logout():
|
|
|
"""Log out the current user and break the connection."""
|
|
|
# return None
|
|
|
- # raises UnknownException
|
|
|
+ # raises UnknownError
|
|
|
global mode
|
|
|
if mode != MODE_MODELLING:
|
|
|
raise InvalidMode()
|
|
@@ -341,7 +346,7 @@ def user_logout():
|
|
|
def user_delete():
|
|
|
"""Removes the current user and break the connection."""
|
|
|
# return None
|
|
|
- # raises UnknownException
|
|
|
+ # raises UnknownError
|
|
|
global mode
|
|
|
if mode != MODE_MODELLING:
|
|
|
raise InvalidMode()
|
|
@@ -351,7 +356,7 @@ def user_delete():
|
|
|
def model_render(model, mapper):
|
|
|
"""Fetch a rendered verion of a model."""
|
|
|
# return JSON_representation
|
|
|
- # raises UnknownException
|
|
|
+ # raises UnknownError
|
|
|
# raises UnknownIdentifier
|
|
|
# raises InterfaceMismatch
|
|
|
global mode
|
|
@@ -369,8 +374,8 @@ def transformation_between(source, target):
|
|
|
_input(["transformation_between", source, target])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
- lst = [v for v in output.split("\n")]
|
|
|
+ return set([])
|
|
|
+ lst = set([v for v in output.split("\n")])
|
|
|
|
|
|
def transformation_add_MT_language(metamodels, RAMified_name):
|
|
|
"""Create a new Model Transformation language out of a set of metamodels."""
|
|
@@ -467,6 +472,7 @@ def transformation_execute_MT(operation_name, input_models_dict, output_models_d
|
|
|
|
|
|
# We are now executing, so everything we get is part of the dialog, except if it is the string for transformation termination
|
|
|
while _output() not in ["Success", "Failure"]:
|
|
|
+ print("Got output: " + str(_last_output()))
|
|
|
reply = callback(_last_output())
|
|
|
if reply is not None:
|
|
|
_input(reply)
|
|
@@ -479,19 +485,37 @@ def transformation_execute_MT(operation_name, input_models_dict, output_models_d
|
|
|
|
|
|
def transformation_list():
|
|
|
"""List existing model operations."""
|
|
|
- raise NotImplementedError()
|
|
|
+ global mode
|
|
|
+ if mode != MODE_MODELLING:
|
|
|
+ raise InvalidMode()
|
|
|
|
|
|
-def transformation_list_full():
|
|
|
- """List detailed information on model operations."""
|
|
|
- raise NotImplementedError()
|
|
|
+ _input("transformation_list")
|
|
|
+ output = _handle_output("Success: ", split=" ")
|
|
|
+ if output == "":
|
|
|
+ return set([])
|
|
|
+
|
|
|
+ lst = set([])
|
|
|
+ value = output.strip().split("\n")
|
|
|
+ for v in value:
|
|
|
+ t, m = v.strip().split(" ", 1)
|
|
|
+ t = t[1:-1].strip()
|
|
|
+ m = m.strip().split(":")[0].strip()
|
|
|
+ lst.add((t, m))
|
|
|
+
|
|
|
+ return lst
|
|
|
|
|
|
def transformation_detail():
|
|
|
"""List full details of a a model operation."""
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
-def transformation_RAMify():
|
|
|
+def transformation_RAMify(metamodel_name, RAMified_metamodel_name):
|
|
|
"""Ramify an existing metamodel."""
|
|
|
- raise NotImplementedError()
|
|
|
+ global mode
|
|
|
+ if mode != MODE_MODELLING:
|
|
|
+ raise InvalidMode()
|
|
|
+
|
|
|
+ _input(["transformation_RAMify", metamodel_name, RAMified_metamodel_name])
|
|
|
+ _handle_output("Success")
|
|
|
|
|
|
def process_execute():
|
|
|
"""Execute a process model."""
|
|
@@ -557,15 +581,15 @@ def element_list(model_name):
|
|
|
|
|
|
try:
|
|
|
_input("list_full")
|
|
|
- lst = []
|
|
|
+ lst = set([])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
for v in output.split("\n"):
|
|
|
m, mm = v.split(":")
|
|
|
m = m.strip()
|
|
|
mm = mm.strip()
|
|
|
- lst.append((m, mm))
|
|
|
+ lst.add((m, mm))
|
|
|
return lst
|
|
|
|
|
|
finally:
|
|
@@ -582,14 +606,14 @@ def types(model_name):
|
|
|
|
|
|
try:
|
|
|
_input("types")
|
|
|
- lst = []
|
|
|
+ lst = set([])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
for v in output.split("\n"):
|
|
|
m, mm = v.split(":")
|
|
|
m = m.strip()
|
|
|
- lst.append(m)
|
|
|
+ lst.add(m)
|
|
|
return lst
|
|
|
|
|
|
finally:
|
|
@@ -606,15 +630,15 @@ def types_full(model_name):
|
|
|
|
|
|
try:
|
|
|
_input("types")
|
|
|
- lst = []
|
|
|
+ lst = set([])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
for v in output.split("\n"):
|
|
|
m, mm = v.split(":")
|
|
|
m = m.strip()
|
|
|
mm = mm.strip()
|
|
|
- lst.append((m, mm))
|
|
|
+ lst.add((m, mm))
|
|
|
return lst
|
|
|
|
|
|
finally:
|
|
@@ -686,7 +710,7 @@ def read_attrs(model_name, ID):
|
|
|
finally:
|
|
|
model_exit()
|
|
|
|
|
|
-def instantiate(model_name, typename, edge=None):
|
|
|
+def instantiate(model_name, typename, edge=None, ID=""):
|
|
|
"""Create a new instance of the specified typename, between the selected elements (if not None), and with the provided ID (if any)"""
|
|
|
# return instantiated_ID
|
|
|
# raises UnknownError
|
|
@@ -700,9 +724,9 @@ def instantiate(model_name, typename, edge=None):
|
|
|
|
|
|
try:
|
|
|
if edge is None:
|
|
|
- _input(["instantiate_node", typename, ""])
|
|
|
+ _input(["instantiate_node", typename, ID])
|
|
|
else:
|
|
|
- _input(["instantiate_edge", typename, "", edge[0], edge[1]])
|
|
|
+ _input(["instantiate_edge", typename, ID, edge[0], edge[1]])
|
|
|
return _handle_output("Success: ", split=" ")
|
|
|
finally:
|
|
|
model_exit()
|
|
@@ -793,9 +817,9 @@ def read_outgoing(model_name, ID, typename):
|
|
|
_input(["read_outgoing", ID, typename])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
else:
|
|
|
- return output.split("\n")
|
|
|
+ return set(output.split("\n"))
|
|
|
finally:
|
|
|
model_exit()
|
|
|
|
|
@@ -814,9 +838,9 @@ def read_incoming(model_name, ID, typename):
|
|
|
_input(["read_incoming", ID, typename])
|
|
|
output = _handle_output("Success: ", split=" ")
|
|
|
if output == "":
|
|
|
- return []
|
|
|
+ return set([])
|
|
|
else:
|
|
|
- return output.split("\n")
|
|
|
+ return set(output.split("\n"))
|
|
|
finally:
|
|
|
model_exit()
|
|
|
|