Fixed issue where get_all_keys or _get_occurence choked on strings.
Created by: jpavlav
Found a bug when trying to utilize get_occurence_of_key and get_all_keys on a data structure similar to this:
self.sample4 = { "values": [ { "checks": [ { "monitoring_zones": [ "mzdfw", "mzfra", "mzhkg", "mziad", "mzlon", "mzord", "mzsyd" ] } ] } ] }
I've added a test to the test_nested_lookup file that shows the error in question, but for ease, this is what is returned when the test is run without the fix:
python -m unittest test_nested_loopkup ...E...........
ERROR: test_sample_data4 (test_nested_loopkup.TestGetAllKeys)
Traceback (most recent call last): File "test_nested_loopkup.py", line 245, in test_sample_data4 File "nested_lookup/nested_lookup.py", line 63, in get_all_keys recrusion(dictionary=dictionary) File "nested_lookup/nested_lookup.py", line 59, in recrusion recrusion(dictionary=list_items) File "nested_lookup/nested_lookup.py", line 59, in recrusion recrusion(dictionary=list_items) File "nested_lookup/nested_lookup.py", line 59, in recrusion recrusion(dictionary=list_items) File "nested_lookup/nested_lookup.py", line 52, in recrusion for key, value in iteritems(dictionary): File "/Users/jpavlav/Projects/nested-lookup/venv2/lib/python2.7/site-packages/six.py", line 605, in iteritems return d.iteritems(**kw) AttributeError: 'str' object has no attribute 'iteritems'
Ran 15 tests in 0.001s
FAILED (errors=1)
The fix implemented in nested_lookup.py works for both python3 and python2.