Skip to content

Instantly share code, notes, and snippets.

@jjjake
Created February 4, 2013 20:46
Show Gist options
  • Select an option

  • Save jjjake/4709603 to your computer and use it in GitHub Desktop.

Select an option

Save jjjake/4709603 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import ujson
# Script/Library created by Mike McCabe to do multiple
# metadata fetches in parallel
# Available here: https://gist.github.com/3784845
from parallel_md_get import metadata_record_iterator
def search_for_foundation(query, manifest):
for form in manifest:
if query.lower() in form['foundation'].lower():
yield form
if __name__ == '__main__':
ids = open(sys.argv[1])
results = metadata_record_iterator(ids, workers=20)
for i, id, md_json in results:
metadata = ujson.loads(md_json)
for result in search_for_foundation('cancer', metadata['manifest']):
if result:
print id, result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment