From 313a3d114c11d5b499eab27d02260bef2b67830b Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 23 Jan 2025 18:21:50 +0000 Subject: [PATCH] opmode: T7084: normalize formatting --- python/vyos/xml_ref/generate_op_cache.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/python/vyos/xml_ref/generate_op_cache.py b/python/vyos/xml_ref/generate_op_cache.py index 9efcd14be1..f2e6dcd40c 100755 --- a/python/vyos/xml_ref/generate_op_cache.py +++ b/python/vyos/xml_ref/generate_op_cache.py @@ -36,6 +36,7 @@ from op_definition import NodeData from op_definition import PathData + xml_op_cache_json = 'xml_op_cache.json' xml_op_tmp = join('/tmp', xml_op_cache_json) op_ref_cache = abspath(join(_here, 'op_cache.py')) @@ -74,7 +75,7 @@ def translate_op_script(s: str) -> str: return s -def insert_node(n: Element, l: list[PathData], path = None) -> None: +def insert_node(n: Element, l: list[PathData], path=None) -> None: # pylint: disable=too-many-locals,too-many-branches prop: OptElement = n.find('properties') children: OptElement = n.find('children') @@ -97,12 +98,12 @@ def insert_node(n: Element, l: list[PathData], path = None) -> None: comp_help = {} if prop is not None: - che = prop.findall("completionHelp") + che = prop.findall('completionHelp') for c in che: - comp_list_els = c.findall("list") - comp_path_els = c.findall("path") - comp_script_els = c.findall("script") + comp_list_els = c.findall('list') + comp_path_els = c.findall('path') + comp_script_els = c.findall('script') comp_lists = [] for i in comp_list_els: @@ -134,7 +135,7 @@ def insert_node(n: Element, l: list[PathData], path = None) -> None: l.append(cur_node_dict) if children is not None: - inner_nodes = children.iterfind("*") + inner_nodes = children.iterfind('*') for inner_n in inner_nodes: inner_path = path[:] insert_node(inner_n, cur_node_dict['children'], inner_path) @@ -143,14 +144,18 @@ def insert_node(n: Element, l: list[PathData], path = None) -> None: def parse_file(file_path, l): tree = ET.parse(file_path) root = tree.getroot() - for n in root.iterfind("*"): + for n in root.iterfind('*'): insert_node(n, l) def main(): parser = ArgumentParser(description='generate dict from xml defintions') - parser.add_argument('--xml-dir', type=str, required=True, - help='transcluded xml op-mode-definition file') + parser.add_argument( + '--xml-dir', + type=str, + required=True, + help='transcluded xml op-mode-definition file' + ) args = vars(parser.parse_args()) @@ -167,5 +172,6 @@ def main(): with open(op_ref_cache, 'w') as f: f.write(f'op_reference = {str(l)}') + if __name__ == '__main__': main()