Traversal¶
Traversal package provides tools for iterating and navigating a resource tree.
Traversal of a datastructure.
TraversalPath¶
A method of defining a location within a data structure, which can then be applied to the datastructure to extract the value.
A TraversalPath
can be expressed as a string using .
as a separator:
field1.field2
Both lists and dicts can be included using []
and {}
syntax:
field[1].field2
or:
field{key=value}.field2
ResourceTraversalIterator¶
Iterator for traversing (walking) a resource structure, including traversing composite fields to fully navigate a resource tree.
This class has hooks that can be used by subclasses to customise the behaviour of the class:
- on_enter - Called after entering a new resource.
- on_exit - Called after exiting a resource.
-
class
odin.traversal.
ResourceTraversalIterator
(resource: Union[odin.resources.ResourceBase, Sequence[odin.resources.ResourceBase]])[source]¶ Iterator for traversing (walking) a resource structure, including traversing composite fields to fully navigate a resource tree.
This class has hooks that can be used by subclasses to customise the behaviour of the class:
- on_enter - Called after entering a new resource.
- on_exit - Called after exiting a resource.
-
current_resource
¶ The current resource being traversed.
-
depth
¶ Depth of the current resource in the tree structure.
-
path
¶ Path to the current resource node in the tree structure.
This path can be used to later traverse the tree structure to find get to the specified resource.