(metadata, base="", nodes=None)
| 47 | |
| 48 | |
| 49 | def collect_nodes(metadata, base="", nodes=None): |
| 50 | nodes = nodes or [] |
| 51 | |
| 52 | for prop_name, value in metadata.items(): |
| 53 | # Support for recursive shapes, the type is directly in the field. |
| 54 | t_value = value.get("type", value) |
| 55 | p_type = t_value.get("name") |
| 56 | |
| 57 | if base: |
| 58 | key = f"{base}.{prop_name}" |
| 59 | else: |
| 60 | key = prop_name |
| 61 | if is_node(p_type): |
| 62 | nodes.append(key) |
| 63 | elif p_type == "arrayOf": |
| 64 | a_value = t_value.get("value", t_value) |
| 65 | nodes = collect_array(a_value, key, nodes) |
| 66 | elif is_shape(p_type): |
| 67 | nodes = collect_nodes(t_value["value"], key, nodes) |
| 68 | elif p_type == "union": |
| 69 | nodes = collect_union(t_value["value"], key, nodes) |
| 70 | elif p_type == "objectOf": |
| 71 | o_value = t_value.get("value", {}) |
| 72 | nodes = collect_object(o_value, key, nodes) |
| 73 | |
| 74 | return nodes |
| 75 | |
| 76 | |
| 77 | def filter_base_nodes(nodes): |
searching dependent graphs…