فهرست منبع

Fixed bugs in wrapper

Yentl Van Tendeloo 8 سال پیش
والد
کامیت
da788db061
3فایلهای تغییر یافته به همراه28 افزوده شده و 5 حذف شده
  1. 2 2
      core/mini_modify.alc
  2. 24 3
      wrappers/modelverse.py
  3. 2 0
      wrappers/test_modelverse.py

+ 2 - 2
core/mini_modify.alc

@@ -306,7 +306,7 @@ String function cmd_retype(write : Boolean, model : Element, element_name : Stri
 String function cmd_read_association_source(write : Boolean, model : Element, element_name : String):
 	if (dict_in(model["model"], element_name)):
 		if (is_edge(model["model"][element_name])):
-			return readAssociationSource(model, element_name)!
+			return "Success: " + readAssociationSource(model, element_name)!
 		else:
 			return "Not an association: " + element_name!
 	else:
@@ -315,7 +315,7 @@ String function cmd_read_association_source(write : Boolean, model : Element, el
 String function cmd_read_association_destination(write : Boolean, model : Element, element_name : String):
 	if (dict_in(model["model"], element_name)):
 		if (is_edge(model["model"][element_name])):
-			return readAssociationDestination(model, element_name)!
+			return "Success: " + readAssociationDestination(model, element_name)!
 		else:
 			return "Not an association: " + element_name!
 	else:

+ 24 - 3
wrappers/modelverse.py

@@ -140,7 +140,11 @@ def _handle_output(requested=None, split=None):
         if split is None:
             return value
         else:
-            return value.strip().split(split, 1)[1].rstrip()
+            splitted = value.strip().split(split, 1)
+            if len(splitted) == 1:
+                return ""
+            else:
+                return splitted[1].rstrip()
     else:
         raise InterfaceMismatch(value)
     
@@ -254,6 +258,9 @@ def model_list():
         raise InvalidMode()
     _input("model_list")
     output = _handle_output("Success: ", split=" ")
+    if output == "":
+        return []
+
     lst = []
     value = output.strip().split("\n")
     for v in value:
@@ -355,6 +362,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")]
 
 def transformation_add_MT_language():
@@ -459,6 +468,8 @@ def element_list(model_name):
         _input("list_full")
         lst = []
         output = _handle_output("Success: ", split=" ")
+        if output == "":
+            return []
         for v in output.split("\n"):
             m, mm = v.split(":")
             m = m.strip()
@@ -482,6 +493,8 @@ def types(model_name):
         _input("types")
         lst = []
         output = _handle_output("Success: ", split=" ")
+        if output == "":
+            return []
         for v in output.split("\n"):
             m, mm = v.split(":")
             m = m.strip()
@@ -504,6 +517,8 @@ def types_full(model_name):
         _input("types")
         lst = []
         output = _handle_output("Success: ", split=" ")
+        if output == "":
+            return []
         for v in output.split("\n"):
             m, mm = v.split(":")
             m = m.strip()
@@ -686,7 +701,10 @@ def read_outgoing(model_name, ID, typename):
     try:
         _input(["read_outgoing", ID, typename])
         output = _handle_output("Success: ", split=" ")
-        return output.split("\n")
+        if output == "":
+            return []
+        else:
+            return output.split("\n")
     finally:
         model_exit()
 
@@ -704,7 +722,10 @@ def read_incoming(model_name, ID, typename):
     try:
         _input(["read_incoming", ID, typename])
         output = _handle_output("Success: ", split=" ")
-        return output.split("\n")
+        if output == "":
+            return []
+        else:
+            return output.split("\n")
     finally:
         model_exit()
 

+ 2 - 0
wrappers/test_modelverse.py

@@ -39,6 +39,8 @@ except UnknownIdentifier:
             t1 = instantiate(model_name2, "Transition")
             p2t = instantiate(model_name2, "P2T", (p1, t1))
             t2p = instantiate(model_name2, "T2P", (t1, p2))
+            print(read_outgoing(model_name2, p1, "P2T"))
+            print(read_outgoing(model_name2, p2, "P2T"))
             print(element_list(model_name2))
             print(read_attrs(model_name2, p1))
             attr_assign(model_name2, p1, "name", "p1")