diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-09 00:28:51 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-09 00:28:51 -0700 |
commit | ce0c06ca8e694362a3bf4cde175efbe1af6e4962 (patch) | |
tree | 94347a1c9d1900bffd79092bc94eb12a6ae6ea31 /python/client.py | |
parent | 1960f398fb3ae664bec0efaaa6a399a7d01675cb (diff) | |
download | fatcat-ce0c06ca8e694362a3bf4cde175efbe1af6e4962.tar.gz fatcat-ce0c06ca8e694362a3bf4cde175efbe1af6e4962.zip |
basic ORCID importer
Diffstat (limited to 'python/client.py')
-rwxr-xr-x | python/client.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/python/client.py b/python/client.py index 070d046a..14814512 100755 --- a/python/client.py +++ b/python/client.py @@ -1,13 +1,19 @@ #!/usr/bin/env python3 +import sys import argparse from fatcat.api_client import FatCatApiClient +from fatcat.orcid_importer import FatcatOrcidImporter -def import_crossref(args): +def run_import_crossref(args): fcc = FatCatApiClient(args.host_url) fcc.import_crossref_file(args.json_file, create_containers=args.create_containers) +def run_import_orcid(args): + foi = FatcatOrcidImporter(args.host_url) + foi.process_batch(args.json_file, size=args.batch_size) + def health(args): fcc = FatCatApiClient(args.host_url) print(fcc.health()) @@ -18,23 +24,34 @@ def main(): action='store_true', help="enable debugging interface") parser.add_argument('--host-url', - default="http://localhost:9411", + default="http://localhost:9411/v0", help="connect to this host/port") subparsers = parser.add_subparsers() - sub_import_crossref = subparsers.add_parser('import-crossref', - aliases=['ic']) - sub_import_crossref.set_defaults(func=import_crossref) + sub_import_crossref = subparsers.add_parser('import-crossref') + sub_import_crossref.set_defaults(func=run_import_crossref) sub_import_crossref.add_argument('json_file', help="crossref JSON file to import from") sub_import_crossref.add_argument('--create-containers', action='store_true', help="if true, create containers based on ISSN") + sub_import_orcid = subparsers.add_parser('import-orcid') + sub_import_orcid.set_defaults(func=run_import_orcid) + sub_import_orcid.add_argument('json_file', + help="orcid JSON file to import from (or stdin)", + default=sys.stdin, type=argparse.FileType('r')) + sub_import_orcid.add_argument('--batch-size', + help="size of batch to send", + default=50, type=int) + sub_health = subparsers.add_parser('health') sub_health.set_defaults(func=health) args = parser.parse_args() + if not args.__dict__.get("func"): + print("tell me what to do!") + sys.exit(-1) args.func(args) if __name__ == '__main__': |