diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-07-19 13:17:09 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-07-19 13:17:09 -0500 |
| commit | bc1280444ea3d5d4e5b5afd4e39bfb9365689393 (patch) | |
| tree | ff467903e14b9b66b4644fd86edc81d046187264 /config_file/nested_lookup/nested_lookup.py | |
| parent | Add more info on installation with poetry and zsh (diff) | |
| download | config-file-bc1280444ea3d5d4e5b5afd4e39bfb9365689393.zip | |
Add nested-lookup to project
russellballestrini is a python project
in the public domain. Rather than installing
it as a dependency, this adds it as part of
the config-file package now, which allows
more control.
Diffstat (limited to 'config_file/nested_lookup/nested_lookup.py')
| -rw-r--r-- | config_file/nested_lookup/nested_lookup.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/config_file/nested_lookup/nested_lookup.py b/config_file/nested_lookup/nested_lookup.py index 0b11b4d..9454a44 100644 --- a/config_file/nested_lookup/nested_lookup.py +++ b/config_file/nested_lookup/nested_lookup.py @@ -1,5 +1,3 @@ -from six import iteritems - from collections import defaultdict @@ -29,7 +27,7 @@ def _nested_lookup(key, document, wild=False, with_keys=False): yield result if isinstance(document, dict): - for k, v in iteritems(document): + for k, v in document.items(): if key == k or (wild and _is_case_insensitive_substring(key, k)): if with_keys: yield k, v @@ -61,7 +59,7 @@ def get_all_keys(dictionary): for list_items in document: recrusion(document=list_items) elif isinstance(document, dict): - for key, value in iteritems(document): + for key, value in document.items(): result_list.append(key) recrusion(document=value) return @@ -148,7 +146,7 @@ def _recursion(dictionary, item, keyword, occurrence, with_values=False): occurrence[0] += list(dictionary.values()).count(keyword) if with_values: values_list.append(dictionary) - for key, value in iteritems(dictionary): + for key, value in dictionary.items(): if isinstance(value, dict): _recursion(value, item, keyword, occurrence, with_values) elif isinstance(value, list): |