quantlab.core.store_uses.walk_store_uses#

quantlab.core.store_uses.walk_store_uses(root, path='', *, descend=None)[source]#

Return every store use declared in the tree under root, root included.

Every component reached through the declared component fields (child_components) is asked store_uses(); an object without the method declares none. A use found under a BuiltFrom sub-component becomes a source use. The uses are ordered deepest component path first (the dots of the path, as the live day always counted them), then owners before readers before sources, keeping the walk’s order otherwise; a store reached again with the same relation (and the same kind, ranged or not) is kept where it is first in that order, keyed by its absolute path (a panel held in memory, by the declaring component).

Parameters:
rootComponent or Mapping

The component to walk, or {path: component} of several roots walked as one tree (None values skipped), each at its own path.

pathstr, optional

The path of root itself, prefixed to every path.

descendcallable, optional

Given a sub-component’s path, whether to visit it and what lies under it; every sub-component is visited when omitted.

Returns:
tuple of FoundStoreUse

The uses, in extension order.

Raises:
TypeError, ValueError

If a declaration holds something other than a StoreUse or a BuiltFrom, or a StoreUse refuses its fields.

Examples

>>> [(use.where, use.relation) for use in walk_store_uses(label)]
[('factor.dataset', 'reads'), ('factor', 'owns')]
>>> [use.relation for use in walk_store_uses(mapped)]   # a MappedTradeBarDataset
['source', 'reads']