From 7c18e1d22b16bb920c9bb9a788691820bbdb2bfa Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 14 May 2019 18:01:27 -0700 Subject: python impl --- python/fatcat_tools/importers/arabesque.py | 11 ++++++----- python/fatcat_tools/importers/cdl_dash_dat.py | 4 ++-- python/fatcat_tools/importers/common.py | 6 +++--- python/fatcat_tools/importers/crossref.py | 9 +++++---- python/fatcat_tools/importers/grobid_metadata.py | 9 +++++---- python/fatcat_tools/importers/journal_metadata.py | 9 +++++---- python/fatcat_tools/importers/matched.py | 11 ++++++----- python/fatcat_tools/importers/orcid.py | 9 +++++---- python/fatcat_tools/importers/wayback_static.py | 2 +- 9 files changed, 38 insertions(+), 32 deletions(-) (limited to 'python/fatcat_tools') diff --git a/python/fatcat_tools/importers/arabesque.py b/python/fatcat_tools/importers/arabesque.py index bf9600dc..ea38ec2f 100644 --- a/python/fatcat_tools/importers/arabesque.py +++ b/python/fatcat_tools/importers/arabesque.py @@ -186,14 +186,15 @@ class ArabesqueMatchImporter(EntityImporter): self.counts['skip-update-too-many-url'] += 1 return None existing.mimetype = existing.mimetype or fe.mimetype - edit = self.api.update_file(existing.ident, existing, editgroup_id=self.get_editgroup_id()) + edit = self.api.update_file(self.get_editgroup_id(), existing.ident, existing) self._edits_inflight.append(edit) self.counts['update'] += 1 return False def insert_batch(self, batch): - self.api.create_file_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_file_auto_batch(fatcat_client.FileAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/cdl_dash_dat.py b/python/fatcat_tools/importers/cdl_dash_dat.py index 9c2bdefc..5175aa89 100755 --- a/python/fatcat_tools/importers/cdl_dash_dat.py +++ b/python/fatcat_tools/importers/cdl_dash_dat.py @@ -179,7 +179,7 @@ def auto_cdl_dash_dat(api, dat_path, release_id=None, editgroup_id=None): except fatcat_client.rest.ApiException: pass if not release_id: - edit = api.create_release(release, editgroup_id=editgroup_id) + edit = api.create_release(eg.editgroup_id, release) release_id = edit.ident release = api.get_release(release_id, expand="filesets") @@ -188,7 +188,7 @@ def auto_cdl_dash_dat(api, dat_path, release_id=None, editgroup_id=None): return (None, None, None) fileset.release_ids = [release.ident] - edit = api.create_fileset(fileset, editgroup_id=editgroup_id) + edit = api.create_fileset(eg.editgroup_id, fileset) fileset = api.get_fileset(edit.ident) return (editgroup_id, release, fileset) diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py index d291aeec..282f775c 100644 --- a/python/fatcat_tools/importers/common.py +++ b/python/fatcat_tools/importers/common.py @@ -237,17 +237,17 @@ class EntityImporter: def create_container(self, entity): eg_id = self.get_editgroup_id() self.counts['inserted.container'] += 1 - return self.api.create_container(entity, editgroup_id=eg_id) + return self.api.create_container(eg_id, entity) def create_release(self, entity): eg_id = self.get_editgroup_id() self.counts['inserted.release'] += 1 - return self.api.create_release(entity, editgroup_id=eg_id) + return self.api.create_release(eg_id, entity) def create_file(self, entity): eg_id = self.get_editgroup_id() self.counts['inserted.file'] += 1 - return self.api.create_file(entity, editgroup_id=eg_id) + return self.api.create_file(eg_id, entity) def updated(self): """ diff --git a/python/fatcat_tools/importers/crossref.py b/python/fatcat_tools/importers/crossref.py index 443879e7..9b1cd2c3 100644 --- a/python/fatcat_tools/importers/crossref.py +++ b/python/fatcat_tools/importers/crossref.py @@ -467,8 +467,9 @@ class CrossrefImporter(EntityImporter): return True def insert_batch(self, batch): - self.api.create_release_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_release_auto_batch(fatcat_client.ReleaseAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/grobid_metadata.py b/python/fatcat_tools/importers/grobid_metadata.py index 573346a1..ea627dd6 100644 --- a/python/fatcat_tools/importers/grobid_metadata.py +++ b/python/fatcat_tools/importers/grobid_metadata.py @@ -193,7 +193,8 @@ class GrobidMetadataImporter(EntityImporter): return True def insert_batch(self, batch): - self.api.create_file_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_file_auto_batch(fatcat_client.FileAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/journal_metadata.py b/python/fatcat_tools/importers/journal_metadata.py index 9bba2b12..89ad6fc0 100644 --- a/python/fatcat_tools/importers/journal_metadata.py +++ b/python/fatcat_tools/importers/journal_metadata.py @@ -122,7 +122,8 @@ class JournalMetadataImporter(EntityImporter): return True def insert_batch(self, batch): - self.api.create_container_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_container_auto_batch(fatcat_client.ContainerAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/matched.py b/python/fatcat_tools/importers/matched.py index f3f2e141..4d78fdc9 100644 --- a/python/fatcat_tools/importers/matched.py +++ b/python/fatcat_tools/importers/matched.py @@ -143,13 +143,14 @@ class MatchedImporter(EntityImporter): existing.size = existing.size or fe.size existing.md5 = existing.md5 or fe.md5 existing.sha256 = existing.sha256 or fe.sha256 - self.api.update_file(existing.ident, existing, editgroup_id=self.get_editgroup_id()) + self.api.update_file(self.get_editgroup_id(), existing.ident, existing) self.counts['update'] += 1 return False def insert_batch(self, batch): - self.api.create_file_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_file_auto_batch(fatcat_client.FileAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/orcid.py b/python/fatcat_tools/importers/orcid.py index 928b9627..0bdd5d19 100644 --- a/python/fatcat_tools/importers/orcid.py +++ b/python/fatcat_tools/importers/orcid.py @@ -89,7 +89,8 @@ class OrcidImporter(EntityImporter): return True def insert_batch(self, batch): - self.api.create_creator_batch(batch, - autoaccept=True, - description=self.editgroup_description, - extra=json.dumps(self.editgroup_extra)) + self.api.create_creator_auto_batch(fatcat_client.CreatorAutoBatch( + editgroup=fatcat_client.Editgroup( + description=self.editgroup_description, + extra=self.editgroup_extra), + entity_list=batch)) diff --git a/python/fatcat_tools/importers/wayback_static.py b/python/fatcat_tools/importers/wayback_static.py index 73779b95..72f4d658 100755 --- a/python/fatcat_tools/importers/wayback_static.py +++ b/python/fatcat_tools/importers/wayback_static.py @@ -207,7 +207,7 @@ def auto_wayback_static(api, release_id, wayback_url, editgroup_id=None): git_rev=git_rev, agent="fatcat_tools.auto_wayback_static"))) editgroup_id = eg.editgroup_id - edit = api.create_webcapture(wc, editgroup_id=editgroup_id) + edit = api.create_webcapture(eg.editgroup_id, wc) return (editgroup_id, edit) def main(): -- cgit v1.2.3