in tools/resource.py [0:0]
def _get_property_schema(self, ast_prop, path):
if ast_prop["NodeType"] == "CallExpr":
path_or_url, t = self.path_or_url()
raise ValueError(
f'Found function call in schema "{path}", not supported. Path: {path_or_url}'
)
prop = {"Required": True}
for elt in ast_prop["Elts"]:
elt_key_name = elt["Key"]["Name"]
elt_value = elt["Value"]
if elt_key_name == "Type":
prop["Type"] = self.TYPE_MAPPING[elt_value["Sel"]["Name"]]
elif elt_key_name == "Optional":
prop["Required"] = elt_value["Name"] == '"True"'
elif elt_key_name == "Elem":
node_type = elt_value["NodeType"]
if node_type == "UnaryExpr":
if elt_value["Op"] == "&":
x = elt_value["X"]
x_name = x["Type"]["Sel"]["Name"]
new_prop_path = f"{path}.*"
if x_name == "Schema":
sub_prop = self._get_property_schema(x, new_prop_path)
prop["Schema"] = {"*": sub_prop}
elif x_name == "Resource":
sub_props = self._get_properties_schema(
x["Elts"][0]["Value"], new_prop_path
)
prop["Schema"] = {
"*": {
"Required": False,
"Type": "map",
"Schema": sub_props,
}
}
return prop