in 02_bootstrap-scripts-python/bootstrap/context.py [0:0]
def GetValues(self) -> dict:
filename = self.indicator
parsetype = ""
sep: str = self.options.get("separator", ".")
if "type" in self.options.keys():
parsetype = self.options["type"]
with open(filename, 'r') as stream:
if parsetype.lower() == "yaml":
obj = _yaml.load(stream)
else:
obj = json.load(stream)
if "pathfilter" in self.options.keys():
expr = parse("$" + self.options["pathfilter"])
try:
obj = expr.find(obj)[0].value
except Exception as e:
print(e)
print(f"Primary: {self.indicator}")
print(f"Options: {self.options}")
print("Filter returned no results, returning null")
return {}
if "key" in self.options.keys():
new_values: dict = {}
stringToNestedObject(
self.options["key"], obj, new_values, separator=sep)
obj = new_values
return obj