diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-07-31 15:43:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-31 15:43:39 +0100 |
| commit | ec534ec7a0641dd5bfa0b8df7b030aa13c64f66f (patch) | |
| tree | 774113be247646f4e4738b4376698661f0a3eec9 /python | |
| parent | 9401f1a5399e4386244c9bce8017a0d455bdb188 (diff) | |
| parent | 9b164d6cb3f0729c403745e935e13863dec7928f (diff) | |
| download | vyos-1x-ec534ec7a0641dd5bfa0b8df7b030aa13c64f66f.tar.gz vyos-1x-ec534ec7a0641dd5bfa0b8df7b030aa13c64f66f.zip | |
Merge pull request #4636 from jestabro/fix-op-cache-file-field
T7672: fix field entries for paths shared across .xml files
Diffstat (limited to 'python')
| -rwxr-xr-x | python/vyos/xml_ref/generate_op_cache.py | 26 | ||||
| -rw-r--r-- | python/vyos/xml_ref/op_definition.py | 3 |
2 files changed, 16 insertions, 13 deletions
diff --git a/python/vyos/xml_ref/generate_op_cache.py b/python/vyos/xml_ref/generate_op_cache.py index 266c81cd0..84553df0e 100755 --- a/python/vyos/xml_ref/generate_op_cache.py +++ b/python/vyos/xml_ref/generate_op_cache.py @@ -202,21 +202,23 @@ def insert_node( if comp_scripts: comp_help['script'] = comp_scripts - cur_node_data = NodeData() - cur_node_data.name = name - cur_node_data.node_type = node_type - cur_node_data.comp_help = comp_help - cur_node_data.help_text = help_text - cur_node_data.command = command_text - cur_node_data.standalone_help_text = standalone_help_text - cur_node_data.standalone_command = standalone_command - cur_node_data.path = path - cur_node_data.file = file - - value = {('__node_data', None): cur_node_data} + new_node_data = NodeData() + new_node_data.name = name + new_node_data.node_type = node_type + new_node_data.comp_help = comp_help + new_node_data.help_text = help_text + new_node_data.command = command_text + new_node_data.standalone_help_text = standalone_help_text + new_node_data.standalone_command = standalone_command + new_node_data.path = path + + value = {('__node_data', None): new_node_data} key = (name, node_type) cur_value = d.setdefault(key, value) + # track the correct pointer reference: + cur_node_data = cur_value[('__node_data', None)] + cur_node_data.files.append(file) if parent and key not in parent.children: parent.children.append(key) diff --git a/python/vyos/xml_ref/op_definition.py b/python/vyos/xml_ref/op_definition.py index 7b0a45a5b..1a4f53a3a 100644 --- a/python/vyos/xml_ref/op_definition.py +++ b/python/vyos/xml_ref/op_definition.py @@ -35,7 +35,7 @@ class NodeData: standalone_help_text: Optional[str] = None standalone_command: Optional[str] = None path: list[str] = field(default_factory=list) - file: str = '' + files: list[str] = field(default_factory=list) children: list[tuple] = field(default_factory=list) @@ -161,6 +161,7 @@ def collapse(d: OpData, acc: dict = None) -> tuple[dict, str, bool]: out += '\n' out += f'new: {new_data.file} {new_data.path}\n\n' else: + new_data.children = list(map(lambda t: t[0], new_data.children)) acc[name] = {} acc[name]['__node_data'] = asdict(new_data) inner, o, e = collapse(v) |
