From 4cf667c283d54f769e73d76bb23bbb68b4329cf8 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 16 May 2018 18:34:19 -0700 Subject: move python code to subdirectory --- python/fatcat_client.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 python/fatcat_client.py (limited to 'python/fatcat_client.py') diff --git a/python/fatcat_client.py b/python/fatcat_client.py new file mode 100755 index 00000000..d1580be5 --- /dev/null +++ b/python/fatcat_client.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import argparse +from fatcat.api_client import FatCatApiClient + +def import_crossref(args): + fcc = FatCatApiClient(args.host_url) + fcc.import_crossref_file(args.json_file, + create_containers=args.create_containers) + +def health(args): + fcc = FatCatApiClient(args.host_url) + print(fcc.health()) + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--debug', + action='store_true', + help="enable debugging interface") + parser.add_argument('--host-url', + default="http://localhost:8040", + 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.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_health = subparsers.add_parser('health') + sub_health.set_defaults(func=health) + + args = parser.parse_args() + args.func(args) + +if __name__ == '__main__': + main() -- cgit v1.2.3