An ordered tree structure to hold configuration data.
A node can be referred to by its path, relative to the current node. A
path is a list of keys, each key a tuple of either string or None
items.
|
__init__(self,
data=None,
sort_key=<function <lambda> at 0x7fedce56b488>,
key_to_string=<function <lambda> at 0x7fedce56b500>)
Initializes a new ConfigTree. |
|
|
|
|
|
|
|
get_clone(self,
parent=None)
Returns a clone of the ConfigTree, not sharing any mutable data. |
|
|
|
get(self,
node_key)
Returns the current node's child having node_key, or None. |
|
|
|
set(self,
node_key,
node_data=None)
Creates and adds a child node to the current node, and returns that
new node. |
|
|
|
cine(self,
node_key,
node_data=None)
cine stands for create if not exist: it makes sure a node exists. |
|
|
|
update(self,
node_key,
node_data=None)
If a node already has node_key as key, its data will be replaced with
node_data. |
|
|
|
delete(self,
path)
Given a path, deletes an entire subtree from the configuration,
relative to the current node. |
|
|
|
get_path(self,
path)
Returns either the node matching path, relative to the current node,
or None if the path does not exists. |
|
|
|
search(self,
search_path,
node_filter=<function <lambda> at 0x7fedce56be60>)
Returns a list of nodes matching the search_path, relative to the
current node, or an empty list if no match was found. |
|
|
|
walk(self,
node_filter=<function <lambda> at 0x7fedce56bf50>)
Returns a generator yielding our children's tree in depth-first order. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
root
Returns the root node of the tree.
|
|
key
Returns the current node's key tuple.
|
|
key_str
Returns the current node's key as a string.
|
|
path
Returns the node's full path from the tree root as a list of keys.
|
|
path_str
Returns the node's full path from the tree root as a string.
|
|
nodes
Returns the list of all children nodes, sorted with potential
dependencies first.
|
|
keys
Generates all children nodes keys, sorted with potential dependencies
first.
|
|
parent
Returns the parent node of the current node, or None.
|
|
is_root
Returns True if this is a root node, else False.
|
Inherited from object :
__class__
|