Browse Source

Try out some change in the wrapper for Addis

Yentl Van Tendeloo 8 years ago
parent
commit
ac0610dc12
1 changed files with 23 additions and 22 deletions
  1. 23 22
      wrappers/modelverse.py

+ 23 - 22
wrappers/modelverse.py

@@ -603,29 +603,30 @@ def read_attrs(model_name, ID):
     if mode != 3:
         raise InvalidMode()
 
-    try:
-        _input("read")
-        _output("Element to read?")
-        _input(ID)
-        if _output() == "Unknown element; aborting":
-            _output("Please give your command.")
-            raise UnknownIdentifier()
-        elif _last_output() == "ID: " + str(ID):
-            rval = {}
-            # Skip until attributes
-            while (_output() != "Attributes:"):
-                pass
-            while (_output() != "Please give your command."):
-                r = _last_output()
-                key, value = r.split(":")
-                _, value = value.split("=")
-                key = json.loads(key.strip())
-                value = value.strip()
-                value = None if value == "None" else json.loads(value)
-                rval[key] = value
-            return rval
-    finally:
+    _input("read")
+    _output("Element to read?")
+    _input(ID)
+    if _output() == "Unknown element; aborting":
+        _output("Please give your command.")
         model_exit()
+        raise UnknownIdentifier()
+    elif _last_output() == "ID: " + str(ID):
+        rval = {}
+        # Skip until attributes
+        while (_output() != "Attributes:"):
+            pass
+        while (_output() != "Please give your command."):
+            r = _last_output()
+            key, value = r.split(":")
+            _, value = value.split("=")
+            key = json.loads(key.strip())
+            value = value.strip()
+            value = None if value == "None" else json.loads(value)
+            rval[key] = value
+        model_exit()
+        return rval
+    else:
+        raise InterfaceMismatch(_last_output())
 
 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)"""