aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-04-03 17:47:40 -0700
committerBryan Newbold <bnewbold@archive.org>2020-04-03 17:47:40 -0700
commit1d114e74ed34d871f9187665f8a2ffcf97116017 (patch)
tree673b330e94f8d7d6055c64661c8337de8e396aeb
parent7c3cdf6e702a1347a3c3942bc5764b60288ebbee (diff)
downloadfatcat-covid19-1d114e74ed34d871f9187665f8a2ffcf97116017.tar.gz
fatcat-covid19-1d114e74ed34d871f9187665f8a2ffcf97116017.zip
tool: reorder commands
-rwxr-xr-xcovid19_tool.py42
1 files changed, 18 insertions, 24 deletions
diff --git a/covid19_tool.py b/covid19_tool.py
index e984c28..1cd0e48 100755
--- a/covid19_tool.py
+++ b/covid19_tool.py
@@ -38,25 +38,29 @@ def main():
default=9119,
help="listen on this port")
- sub_enrich = subparsers.add_parser('enrich',
- help="enrich CORD-19 dataset (JSON) with fatcat metadata")
- sub_enrich.set_defaults(
- action='enrich',
- )
- sub_enrich.add_argument('json_file',
- help="CORD-19 parsed JSON file",
+ sub_enrich_fatcat = subparsers.add_parser('enrich-fatcat',
+ help="lookup fatcat releases from JSON metadata")
+ sub_enrich_fatcat.add_argument('json_file',
+ help="input JSON rows file (eg, CORD-19 parsed JSON)",
type=argparse.FileType('r'))
+ sub_enrich_fatcat.add_argument('--json-output',
+ help="file to write to",
+ type=argparse.FileType('r'),
+ default=sys.stdout)
- sub_derivatives = subparsers.add_parser('derivatives',
+ sub_enrich_derivatives = subparsers.add_parser('enrich-derivatives',
help="enrich JSON rows with existing derivative files")
- sub_derivatives.add_argument('json_file',
+ sub_enrich_derivatives.set_defaults(
+ action='enrich-derivatives',
+ )
+ sub_enrich_derivatives.add_argument('json_file',
help="enriched (with fatcat_release) metadata file",
type=argparse.FileType('r'))
- sub_derivatives.add_argument('--json-output',
+ sub_enrich_derivatives.add_argument('--json-output',
help="file to write ",
type=argparse.FileType('r'),
default=sys.stdout)
- sub_derivatives.add_argument('--base-dir',
+ sub_enrich_derivatives.add_argument('--base-dir',
help="directory to look for files (in 'pdf' subdirectory)",
default="fulltext_web")
@@ -70,27 +74,17 @@ def main():
type=argparse.FileType('r'),
default=sys.stdout)
- sub_enrich_fatcat = subparsers.add_parser('enrich-fatcat',
- help="lookup fatcat releases from JSON metadata")
- sub_enrich_fatcat.add_argument('json_file',
- help="input JSON rows file (eg, CORD-19 parsed JSON)",
- type=argparse.FileType('r'))
- sub_enrich_fatcat.add_argument('--json-output',
- help="file to write to",
- type=argparse.FileType('r'),
- default=sys.stdout)
-
args = parser.parse_args()
if args.action == 'webface':
app.run(debug=args.debug, host=args.host, port=args.port)
- elif args.action == 'derivatives':
+ elif args.action == 'enrich-fatcat':
+ transform_es_file(args.json_file, args.json_output)
+ elif args.action == 'enrich-derivatives':
enrich_derivatives_file(args.json_file, args.json_output,
args.base_dir)
elif args.action == 'transform-es':
transform_es_file(args.json_file, args.json_output)
- elif args.action == 'enrich-fatcat':
- transform_es_file(args.json_file, args.json_output)
else:
print("tell me what to do!")
sys.exit(-1)