summaryrefslogtreecommitdiff
path: root/scripts/override-default
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-03-31 08:01:48 -0500
committerJohn Estabrook <jestabro@vyos.io>2021-03-31 12:03:05 -0500
commit4ae739188753d5141bbe2f3be2f954aa61562aab (patch)
tree23353903698976658484160e27e5608c7df8fdb1 /scripts/override-default
parentf2633dcbdbf108804acff61964c0b418ba25d645 (diff)
downloadvyos-1x-4ae739188753d5141bbe2f3be2f954aa61562aab.tar.gz
vyos-1x-4ae739188753d5141bbe2f3be2f954aa61562aab.zip
xml: T3445: avoid false positive on element references; use path name
(cherry picked from commit f22fa8e6454b1cd2539ddb7c354ac9eeeac725c5)
Diffstat (limited to 'scripts/override-default')
-rwxr-xr-xscripts/override-default9
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/override-default b/scripts/override-default
index d91b89426..c8a0ff1da 100755
--- a/scripts/override-default
+++ b/scripts/override-default
@@ -63,8 +63,7 @@ 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)); the second component must be immutable for
- tuple to act as key, hence str().
+ of (name: str, ancestor path: str).
"""
for fname in glob.glob(f'{dir_name}/*.xml'):
tree = etree.parse(fname)
@@ -76,11 +75,13 @@ def collect_and_override(dir_name):
for element in xp:
ap = element.xpath('ancestor::*[@name]')
- defv.setdefault((ap[-1].get("name"), str(ap[:-1])), []).append(element)
+ 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)
for k, v in defv.items():
if len(v) > 1:
- logger.debug(f'overridding default in {k[0]}')
+ logger.info(f"overridding default in {k[0]}, path '{k[1]}'")
override_element(v)
revised_str = etree.tostring(root, encoding='unicode', pretty_print=True)