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

Function parse_wildcard_id

dash/_layout_utils.py:147–170  ·  view source on GitHub ↗

Parse a component ID and return it as a dict if it contains a wildcard. Accepts string (JSON-encoded) or dict IDs. Returns ``None`` if the ID is not a wildcard pattern. Example:: >>> parse_wildcard_id('{"type":"input","index":["ALL"]}') {"type": "input", "index": ["ALL

(pid: Any)

Source from the content-addressed store, hash-verified

145
146
147def parse_wildcard_id(pid: Any) -> dict | None:
148 """Parse a component ID and return it as a dict if it contains a wildcard.
149
150 Accepts string (JSON-encoded) or dict IDs. Returns ``None``
151 if the ID is not a wildcard pattern.
152
153 Example::
154
155 >>> parse_wildcard_id('{"type":"input","index":["ALL"]}')
156 {"type": "input", "index": ["ALL"]}
157 >>> parse_wildcard_id("my-dropdown")
158 None
159 """
160 if isinstance(pid, str) and pid.startswith("{"):
161 try:
162 pid = json.loads(pid)
163 except (json.JSONDecodeError, ValueError):
164 return None
165 if not isinstance(pid, dict):
166 return None
167 for v in pid.values():
168 if isinstance(v, list) and len(v) == 1 and v[0] in _WILDCARD_VALUES:
169 return pid
170 return None
171
172
173def find_matching_components(pattern: dict) -> list[Component]:

Callers 10

_expand_depFunction · 0.90
_expand_output_specFunction · 0.90
get_schemaMethod · 0.90
_infer_value_schemaFunction · 0.90
describeMethod · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…