|
@@ -124,6 +124,7 @@ Element function petrinet_loaded(model : Element):
|
|
|
output(" delete -- Delete an existing element")
|
|
|
output(" attr_add -- Add an attribute to an existing element")
|
|
|
output(" rename -- Rename an existing element")
|
|
|
+ output(" modify -- Modify the attributes of an element")
|
|
|
output(" list -- Prints the list of elements in the model")
|
|
|
output(" types -- Prints the list of elements that can be instantiated")
|
|
|
output(" read -- Prints the current state of a model element")
|
|
@@ -178,6 +179,25 @@ Element function petrinet_loaded(model : Element):
|
|
|
output("Instantiation error!")
|
|
|
else:
|
|
|
output("Unknown type specified; aborting")
|
|
|
+ elif (cmd == "modify"):
|
|
|
+ String model_name
|
|
|
+ output("Element to modify?")
|
|
|
+ model_name = input()
|
|
|
+ if (dict_in(model["model"], model_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, model_name)
|
|
|
+ String attr_name
|
|
|
+ output("Attribute to modify?")
|
|
|
+ attr_name = input()
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ output("New value?")
|
|
|
+ unset_attribute(model, model_name, attr_name)
|
|
|
+ instantiate_attribute(model, model_name, attr_name, input())
|
|
|
+ output("Modified!")
|
|
|
+ else:
|
|
|
+ output("No such attribute!")
|
|
|
+ else:
|
|
|
+ output("No such model!")
|
|
|
elif (cmd == "attr_add"):
|
|
|
String model_name
|
|
|
output("Which model do you want to assign an attribute to?")
|
|
@@ -197,11 +217,28 @@ Element function petrinet_loaded(model : Element):
|
|
|
output("No such attribute!")
|
|
|
else:
|
|
|
output("No such model!")
|
|
|
+ elif (cmd == "attr_del"):
|
|
|
+ String model_name
|
|
|
+ output("Which model do you want to remove an attribute of?")
|
|
|
+ model_name = input()
|
|
|
+ if (dict_in(model["model"], model_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, model_name)
|
|
|
+ output(print_dict(attrs))
|
|
|
+ String attr_name
|
|
|
+ output("Which attribute do you want to delete?")
|
|
|
+ attr_name = input()
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ unset_attribute(model, model_name, attr_name)
|
|
|
+ else:
|
|
|
+ output("No such attribute!")
|
|
|
+ else:
|
|
|
+ output("No such model!")
|
|
|
elif (cmd == "delete"):
|
|
|
output("What is the name of the element you want to delete?")
|
|
|
cmd = input()
|
|
|
if (dict_in(model["model"], cmd)):
|
|
|
- delete_element(model["model"][cmd])
|
|
|
+ model_delete_element(model, cmd)
|
|
|
output("Deleted!")
|
|
|
else:
|
|
|
output("No such element; aborting")
|