bucky.util.nested_dict#

Provide a nested version of dict() along with convenient API additions (apply, update, etc).

Module Contents#

Classes#

NestedDict

A nested version of dict.

Functions#

_is_dict_type(x)

Check is a variable has a dict-like interface.

_is_list_type(x)

Check is a variable has a list-like interface.

Attributes#

test_dict

yaml

bucky.util.nested_dict.test_dict#
bucky.util.nested_dict.yaml[source]#
class bucky.util.nested_dict.NestedDict(dict_of_dicts=None, seperator='.', ordered=True)[source]#

Bases: collections.abc.MutableMapping

A nested version of dict.

__delitem__(self, key)[source]#

WIP.

__getitem__(self, key)[source]#

Getitem, supports flattened keys.

__iter__(self)[source]#

WIP.

__len__(self)[source]#

WIP.

__repr__(self)[source]#

REPL string representation for NestedDict, basically just yaml-ize it.

__setitem__(self, key, value)[source]#

Setitem, doing it recusively if a flattened key is used.

apply(self, func, copy=False, key_filter=None, contains_filter=None, apply_to_lists=False)[source]#

Apply a function of values stored in self, optionally filtering or doing a deep copy.

flatten(self, parent='')[source]#

Flatten to a normal dict where the hierarchy exists in the key names.

from_dict(self, dict_of_dicts)[source]#

Create a NestedDict from a dict of dicts.

from_flat_dict(self, flat_dict)[source]#

Create a NestedDict from a flattened dict.

to_dict(self)[source]#

Return self but as a proper dict of dicts.

to_yaml(self, *args, **kwargs)[source]#

Return YAML represenation of self.

update(self, other=(), **kwargs)[source]#

Update (like dict().update), but accept dict_of_dicts as input.

bucky.util.nested_dict._is_dict_type(x)[source]#

Check is a variable has a dict-like interface.

bucky.util.nested_dict._is_list_type(x)[source]#

Check is a variable has a list-like interface.