summaryrefslogtreecommitdiff
path: root/scripts/override-default
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-08-11 11:06:39 -0500
committerJohn Estabrook <jestabro@vyos.io>2021-08-11 13:40:49 -0500
commite7c69ead85af485b2b881f24b929a4bcc779a4ce (patch)
tree5a9215d54c1feb10f96b903cc9c9bfc65b0a3e64 /scripts/override-default
parent82fbacd13f852374df2ecdd394b983325445f81b (diff)
downloadvyos-1x-e7c69ead85af485b2b881f24b929a4bcc779a4ce.tar.gz
vyos-1x-e7c69ead85af485b2b881f24b929a4bcc779a4ce.zip
xml: T3732: simplifications for merging defaultValue and default-less nodes
Diffstat (limited to 'scripts/override-default')
-rwxr-xr-xscripts/override-default12
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/override-default b/scripts/override-default
index c8a0ff1da..228aca30f 100755
--- a/scripts/override-default
+++ b/scripts/override-default
@@ -62,26 +62,26 @@ def override_element(l: list):
def collect_and_override(dir_name):
"""
- Collect elements with defaultValue tag into dictionary indexed by tuple
- of (name: str, ancestor path: str).
+ Collect elements with defaultValue tag into dictionary indexed by name
+ attributes of ancestor path.
"""
for fname in glob.glob(f'{dir_name}/*.xml'):
tree = etree.parse(fname)
root = tree.getroot()
defv = {}
- xpath_str = f'//defaultValue'
+ xpath_str = '//defaultValue'
xp = tree.xpath(xpath_str)
for element in xp:
ap = element.xpath('ancestor::*[@name]')
ap_name = [el.get("name") for el in ap]
- ap_path_str = ' '.join(ap_name[:-1])
- defv.setdefault((ap_name[-1], ap_path_str), []).append(element)
+ ap_path_str = ' '.join(ap_name)
+ defv.setdefault(ap_path_str, []).append(element)
for k, v in defv.items():
if len(v) > 1:
- logger.info(f"overridding default in {k[0]}, path '{k[1]}'")
+ logger.info(f"overridding default in path '{k}'")
override_element(v)
revised_str = etree.tostring(root, encoding='unicode', pretty_print=True)