From 5b328d8a7ddeb641d588231c1f412fa0520c0f3d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 22 Apr 2019 17:01:24 -0700 Subject: editgroup description override --- python/fatcat_import.py | 12 +++++++++++- python/fatcat_tools/importers/matched.py | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/python/fatcat_import.py b/python/fatcat_import.py index de5b4202..c421fb43 100755 --- a/python/fatcat_import.py +++ b/python/fatcat_import.py @@ -28,7 +28,8 @@ def run_journal_metadata(args): def run_matched(args): fmi = MatchedImporter(args.api, - edit_batch_size=args.batch_size) + edit_batch_size=args.batch_size, + editgroup_description=args.editgroup_description_override) JsonLinePusher(fmi, args.json_file).run() def run_arabesque_match(args): @@ -115,6 +116,9 @@ def main(): parser.add_argument('--batch-size', help="size of batch to send", default=50, type=int) + parser.add_argument('--editgroup-description-override', + help="editgroup description override", + default=None, type=str) subparsers = parser.add_subparsers() sub_crossref = subparsers.add_parser('crossref') @@ -249,6 +253,12 @@ def main(): print("tell me what to do!") sys.exit(-1) + # allow editgroup description override via env variable (but CLI arg takes + # precedence) + if not args.editgroup_description_override \ + and os.environ.get('FATCAT_EDITGROUP_DESCRIPTION'): + args.editgroup_description_override = os.environ.get('FATCAT_EDITGROUP_DESCRIPTION') + args.api = authenticated_api( args.host_url, # token is an optional kwarg (can be empty string, None, etc) diff --git a/python/fatcat_tools/importers/matched.py b/python/fatcat_tools/importers/matched.py index 7868fb75..5096cc97 100644 --- a/python/fatcat_tools/importers/matched.py +++ b/python/fatcat_tools/importers/matched.py @@ -33,9 +33,9 @@ class MatchedImporter(EntityImporter): def __init__(self, api, **kwargs): - eg_desc = kwargs.get('editgroup_description', + eg_desc = kwargs.pop('editgroup_description', "Import of large-scale file-to-release match results. Source of metadata varies.") - eg_extra = kwargs.get('editgroup_extra', dict()) + eg_extra = kwargs.pop('editgroup_extra', dict()) eg_extra['agent'] = eg_extra.get('agent', 'fatcat_tools.MatchedImporter') super().__init__(api, editgroup_description=eg_desc, -- cgit v1.2.3