diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2022-05-31 11:32:36 +0200 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2022-05-31 18:21:20 +0200 |
commit | df039e9c797a24e4599d6d0b3bacfabfef894bfd (patch) | |
tree | ecd4774cd63a4f1b1b620f90632e6158c99ff8ed /python | |
parent | 51f9de97678a3e4d9d2096699986db77a26a245c (diff) | |
download | vyos-1x-df039e9c797a24e4599d6d0b3bacfabfef894bfd.tar.gz vyos-1x-df039e9c797a24e4599d6d0b3bacfabfef894bfd.zip |
pki: T3642: Update conf scripts using changed PKI objects
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/util.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index de55e108b..0d62fbfe9 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -757,21 +757,26 @@ def dict_search_args(dict_object, *path): dict_object = dict_object[item] return dict_object -def dict_search_recursive(dict_object, key): +def dict_search_recursive(dict_object, key, path=[]): """ Traverse a dictionary recurisvely and return the value of the key we are looking for. Thankfully copied from https://stackoverflow.com/a/19871956 + + Modified to yield optional path to found keys """ if isinstance(dict_object, list): for i in dict_object: - for x in dict_search_recursive(i, key): - yield x + new_path = path + [i] + for x in dict_search_recursive(i, key, new_path): + yield x elif isinstance(dict_object, dict): if key in dict_object: - yield dict_object[key] - for j in dict_object.values(): - for x in dict_search_recursive(j, key): + new_path = path + [key] + yield dict_object[key], new_path + for k, j in dict_object.items(): + new_path = path + [k] + for x in dict_search_recursive(j, key, new_path): yield x def get_bridge_fdb(interface): |