Skip to content

Instantly share code, notes, and snippets.

@kf0jvt
Forked from jeffbryner/gist:8918508
Created February 10, 2014 16:28
Show Gist options
  • Save kf0jvt/8919157 to your computer and use it in GitHub Desktop.
Save kf0jvt/8919157 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
vDict=json.loads(open('verisc-enum.json').read())
def dict_walker(inCollection, pre=None):
pre = pre[:] if pre else []
#print(pre)
if isinstance(inCollection, dict):
for key, value in inCollection.iteritems():
if isinstance(value, dict):
for d in dict_walker(value, pre+ [key]):
yield d
elif isinstance(value, list) or isinstance(value, tuple):
for v in value:
for d in dict_walker(v, pre+ [key] ):
yield d
else:
print(end)
yield '.'.join(pre) + '.' + d
elif isinstance(inCollection, list) or isinstance(inCollection, tuple):
for v in inCollection:
for d in dict_walker(v, pre ):
yield d
else:
yield '.'.join(pre) + '.' + inCollection
for key in vDict.keys():
for y in dict_walker(vDict[key],[key]):
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment