Przeglądaj źródła

Fixed set_difference and made some new operations/altered them for the GUI

Yentl Van Tendeloo 7 lat temu
rodzic
commit
7d7a5b50ab

+ 4 - 4
bootstrap/conformance_finding.alc

@@ -32,10 +32,10 @@ Boolean function find_type_mapping(model : Element):
 	// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
 	// TODO this must be expanded for other things than trivial metamodels!
 	if (dict_len(model["model"]) > dict_len(tm)):
-		//log("Model is incompletely typed!")
-		//log("Model has: " + set_to_string(dict_keys(model["model"])))
-		//log("Type mapping has: " + set_to_string(dict_keys(tm)))
-		//log("Missing: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
+		log("Model is incompletely typed!")
+		log("Model has: " + set_to_string(dict_keys(model["model"])))
+		log("Type mapping has: " + set_to_string(dict_keys(tm)))
+		log("Difference: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
 
 		// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
 		//      and it makes the assumption that SCD is the M3 level...

+ 3 - 1
bootstrap/mini_modify.alc

@@ -321,7 +321,7 @@ String function cmd_read_attrs(model : Element, element_name : String):
 		attr_keys = dict_keys(attr_list)
 		while (0 < set_len(attr_keys)):
 			attr_key = set_pop(attr_keys)
-			result = ((((((result + "  ") + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, element_name, attr_key))) + "\n"
+			result = ((((string_join(result, attr_key) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, element_name, attr_key))) + "\n"
 		return result!
 	else:
 		return "Element not found: " + element_name!
@@ -423,6 +423,8 @@ Element function modify(model : Element, write : Boolean):
 			output(cmd_read_incoming(model, single_input("Name?"), single_input("Type?")))
 		elif (cmd == "read"):
 			output(cmd_read(model, single_input("Name?")))
+		elif (cmd == "read_attrs"):
+			output(cmd_read_attrs(model, single_input("Name?")))
 		elif (cmd == "types"):
 			output(cmd_types(model))
 		elif (cmd == "retype"):

+ 0 - 10
bootstrap/utils.alc

@@ -88,15 +88,5 @@ Void function list_extend(lst : Element, ext : Element):
 
 	return!
 
-Void function set_difference(set1 : Element, set2 : Element):
-	set2 = set_copy(set2)
-
-	Element elem
-	while (set_len(set2) > 0):
-		elem = set_pop(set2)
-		if (set_in(set1, elem)):
-			set_remove(set1, elem)
-	return!
-
 String function get_taskname():
 	return reverseKeyLookup(read_root(), read_taskroot())!

+ 1 - 1
interface/HUTN/includes/primitives.alh

@@ -108,8 +108,8 @@ String function set_to_string(set : Element)
 String function list_to_string(set : Element)
 String function dict_to_string(dict : Element)
 Element function set_overlap(sa : Element, sb : Element)
-Element function set_difference(sa : Element, sb : Element)
 Element function set_equality(sa : Element, sb : Element)
+Element function set_difference(sa : Element, sb : Element)
 Element function dict_eq(da : Element, db : Element)
 Element function dict_copy(dict : Element)
 Element function set_to_list(s : Element)

+ 0 - 1
interface/HUTN/includes/utils.alh

@@ -2,6 +2,5 @@ String function JSON_print(model : Element)
 Element function list_reverse(lst : Element)
 Element function list_splice(lst : Element, start : Integer, end : Integer)
 Void function list_extend(lst : Element, ext : Element)
-Void function set_difference(set1 : Element, set2 : Element)
 String function get_taskname()
 Void function sleep(seconds : Float)

+ 2 - 2
wrappers/classes/modelverse.xml

@@ -1131,8 +1131,8 @@
                         <transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
                             <script>
                                 response = self.responses.pop(0).strip()
-                                _, response = response.split(": ", 1)
-                                values = {line.split(": ", 1)[0]: line.split(": ", 1)[1] for line in response.split("\n")}
+                                _, response = response.split(" : ", 1)
+                                values = {line.split(" : ", 1)[0]: line.split(" : ", 1)[1] for line in response.split("\n")}
                                 values = {key: values[key].split(" = ", 1)[1] for key in values}
                             </script>
                             <raise event="result">