9 yaml_name = "../adventure.yaml"
11 def loc_coverage(locations, text):
12 for locname, loc in locations:
13 if loc["description"]["long"] == None or loc["description"]["long"] == '':
14 loc["description"]["long"] = True
15 if loc["description"]["long"] != True:
16 if text.find(loc["description"]["long"]) != -1:
17 loc["description"]["long"] = True
18 if loc["description"]["short"] == None or loc["description"]["short"] == '':
19 loc["description"]["short"] = True
20 if loc["description"]["short"] != True:
21 if text.find(loc["description"]["short"]) != -1:
22 loc["description"]["short"] = True
24 def arb_coverage(arb_msgs, text):
25 for i, msg in enumerate(arb_msgs):
26 (msg_name, msg_text) = msg
27 if msg_text == None or msg_text == '':
28 arb_msgs[i] = (msg_name, True)
29 elif msg_text != True:
30 if text.find(msg_text) != -1:
31 arb_msgs[i] = (msg_name, True)
33 def obj_coverage(objects, text):
34 for i, objouter in enumerate(objects):
35 (obj_name, obj) = objouter
36 if obj["descriptions"]:
37 for j, desc in enumerate(obj["descriptions"]):
38 if desc == None or desc == '':
39 obj["descriptions"][j] = True
40 objects[i] = (obj_name, obj)
42 if text.find(desc) != -1:
43 obj["descriptions"][j] = True
44 objects[i] = (obj_name, obj)
46 if __name__ == "__main__":
47 with open(yaml_name, "r") as f:
50 locations = db["locations"]
51 arb_msgs = db["arbitrary_messages"]
52 objects = db["objects"]
55 for filename in os.listdir(test_dir):
56 if filename.endswith(".chk"):
57 with open(filename, "r") as chk:
59 loc_coverage(locations, text)
60 arb_coverage(arb_msgs, text)
61 obj_coverage(objects, text)
63 for locouter in locations:
66 if loc["description"]["long"] != True:
67 print("%s long description not covered!" % locname)
68 if loc["description"]["short"] != True:
69 print("location: %s short description not covered!" % locname)
71 for name, msg in arb_msgs:
73 print("arbitrary message: %s not covered!" % name)
75 for (obj_name, obj) in objects:
76 if obj["descriptions"]:
77 for j, desc in enumerate(obj["descriptions"]):
79 print("object: %s desctiption #%d not covered!" % (obj_name, j))