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

Method _traverse_with_paths

dash/development/base_component.py:395–417  ·  view source on GitHub ↗

Yield each item with its path in the tree.

(self)

Source from the content-addressed store, hash-verified

393 return id_ and f" (id={id_:s})"
394
395 def _traverse_with_paths(self):
396 """Yield each item with its path in the tree."""
397 children = getattr(self, "children", None)
398 children_type = type(children).__name__
399 children_string = children_type + self._id_str(children)
400
401 # children is just a component
402 if isinstance(children, Component):
403 yield "[*] " + children_string, children
404 # pylint: disable=protected-access
405 for p, t in children._traverse_with_paths():
406 yield "\n".join(["[*] " + children_string, p]), t
407
408 # children is a list of components
409 elif isinstance(children, (tuple, MutableSequence)):
410 for idx, i in enumerate(children): # type: ignore[reportOptionalIterable]
411 list_path = f"[{idx:d}] {type(i).__name__:s}{self._id_str(i)}"
412 yield list_path, i
413
414 if isinstance(i, Component):
415 # pylint: disable=protected-access
416 for p, t in i._traverse_with_paths():
417 yield "\n".join([list_path, p]), t
418
419 def _traverse_ids(self):
420 """Yield components with IDs in the tree of children."""

Callers 2

_traverseMethod · 0.95
_validate_valueFunction · 0.80

Calls 1

_id_strMethod · 0.95

Tested by

no test coverage detected