summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-06-25 10:49:53 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-06-25 10:49:53 +0100
commit786fefe821e821cfdba896b5584fff49074be6ca (patch)
treeac37c2cafed33c87a9c371399a5e51ef4f8c6742 /python
parent9fc8158f98ba7154da9867d9a28f00e39f76d0e0 (diff)
downloadvyos-1x-786fefe821e821cfdba896b5584fff49074be6ca.tar.gz
vyos-1x-786fefe821e821cfdba896b5584fff49074be6ca.zip
xml: T2528: fix to work with named tags (edit mode)
Diffstat (limited to 'python')
-rw-r--r--python/vyos/xml/definition.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/python/vyos/xml/definition.py b/python/vyos/xml/definition.py
index c5f6b0fc7..52cbbaf97 100644
--- a/python/vyos/xml/definition.py
+++ b/python/vyos/xml/definition.py
@@ -228,8 +228,9 @@ class XML(dict):
inner = self.tree[option]
prefix = '+> ' if inner.get(kw.node, '') != kw.leafNode else ' '
if kw.help in inner:
- h = inner[kw.help]
- yield (prefix + option, h.get(kw.summary), '')
+ yield (prefix + option, inner[kw.help].get(kw.summary), '')
+ else:
+ yield (prefix + option, '(no help available)', '')
def debug(self):
print('------')
@@ -260,7 +261,7 @@ class XML(dict):
if isinstance(d[k],dict):
_flatten(level, index, d[k], r)
continue
- if self.is_multi(level):
+ if self.is_multi(level, with_tag=False):
r[under] = [_.strip() for _ in d[k].split(',')]
continue
r[under] = d[k]
@@ -272,9 +273,11 @@ class XML(dict):
# @lru_cache(maxsize=100)
# XXX: need to use cachetool instead - for later
- def _tree(self, lpath):
+ def _tree(self, lpath, with_tag=True):
"""
returns the part of the tree searched or None if it does not exists
+ if with_tag is set, this is a configuration path (with tagNode names)
+ and tag name will be removed from the path when traversing the tree
"""
tree = self[kw.tree]
spath = lpath.copy()
@@ -283,6 +286,8 @@ class XML(dict):
if p not in tree:
return None
tree = tree[p]
+ if with_tag and spath and tree[kw.node] == kw.tagNode:
+ spath.pop(0)
return tree
def _get(self, lpath, tag):