Created
June 28, 2013 22:57
-
-
Save gcarothers/5888789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base_urls = { | |
None: "http://lexmachina.com/data/case/", | |
"judges": "http://lexmachina.com/data/fjc-judge/", | |
"court": "http://lexmachina.com/data/court/", | |
"tags": "http://lexmachina.com/vocab/tags#", | |
"docket_entries": "http://lexmachina.com/data/docket-entry/", | |
"documents": "http://lexmachina.com/data/documents/", | |
} | |
def walk(node, context=None): | |
for key, item in node.items(): | |
if isinstance(item, dict): | |
walk(item, context=key) | |
elif isinstance(item, list): | |
for l_item in item: | |
if isinstance(l_item, dict): | |
walk(l_item, context=key) | |
else: | |
log.debug(key) | |
if key == 'id' or key == "ecf_abbreviation": | |
node['@id'] = base_urls[context] + str(item) | |
walk(case) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment