From 96cf89f5fdd415fec930f77e2f70446f999187e4 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Thu, 7 Aug 2025 18:35:06 -0500 Subject: T7699: correctly update command/help fields for paths shared over files --- python/vyos/xml_ref/generate_op_cache.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/vyos/xml_ref/generate_op_cache.py b/python/vyos/xml_ref/generate_op_cache.py index fb48debad..83900c7c7 100755 --- a/python/vyos/xml_ref/generate_op_cache.py +++ b/python/vyos/xml_ref/generate_op_cache.py @@ -223,23 +223,42 @@ def insert_node( new_node_data.standalone_help_text = standalone_help_text new_node_data.standalone_command = standalone_command new_node_data.path = path + new_node_data.files = [file] 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) if CHECK_XML_CONSISTENCY: out = node_data_difference(get_node_data(cur_value), get_node_data(value)) if out: err_buf.write(out) + # track the correct pointer reference: + cur_node_data = cur_value[('__node_data', None)] + + if file not in cur_node_data.files: + cur_node_data.files.append(file) + + if not cur_node_data.comp_help and comp_help: + cur_node_data.comp_help = comp_help + + if not cur_node_data.help_text and help_text: + cur_node_data.help_text = help_text + + if not cur_node_data.command and command_text: + cur_node_data.command = command_text + + if not cur_node_data.standalone_help_text and standalone_help_text: + cur_node_data.standalone_help_text = standalone_help_text + + if not cur_node_data.standalone_command and standalone_command: + cur_node_data.standalone_command = standalone_command + + if parent and key not in parent.children: + parent.children.append(key) + if children is not None: inner_nodes = children.iterfind('*') for inner_n in inner_nodes: -- cgit v1.2.3 From 97e947c959179db47c2b268d53ca15d9cbb89c76 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Thu, 7 Aug 2025 18:37:06 -0500 Subject: T7699: update check-xml-consistency test for change in field name --- python/vyos/xml_ref/op_definition.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/vyos/xml_ref/op_definition.py b/python/vyos/xml_ref/op_definition.py index 1a4f53a3a..d4b767324 100644 --- a/python/vyos/xml_ref/op_definition.py +++ b/python/vyos/xml_ref/op_definition.py @@ -126,13 +126,13 @@ def get_node_data_at_path(d: dict, tpath): def node_data_difference(a: NodeData, b: NodeData): out = '' for fld in fields(NodeData): - if fld.name in ('children', 'file'): + if fld.name in ('children', 'files'): continue a_fld = getattr(a, fld.name) b_fld = getattr(b, fld.name) if a_fld != b_fld: - out += f'prev: {a.file} {a.path} {fld.name}: {a_fld}\n' - out += f'new: {b.file} {b.path} {fld.name}: {b_fld}\n' + out += f'prev: {a.files[-1:]} {a.path} {fld.name}: {a_fld}\n' + out += f'new: {b.files[-1:]} {b.path} {fld.name}: {b_fld}\n' out += '\n' return out -- cgit v1.2.3 From ddc8059fb7ecd5fe0e9ffd636e5199d32c06800a Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Thu, 7 Aug 2025 18:38:40 -0500 Subject: T7699: formatting --- python/vyos/xml_ref/generate_op_cache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/xml_ref/generate_op_cache.py b/python/vyos/xml_ref/generate_op_cache.py index 83900c7c7..f49b2290b 100755 --- a/python/vyos/xml_ref/generate_op_cache.py +++ b/python/vyos/xml_ref/generate_op_cache.py @@ -93,7 +93,7 @@ def translate_command(s: str, pos: list[str]) -> str: # it means the command is incorrect, # e.g., it references "$6" when it only has five words. if re.search(r'_place_holder_', s): - print(f"Command translation failed: {s}") + print(f'Command translation failed: {s}') sys.exit(1) return s @@ -155,7 +155,9 @@ def insert_node( else: name = n.get('name') if not name: - raise ValueError("Node name is required for all node types except ") + raise ValueError( + 'Node name is required for all node types except ' + ) if path is None: path = [] -- cgit v1.2.3