selector
NUC selectors.
- class SelectorTarget(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumThe target for a selector.
- TOKEN = 0
The target is the token itself.
- CONTEXT = 1
The target is the provided context.
- class Selector(path: List[str], target: SelectorTarget)[source]
Bases:
objectA selector that specifies a path within a JSON object to be matched.
- target: SelectorTarget
- static parse(selector: str) Selector[source]
Parse a selector from a string.
- Parameters:
selector – The selector to be parsed.
Example
from nuc.selector import Selector selector = Selector.parse(".foo.bar")
- apply(value: Dict[str, Any], context: SelectorContext) Any[source]
Apply a selector on a value and return the matched value, if any.
- Parameters:
value – The dict that this selector should be applied to.
- __eq__(other)
Return self==value.
- __repr__()
Return repr(self).