betty.indicator.selector module

Data selectors.

final class betty.indicator.selector.Attr

Bases: Element[str]

An attribute selector.

format() str

Format the indicator to a string.

class betty.indicator.selector.Element

Bases: Selector, Generic

An aggregate element selector.

__init__(element: ElementT, /)
property element: ElementT

The element.

final class betty.indicator.selector.Index

Bases: Element[int]

A sequence item selector.

format() str

Format the indicator to a string.

final class betty.indicator.selector.Key

Bases: Element[str]

A mapping key selector.

format() str

Format the indicator to a string.

class betty.indicator.selector.Selector

Bases: Indicator, ABC

Indicate and interact with aggregate data.

final delete(data: Any, /) None

Delete the element for this selector.

Raises:

SelectorError – raised if the selected element cannot be accessed.

final get(data: Any, assertion: Pipe[Any, T] | None = None, /) T

Get the value for this selector.

Raises:

SelectorError – raised if the selected element cannot be accessed.

final set(data: Any, value: Any, /) None

Set the value for this selector.

Raises:

SelectorError – raised if the selected element cannot be accessed.

final exception betty.indicator.selector.SelectorError

Bases: ValueError

Raise when a selector cannot access its element on the given data.

__init__(selector: Selector, /)
final class betty.indicator.selector.Selectors

Bases: Selector

Combine multiple selectors into one.

__init__(*selectors: Selector)
format() str

Format the indicator to a string.

classmethod reduce(*indicators: Indicator) Sequence[Indicator]

Reduce all consecutive instances of py:class:betty.indicator.selector.Selector to a single instance of this class.

All other indicators are kept verbatim.