Created
February 4, 2013 20:46
-
-
Save jjjake/4709603 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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