|
@@ -611,11 +611,33 @@ def attr_assign(ID, attr, value):
|
|
|
# raises UnsupportedValue
|
|
|
if mode != 3:
|
|
|
raise InvalidMode()
|
|
|
- _input("attr_modify")
|
|
|
- _input(ID)
|
|
|
- _input(attr)
|
|
|
- _input(value)
|
|
|
- _consume_to_end()
|
|
|
+
|
|
|
+ _input("attr_add")
|
|
|
+ if _output() == "Which element do you want to assign an attribute to?":
|
|
|
+ _input(ID)
|
|
|
+ if _output() == "Which attribute do you want to assign?":
|
|
|
+ _input(attr)
|
|
|
+ if _output() == "Value of attribute?":
|
|
|
+ _input(value)
|
|
|
+ _output("Added attribute!")
|
|
|
+ _output("Please give your command.")
|
|
|
+ elif _last_output() == "No such attribute!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise NoSuchAttribute()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+
|
|
|
+ elif _last_output() == "No such element!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise UnknownIdentifier()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+
|
|
|
+ elif _last_output() == "Permission denied":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise PermissionDenied()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
|
|
|
def attr_assign_code(ID, attr, code):
|
|
|
"""Assign a piece of Action Language code to the attribute"""
|
|
@@ -626,20 +648,64 @@ def attr_assign_code(ID, attr, code):
|
|
|
# raises UnsupportedValue
|
|
|
if mode != 3:
|
|
|
raise InvalidMode()
|
|
|
- _input("attr_modify")
|
|
|
- _input(ID)
|
|
|
- _input(attr)
|
|
|
- _compile_AL(code)
|
|
|
+ try:
|
|
|
+ compiled = _compile_AL(code)
|
|
|
+ except Exception as e:
|
|
|
+ raise CompilationError(e)
|
|
|
|
|
|
-def upload(new_model):
|
|
|
- """Overwrite the current model with the provided model"""
|
|
|
- # return None
|
|
|
- # raises UnknownError
|
|
|
- # raises CompilationError
|
|
|
+ _input("attr_add")
|
|
|
+ if _output() == "Which element do you want to assign an attribute to?":
|
|
|
+ _input(ID)
|
|
|
+ if _output() == "Which attribute do you want to assign?":
|
|
|
+ _input(attr)
|
|
|
+ if _output() == "Waiting for code constructors...":
|
|
|
+ _input(compiled)
|
|
|
+ _output("Added attribute!")
|
|
|
+ _output("Please give your command.")
|
|
|
+ elif _last_output() == "No such attribute!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise NoSuchAttribute()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+
|
|
|
+ elif _last_output() == "No such element!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise UnknownIdentifier()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+
|
|
|
+ elif _last_output() == "Permission denied":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise PermissionDenied()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+
|
|
|
+def attr_delete(ID, attr):
|
|
|
+ """Remove an attribute."""
|
|
|
if mode != 3:
|
|
|
raise InvalidMode()
|
|
|
- _input("upload")
|
|
|
- _compile_model(new_model)
|
|
|
+ _input("attr_del")
|
|
|
+ if _output() == "Which element do you want to remove an attribute of?":
|
|
|
+ _input(ID)
|
|
|
+ if _output() == "Which attribute do you want to delete?":
|
|
|
+ _input(attr)
|
|
|
+ if _output() == "Attribute deleted!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ elif _last_output() == "No such attribute!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise NoSuchAttribute()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+ elif _last_output() == "No such element!":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise UnknownIdentifier()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
+ elif _last_output() == "Permission denied":
|
|
|
+ _output("Please give your command.")
|
|
|
+ raise PermissionDenied()
|
|
|
+ else:
|
|
|
+ raise InterfaceMismatch(_last_output())
|
|
|
|
|
|
def read_outgoing(ID, typename):
|
|
|
"""Returns a list of all outgoing associations of a specific type ("" = all)"""
|