Browse Source

Add read_incoming/outgoing

Yentl Van Tendeloo 8 years ago
parent
commit
0444b5f6bc
1 changed files with 26 additions and 11 deletions
  1. 26 11
      wrappers/modelverse.py

+ 26 - 11
wrappers/modelverse.py

@@ -712,16 +712,23 @@ def read_outgoing(ID, typename):
     # return [name1, name2, ...]
     # raises UnknownError
     # raises UnknownIdentifier
-    # raises UnknownType
     if mode != 3:
         raise InvalidMode()
+
     _input("read_outgoing")
+    _output("Element to read from?")
     _input(ID)
-    _input(typename)
-    lst = []
-    while (_output() != "Please give your command."):
-        lst.append(_last_output())
-    return lst
+    if _output() == "Type of outgoing edge (empty for all)?":
+        _input(typename)
+        lst = []
+        while (_output() != "Please give your command."):
+            lst.append(_last_output())
+        return lst
+    elif _last_output() == "Unknown element; aborting":
+        _output("Please give your command.")
+        raise UnknownIdentifier()
+    else:
+        raise InterfaceMismatch()
 
 def read_incoming(ID, typename):
     """Returns a list of all incoming associations of a specific type ("" = all)"""
@@ -731,13 +738,21 @@ def read_incoming(ID, typename):
     # raises UnknownType
     if mode != 3:
         raise InvalidMode()
+
     _input("read_incoming")
+    _output("Element to read from?")
     _input(ID)
-    _input(typename)
-    lst = []
-    while (_output() != "Please give your command."):
-        lst.append(_last_output())
-    return lst
+    if _output() == "Type of incoming edge (empty for all)?":
+        _input(typename)
+        lst = []
+        while (_output() != "Please give your command."):
+            lst.append(_last_output())
+        return lst
+    elif _last_output() == "Unknown element; aborting":
+        _output("Please give your command.")
+        raise UnknownIdentifier()
+    else:
+        raise InterfaceMismatch()
 
 def read_association_source(ID):
     """Returns the source of an association."""