attribute_tree module

class attribute_tree.attribute_tree(**kwds)[source]

Bases: dict

creates dict based tree-like structure

Parameters:kwds (keywords) – passed to underlying dictionary
__getattr__(name)[source]

x.__getattr__(y) <===> x.y

Returns attribute matching given name. If name is not present creates and returns nested attribute_tree.

Parameters:name (str) – name of the attribure
Returns:attribute if name present, nested attribute_tree otherwise
Return type:any
__lt__(rhs)[source]

checks if self is subset of rhs

have same semantics like set.__lt__

Parameters:rhs (attribute_tree) – superset tree
Returns:True if self is subset of rhs, False otherwise
Return type:bool
__setattr__(name, value)[source]

x.__setattr__(name, value) <===> x[name] = value

Adds or changes attribure for a given name to value. If value is a dictionary it is changed to attribute_tree. If value is a collection (list or tuple) each nested dictonary is also changed to attribute_tree.

Parameters:
  • name (str) – name of the attribute
  • value – value of the attribute
attribute_tree.items(x) <===> <dict>x.items()[source]

allows access to underlying dict’s items method

Parameters:tree (attribute_tree) – attribute_tree from which items are returned
attribute_tree.keys(x) <===> <dict>x.keys()[source]

allows access to underlying dict’s keys method

Parameters:tree (attribute_tree) – attribute_tree from which keys are returned
attribute_tree.values(x) <===> <dict>x.values()[source]

allows access to underlying dict’s values method

Parameters:tree (attribute_tree) – attribute_tree from which values are returned
attribute_tree.walk(tree)[source]

walks over tree structure

Function walks over a tree structure yielding each (path, leaf) value

Parameters:tree (dict, list, tuple) – tree-like structure to walk over
Returns:pairs of each (path, leaf) values
Return type:iterable