aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-04-02 17:38:55 -0700
committerBryan Newbold <bnewbold@archive.org>2020-04-02 17:38:57 -0700
commita64e93349fc475d67d8a7079a610959a5afcce0f (patch)
tree0fa4effbfe6b3389e67d4cd34921691ebd313cbd
parentf760c853eb3d878974d307d0468408dea5552e1d (diff)
downloadfatcat-covid19-a64e93349fc475d67d8a7079a610959a5afcce0f.tar.gz
fatcat-covid19-a64e93349fc475d67d8a7079a610959a5afcce0f.zip
WIP: top-level helper script
Goal is to refactor most other covid19-specific commands into this tool, with code living in the fatcat_covid19 module.
-rwxr-xr-xcovid19_tool.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/covid19_tool.py b/covid19_tool.py
new file mode 100755
index 0000000..5be70b4
--- /dev/null
+++ b/covid19_tool.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+import sys
+import argparse
+
+from fatcat_covid19.webface import app
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+ parser.set_defaults(
+ action='none',
+ )
+ subparsers = parser.add_subparsers()
+
+ sub_webface = subparsers.add_parser('webface',
+ help="run flask web interface")
+ sub_webface.set_defaults(
+ action='webface',
+ )
+ sub_webface.add_argument('--debug',
+ action='store_true',
+ help="enable debugging interface (note: not for everything)")
+ sub_webface.add_argument('--host',
+ default="127.0.0.1",
+ help="listen on this host/IP")
+ sub_webface.add_argument('--port',
+ type=int,
+ default=9119,
+ help="listen on this port")
+
+ sub_enrich = subparsers.add_parser('enrich',
+ help="enrich CORD-19 dataset (JSON) with fatcat metadata (prints to stdout)")
+ sub_enrich.set_defaults(
+ action='enrich',
+ )
+ sub_enrich.add_argument('json_file',
+ help="CORD-19 parsed JSON file",
+ type=argparse.FileType('r'))
+
+ args = parser.parse_args()
+
+ if args.action == 'webface':
+ app.run(debug=args.debug, host=args.host, port=args.port)
+ if args.action == 'enrich':
+ # TODO
+ pass
+ else:
+ print("tell me what to do!")
+ sys.exit(-1)
+
+
+if __name__ == '__main__':
+ main()