Home
Overview
Fundamentals
Glossary
Cheatsheet
API Reference
Quick Recipes
Deep Dive
Common Pitfalls and Gotchas
Persistent Storage
A data slice path.
DataSlicePath.__init__(self, actions: tuple[DataSliceAction, ...]) -> NoneInitialize self. See help(type(self)) for accurate signature.
DataSlicePath.concat(self, other: DataSlicePath) -> DataSlicePathAliases:
Returns a new data slice path with the given data slice path appended.
DataSlicePath.depthReturns the depth of this data slice path from the root.
That is the same as the number of actions in the path. The root is at the
empty path, which has depth 0. A path ".foo" has depth 1, ".foo[:]" has
depth 2, ".foo[:].bar" has depth 3, etc.
DataSlicePath.evaluate(self, data_slice: kd.types.DataSlice) -> kd.types.DataSliceAliases:
Evaluates this path on `data_slice`.
Args:
data_slice: the DataSlice on which this path must be evaluated.
Returns:
The part of `data_slice` at the path defined by `self`.
Raises:
ValueError: if this path is not valid for `data_slice`.
DataSlicePath.extended_with_action(self, action: DataSliceAction) -> DataSlicePathAliases:
Returns a new data slice path with the given action appended.
DataSlicePath.from_actions(actions: list[DataSliceAction]) -> DataSlicePathAliases:
DataSlicePath.parse_from_string(data_slice_path: str) -> DataSlicePathAliases:
Parses the given string to return a data slice path.
The empty string is a valid data slice path. Given a valid data slice path,
we can obtain another valid data slice path by appending further actions:
* append '.get_keys()' to get the keys of a dict.
* append '.get_values()' to get the values of a dict.
* append '[:]' to explode a list.
* append '.attribute_name' to get an attribute of an entity. The attribute
name must be a valid Python identifier to be used with this dot syntax.
You can test for that by using some_string.isidentifier().
* append '.get_attr("base64_encoded_attribute_name")' to get an attribute of
an entity. The base64-encoded attribute name can be enclosed in single or
double quotes. This syntax is useful when the attribute name contains
special characters such as dots or quotes.
Args:
data_slice_path: the data slice path to parse. It must be valid according
to the rules above.
Returns:
The parsed data slice path.
Raises:
ValueError: if the data_slice_path is not valid.
DataSlicePath.to_string(self) -> strAliases:
Returns the data slice path as a string.