Pointer#
RConf pointer module.
rconf.pointer.Pointer can be implemented for different pointer types,
with type-specific
class method
rconf.pointer.Pointer.parse()andmethod
rconf.pointer.Pointer.__str__().
A rconf.pointer.Pointer can be fully resolved
for a rconf.Value (rconf.pointer.Pointer.resolve()),
or as far as possible (rconf.pointer.Pointer.reduce()).
Optionally, resolution can be stopped at mappings containing certain keys,
for example stop_keys=("$ref",).
rconf.pointer.traverse() implements post-order depth-first traversal
of a rconf.Value.
- class rconf.pointer.Pointer#
A Pointer to a
rconf.Valuefragment.It’s a hashable, iterable sequence of
rconf.Key. The slash operator can be used to create child paths.- __init__(*keys)#
Build a pointer from its keys, or copy a
Pointer.- Parameters:
keys (Pointer | Key) –
- Return type:
None
- classmethod parse(ptr)#
Pointer-specific parsing.
- Raises:
PointerValueErrorfor invalid pointer strings.- Parameters:
ptr (str) –
- Return type:
- reduce(value, *, parent=None, key=None, stop_keys=None)#
Reduce the pointer by following the path as far as possible.
- Parameters:
- Returns:
The reduced (parent, key, value, pointer) tuple.
- Return type:
- resolve(value, *, stop_keys=None)#
Resolve the pointer in a configuration.
- Parameters:
value (Value) – The configuration.
stop_keys (Iterable[Key] | None) – Don’t cross a mapping if it contains any of the listed keys.
- Returns:
The value.
- Raises:
PointerLookupErrorif the pointer path is not present in the configuration.- Return type:
- rconf.pointer.traverse(value, *, leafs=True, dicts=True, lists=True, parent=None, key=None, pointer_type=<class 'rconf.pointer.Pointer'>)#
Post-order depth-first traversal of a configuration.
Iterates over (pointer, parent, key, value)
tuples.- Parameters:
- Return type:
Language-specific pointers#
- class rconf.pointer.JSONPointer#
rconf.pointer.Pointerto parse and serialize JSON Pointers.Follows JSON Pointer.
- __new__(**kwargs)#
Exceptions#
- class rconf.pointer.PointerError#
A generic Pointer exception.
- __new__(**kwargs)#
- __init__(*args, **kwargs)#