kd.kontext

kd.kontext#

[[Source]]

Kontext is a small self-contained library to manipulate nested trees.

  • Extract values

Symbols#

Class#

kd.kontext.Context

kd.kontext.GlobPath

Represents a string path.

kd.kontext.Path

Represents a (non-glob) string path.

Function#

kd.kontext.filter_by_path

Filters a context by a path.

kd.kontext.flatten_with_path

Flatten any PyTree / ConfigDict into a dict with ‘keys.like[0].this’.

kd.kontext.get_by_path

Get (nested) item or attribute by given path.

kd.kontext.get_keypaths

Return a dictionary mapping Key-annotated fieldnames to their paths.

kd.kontext.is_key_annotated

Check if a given class or instance has fields annotated with Key.

kd.kontext.path_builder_from

Create a path builder from a class.

kd.kontext.resolve_from_keyed_obj

Resolve the Key annotations of an object for given context.

kd.kontext.resolve_from_keypaths

Get values for key_paths from context with useful errors when failing.

kd.kontext.set_by_path

Mutate the obj to set the value.

Attribute#

Typing#