From 06901b2b271a8aa7454dcaec2805e0858db38b92 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Tue, 23 Jun 2020 11:49:34 +0100 Subject: xml: T2588: fix mistake when determining if a node is multi --- python/vyos/xml/definition.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'python/vyos/xml') diff --git a/python/vyos/xml/definition.py b/python/vyos/xml/definition.py index 1ecc2017a..c5f6b0fc7 100644 --- a/python/vyos/xml/definition.py +++ b/python/vyos/xml/definition.py @@ -251,20 +251,21 @@ class XML(dict): d = d[k] r = {} - def _flatten(inside, d, r): - prefix = '_'.join(_.replace('-','_') for _ in inside) + '_' if inside else '' + def _flatten(inside, index, d, r): + local = inside[index:] + prefix = '_'.join(_.replace('-','_') for _ in local) + '_' if local else '' for k in d: under = prefix + k.replace('-','_') level = inside + [k] if isinstance(d[k],dict): - _flatten(level, d[k], r) + _flatten(level, index, d[k], r) continue if self.is_multi(level): r[under] = [_.strip() for _ in d[k].split(',')] continue r[under] = d[k] - _flatten([], d, r) + _flatten(lpath, len(lpath), d, r) return r # from functools import lru_cache -- cgit v1.2.3