Skip to content

Instantly share code, notes, and snippets.

@gcarothers
Created June 28, 2013 22:57
Show Gist options
  • Save gcarothers/5888789 to your computer and use it in GitHub Desktop.
Save gcarothers/5888789 to your computer and use it in GitHub Desktop.
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