-def compat_open(path):
- """Invokes open correctly depending on the Python version"""
- if sys.version_info.major < 3:
- return open(path, "wb")
- else:
- return open(path, "w", newline="")
+def select_heat_requirements(reqs):
+ """Filters dict requirements to only those requirements pertaining to Heat"""
+ return {k: v for k, v in reqs.items() if "Heat" in v["docname"]}
+
+
+def build_rst_json(reqs):
+ """Takes requirements and returns list of only Heat requirements"""
+ data = json.loads(reqs)
+ for key, values in list(data.items()):
+ if "Heat" in (values["docname"]):
+ if "MUST" in (values["keyword"]):
+ if "none" in (values["validation_mode"]):
+ del data[key]
+ else:
+ # Creates links in RST format to requirements and test cases
+ if values["test_case"]:
+ mod = values["test_case"].split(".")[-1]
+ val = TEST_SCRIPT_SITE + mod + ".py"
+ rst_value = ("`" + mod + " <" + val + ">`_")
+ title = "`" + values["id"] + " <" + VNFRQTS_ID_URL + values["docname"].replace(" ", "%20") + ".html#" + values["id"] + ">`_"
+ data[key].update({'full_title': title, 'test_case': rst_value})
+ else:
+ del data[key]
+ else:
+ del data[key]
+ else:
+ del data[key]
+ return data