MCPcopy Index your code
hub / github.com/plotly/dash / find_matching_components

Function find_matching_components

dash/_layout_utils.py:173–190  ·  view source on GitHub ↗

Find all components whose dict ID matches a wildcard pattern. Non-wildcard keys must match exactly. Wildcard keys are ignored.

(pattern: dict)

Source from the content-addressed store, hash-verified

171
172
173def find_matching_components(pattern: dict) -> list[Component]:
174 """Find all components whose dict ID matches a wildcard pattern.
175
176 Non-wildcard keys must match exactly. Wildcard keys are ignored.
177 """
178 non_wildcard_keys = {
179 k: v
180 for k, v in pattern.items()
181 if not (isinstance(v, list) and len(v) == 1 and v[0] in _WILDCARD_VALUES)
182 }
183 matches = []
184 for comp, _ in traverse():
185 comp_id = getattr(comp, "id", None)
186 if not isinstance(comp_id, dict):
187 continue
188 if all(comp_id.get(k) == v for k, v in non_wildcard_keys.items()):
189 matches.append(comp)
190 return matches
191
192
193def extract_text(component: Component) -> str:

Callers 2

_expand_output_specFunction · 0.90
_infer_value_schemaFunction · 0.90

Calls 3

traverseFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…