py2store.examples.kv_walking¶
walking through kv stores
-
class
py2store.examples.kv_walking.
SrcReader
(src, src_to_keys, key_to_obj)[source]¶ -
update_keys_cache
(keys)¶ Updates the _keys_cache by calling its {} method
-
-
py2store.examples.kv_walking.
conjunction
(*args, **kwargs)[source]¶ ` will be equal to `
func_1(*args, **kwargs) & … & func_n(*args, **kwargs) ``` for all args, kwargs.
-
py2store.examples.kv_walking.
kv_walk
(v: collections.abc.Mapping, yield_func=<function asis>, walk_filt=<function val_is_mapping>, pkv_to_pv=<function tuple_keypath_and_val>, p=())[source]¶ - Parameters
v –
yield_func – (pp, k, vv) -> what ever you want the gen to yield
walk_filt – (p, k, vv) -> (bool) whether to explore the nested structure v further
pkv_to_pv – (p, k, v) -> (pp, vv) where pp is a form of p + k (update of the path with the new node k) and vv is the value that will be used by both walk_filt and yield_func
p – The path to v
>>> d = {'a': 1, 'b': {'c': 2, 'd': 3}} >>> list(kv_walk(d)) [(('a',), 'a', 1), (('b',), 'b', {'c': 2, 'd': 3}), (('b', 'c'), 'c', 2), (('b', 'd'), 'd', 3)] >>> list(kv_walk(d, lambda p, k, v: '.'.join(p))) ['a', 'b', 'b.c', 'b.d'] >>> list(kv_walk(d, lambda p, k, v: '.'.join(p))) ['a', 'b', 'b.c', 'b.d']