summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-07-15 14:22:49 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-07-15 22:09:52 -0500
commit3284444b1755912883eaa8d474fac01c2355af66 (patch)
tree6580a32635b9d4794a84b92fea9edd2479ed7533 /python/vyos
parentf8797df83d9ce127346ee9f0fae43a031559c790 (diff)
downloadvyos-1x-3284444b1755912883eaa8d474fac01c2355af66.tar.gz
vyos-1x-3284444b1755912883eaa8d474fac01c2355af66.zip
T5195: remove obsoleted mangle_dict_keys
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configdiff.py2
-rw-r--r--python/vyos/util.py46
2 files changed, 1 insertions, 47 deletions
diff --git a/python/vyos/configdiff.py b/python/vyos/configdiff.py
index 5d30e9b66..0caa204c3 100644
--- a/python/vyos/configdiff.py
+++ b/python/vyos/configdiff.py
@@ -20,7 +20,7 @@ from vyos.configtree import DiffTree
from vyos.configdict import dict_merge
from vyos.configdict import list_diff
from vyos.utils.dict import get_sub_dict
-from vyos.util import mangle_dict_keys
+from vyos.utils.dict import mangle_dict_keys
from vyos.utils.dict import dict_search_args
from vyos.xml import defaults
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 63539e897..a13d95201 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -13,49 +13,3 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-def _mangle_dict_keys(data, regex, replacement, abs_path=[], no_tag_node_value_mangle=False, mod=0):
- """ Mangles dict keys according to a regex and replacement character.
- Some libraries like Jinja2 do not like certain characters in dict keys.
- This function can be used for replacing all offending characters
- with something acceptable.
-
- Args:
- data (dict): Original dict to mangle
-
- Returns: dict
- """
- import re
- from vyos.xml import is_tag
-
- new_dict = {}
-
- for key in data.keys():
- save_mod = mod
- save_path = abs_path[:]
-
- abs_path.append(key)
-
- if not is_tag(abs_path):
- new_key = re.sub(regex, replacement, key)
- else:
- if mod%2:
- new_key = key
- else:
- new_key = re.sub(regex, replacement, key)
- if no_tag_node_value_mangle:
- mod += 1
-
- value = data[key]
-
- if isinstance(value, dict):
- new_dict[new_key] = _mangle_dict_keys(value, regex, replacement, abs_path=abs_path, mod=mod, no_tag_node_value_mangle=no_tag_node_value_mangle)
- else:
- new_dict[new_key] = value
-
- mod = save_mod
- abs_path = save_path[:]
-
- return new_dict
-
-def mangle_dict_keys(data, regex, replacement, abs_path=[], no_tag_node_value_mangle=False):
- return _mangle_dict_keys(data, regex, replacement, abs_path=abs_path, no_tag_node_value_mangle=no_tag_node_value_mangle, mod=0)