Browse Source

Added read_association_source/destination

Yentl Van Tendeloo 8 years ago
parent
commit
f72ed32bc9
2 changed files with 56 additions and 0 deletions
  1. 26 0
      core/mini_modify.alc
  2. 30 0
      wrappers/modelverse.py

+ 26 - 0
core/mini_modify.alc

@@ -338,6 +338,32 @@ Element function modify(model : Element, write : Boolean):
 			else:
 				output("Permission denied")
 
+		elif (cmd == "read_association_source"):
+			output("Association to read source of?")
+			cmd = input()
+
+			if (dict_in(model["model"], cmd)):
+				if (is_edge(model["model"][cmd])):
+					output("Read source:")
+					output(readAssociationSource(model, cmd))
+				else:
+					output("Not an association; aborting")
+			else:
+				output("Unknown element; aborting")
+
+		elif (cmd == "read_association_destination"):
+			output("Association to read destination of?")
+			cmd = input()
+
+			if (dict_in(model["model"], cmd)):
+				if (is_edge(model["model"][cmd])):
+					output("Read destination:")
+					output(readAssociationDestination(model, cmd))
+				else:
+					output("Not an association; aborting")
+			else:
+				output("Unknown element; aborting")
+
 		else:
 			output("Unknown command: " + cast_v2s(cmd))
 			output("Use command 'help' to get a list of available commands")

+ 30 - 0
wrappers/modelverse.py

@@ -761,6 +761,21 @@ def read_association_source(ID):
     # raises UnknownError
     # raises UnknownIdentifier
     # raises NotAnAssociation
+    _input("read_association_source")
+    _output("Association to read source of?")
+    _input(ID)
+    if _output() == "Read source:":
+        result = _output()
+        _output("Please give your command.")
+        return result
+    elif _last_output() == "Unknown element; aborting":
+        _output("Please give your command.")
+        raise UnknownIdentifier()
+    elif _last_output() == "Not an association; aborting":
+        _output("Please give your command.")
+        raise NotAnEdge()
+    else:
+        raise InterfaceMismatch(_last_output())
 
 def read_association_destination(ID):
     """Returns the destination of an association."""
@@ -769,6 +784,21 @@ def read_association_destination(ID):
     # raises UnknownError
     # raises UnknownIdentifier
     # raises NotAnAssociation
+    _input("read_association_destination")
+    _output("Association to read destination of?")
+    _input(ID)
+    if _output() == "Read destination:":
+        result = _output()
+        _output("Please give your command.")
+        return result
+    elif _last_output() == "Unknown element; aborting":
+        _output("Please give your command.")
+        raise UnknownIdentifier()
+    elif _last_output() == "Not an association; aborting":
+        _output("Please give your command.")
+        raise NotAnEdge()
+    else:
+        raise InterfaceMismatch(_last_output())
 
 def model_exit():
     """Leave model modify mode."""