Module API - Nodes
Prefer from clak import Parser for app code. Node internals:
clak.core.nodes
Node tree and Meta configuration lookup (base of ParserNode).
A setting <name> is declared with meta__config__<name> and read, in
order, from self._<name>, self.Meta.<name> then self.meta__<name>.
Node
A named node in a parent/children tree with Meta settings lookup
Source code in clak/core/nodes.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
Meta
get_fname(attr='name')
get_hierarchy()
Return the nodes from the root down to self
query_cfg_inst(name, default=_REQUIRED)
Query a setting on this node only (dict/list values are copied).
Lookup: self._<name>, self.Meta.<name>, self.meta__<name>,
then default. Raises IndexError when nothing matches.
Source code in clak/core/nodes.py
query_cfg_parents(name, default=_REQUIRED, include_self=True)
Query a setting from this node (or its parent) up to the root.
The setting must be declared (meta__config__<name>) on at least
one node of the lookup chain; values are then read from every node,
closest first, so a plain subcommand's Meta overrides a setting
declared by a mixin on an ancestor.
Raises:
| Type | Description |
|---|---|
MissingMetaError
|
The setting is not declared in the lookup chain |
ConfigurationError
|
No value found and no default provided |