diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-06-25 17:16:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 17:16:35 +0200 |
commit | 8bc1c23d218b1e75a7807eb4ca978a29543cf67e (patch) | |
tree | ac37c2cafed33c87a9c371399a5e51ef4f8c6742 /python/vyos | |
parent | 9fc8158f98ba7154da9867d9a28f00e39f76d0e0 (diff) | |
parent | 786fefe821e821cfdba896b5584fff49074be6ca (diff) | |
download | vyos-1x-8bc1c23d218b1e75a7807eb4ca978a29543cf67e.tar.gz vyos-1x-8bc1c23d218b1e75a7807eb4ca978a29543cf67e.zip |
Merge pull request #475 from thomas-mangin/T2588-tag
xml: T2528: fix to work with named tags (edit mode)
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/xml/definition.py | 13 |
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): |