confignode
ConfigNode
Bases: collections.abc.Mapping
Represent a dict-like config object.
ConfigNode
is immutable, changes should be made to the source RootConfig
object. This class should be safe to pickle and pass to subprocesses.
You when accessing keys by attribute eg: config.foo
they'll return an empty
ConfigNode
instead of raising an AttributeError
.
Source code in gamma/config/confignode.py
__init__(node, root=None, parent=None, key=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
MappingNode
|
the backing |
required |
root |
Optional[RootConfig]
|
the root of the config tree |
None
|
key |
the node key in the config tree |
None
|
Source code in gamma/config/confignode.py
RootConfig
Bases: ConfigNode
A root config object.
The object is a collection of (entry_key: str, entry: Node)
, sorted by
the entry_key
. A item access will search for the key in each entry and merge
those found.
New entries should be inserted with the push_entryfunction.
The entries are always iterated in
entry_key` lexicographical
sort order and this affects merge results.
Initialize the object, optionally adding a single entry. See
push_entry
.
If entry_key
is None
, a dynamically generated entry key will be created.
Source code in gamma/config/confignode.py
as_node(a)
config_getitem(cfg, key, **ctx)
Get an item from a root config by key.
We find all entries matching the key and merge them dynamically using
merge_nodes
.
Source code in gamma/config/confignode.py
config_len(cfg)
create_last_entry_key(cfg)
Create an entry_key guaranteed to be the last entry for the object.
get_keys(cfg)
Return all distinct keys in a config node
Source code in gamma/config/confignode.py
push_entry(root, entry_key, node, *, _allow_unsafe=False)
Add a Node
entry to the root config object.
Entries are loaded in sorted order.
Note: the global root object can only be modified by the thread that created it.
Source code in gamma/config/confignode.py
push_folder(root, folder)
Push all entries in a given folder.
remove_entry(cfg, entry_key)
resolve_item(item, tag, **ctx)
Iterates on a seq
node, resolving each child item node.