MCPcopy
hub / github.com/plotly/dash / collect_nodes

Function collect_nodes

dash/development/_collect_nodes.py:49–74  ·  view source on GitHub ↗
(metadata, base="", nodes=None)

Source from the content-addressed store, hash-verified

47
48
49def 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
77def filter_base_nodes(nodes):

Callers 6

generate_class_stringFunction · 0.90
test_dcn002_base_nodesFunction · 0.90
collect_arrayFunction · 0.85
collect_unionFunction · 0.85
collect_objectFunction · 0.85

Calls 7

is_nodeFunction · 0.85
collect_arrayFunction · 0.85
is_shapeFunction · 0.85
collect_unionFunction · 0.85
collect_objectFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by 2

test_dcn002_base_nodesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…