aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/importers
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-30 14:48:16 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-30 14:48:16 -0700
commitab5755117907a5e4f55e3b508c75f4f5220c6333 (patch)
tree4334e19ed05d492628ef8fe12931f1bde1ccde28 /python/fatcat_tools/importers
parentd6ab59e69c3235b5ac4085624987b45c25f577ec (diff)
downloadfatcat-ab5755117907a5e4f55e3b508c75f4f5220c6333.tar.gz
fatcat-ab5755117907a5e4f55e3b508c75f4f5220c6333.zip
journal_metadata import: allow KBART updates
Diffstat (limited to 'python/fatcat_tools/importers')
-rw-r--r--python/fatcat_tools/importers/journal_metadata.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/python/fatcat_tools/importers/journal_metadata.py b/python/fatcat_tools/importers/journal_metadata.py
index 89ad6fc0..d24b4103 100644
--- a/python/fatcat_tools/importers/journal_metadata.py
+++ b/python/fatcat_tools/importers/journal_metadata.py
@@ -110,16 +110,27 @@ class JournalMetadataImporter(EntityImporter):
except fatcat_client.rest.ApiException as err:
if err.status != 404:
raise err
- # doesn't exist, need to update
+
+ if not existing:
+ # doesn't exist, create it
return True
- # eventually we'll want to support "updates", but for now just skip if
- # entity already exists
- if existing:
+ # for now, only update KBART, and only if there is new content
+ if not existing.extra:
+ existing.extra = dict()
+ if ce.extra.get('kbart') and (existing.extra.get('kbart') != ce.extra['kbart']):
+ if not existing.extra.get('kbart'):
+ existing.extra['kbart'] = {}
+ existing.extra['kbart'].update(ce.extra['kbart'])
+ self.api.update_container(self.get_editgroup_id(), existing.ident, existing)
+ self.counts['update'] += 1
+ return False
+ else:
self.counts['exists'] += 1
return False
- return True
+ # if we got this far, it's a bug
+ raise NotImplementedError
def insert_batch(self, batch):
self.api.create_container_auto_batch(fatcat_client.ContainerAutoBatch(