diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 18:14:59 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 18:14:59 -0700 |
commit | 31d1a6a713d177990609767d508209ced19ca396 (patch) | |
tree | a628a57bdb373669394a6b520102b1b4b5ffe7da /python/fatcat_tools/importers/fileset_generic.py | |
parent | 9dc891b8098542bb089c8c47098b60a8beb76a53 (diff) | |
download | fatcat-31d1a6a713d177990609767d508209ced19ca396.tar.gz fatcat-31d1a6a713d177990609767d508209ced19ca396.zip |
fmt (black): fatcat_tools/
Diffstat (limited to 'python/fatcat_tools/importers/fileset_generic.py')
-rw-r--r-- | python/fatcat_tools/importers/fileset_generic.py | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/python/fatcat_tools/importers/fileset_generic.py b/python/fatcat_tools/importers/fileset_generic.py index 43c2a49c..dd8f5600 100644 --- a/python/fatcat_tools/importers/fileset_generic.py +++ b/python/fatcat_tools/importers/fileset_generic.py @@ -1,4 +1,3 @@ - import fatcat_openapi_client from fatcat_tools import entity_from_dict @@ -20,34 +19,31 @@ class FilesetImporter(EntityImporter): def __init__(self, api, **kwargs): - eg_desc = kwargs.pop('editgroup_description', None) or "Generic Fileset entity import" - eg_extra = kwargs.pop('editgroup_extra', dict()) - eg_extra['agent'] = eg_extra.get('agent', 'fatcat_tools.FilesetImporter') - kwargs['do_updates'] = bool(kwargs.get("do_updates", False)) + eg_desc = kwargs.pop("editgroup_description", None) or "Generic Fileset entity import" + eg_extra = kwargs.pop("editgroup_extra", dict()) + eg_extra["agent"] = eg_extra.get("agent", "fatcat_tools.FilesetImporter") + kwargs["do_updates"] = bool(kwargs.get("do_updates", False)) self.skip_release_fileset_check = bool(kwargs.get("skip_release_fileset_check", False)) - super().__init__(api, - editgroup_description=eg_desc, - editgroup_extra=eg_extra, - **kwargs) + super().__init__(api, editgroup_description=eg_desc, editgroup_extra=eg_extra, **kwargs) # bezerk mode doesn't make sense for this importer assert self.bezerk_mode is False def want(self, row): - if not row.get('release_ids'): - self.counts['skip-no-release-ids'] += 1 + if not row.get("release_ids"): + self.counts["skip-no-release-ids"] += 1 return False - if not row.get('urls'): - self.counts['skip-no-urls'] += 1 + if not row.get("urls"): + self.counts["skip-no-urls"] += 1 return False - if not row.get('manifest'): - self.counts['skip-no-files'] += 1 + if not row.get("manifest"): + self.counts["skip-no-files"] += 1 return False - for f in row.get('manifest'): - for k in ('sha1', 'md5'): + for f in row.get("manifest"): + for k in ("sha1", "md5"): if not f.get(k): - self.counts['skip-missing-file-field'] += 1 + self.counts["skip-missing-file-field"] += 1 return False return True @@ -66,19 +62,24 @@ class FilesetImporter(EntityImporter): if not self.skip_release_fileset_check: for release_id in fse.release_ids: # don't catch 404, that would be an error - release = self.api.get_release(release_id, expand='filesets', hide='abstracts,refs') - assert release.state == 'active' + release = self.api.get_release( + release_id, expand="filesets", hide="abstracts,refs" + ) + assert release.state == "active" if release.filesets: - self.counts['exists'] += 1 - self.counts['exists-via-release-filesets'] += 1 + self.counts["exists"] += 1 + self.counts["exists-via-release-filesets"] += 1 return False # do the insert return True def insert_batch(self, batch): - self.api.create_fileset_auto_batch(fatcat_openapi_client.FilesetAutoBatch( - editgroup=fatcat_openapi_client.Editgroup( - description=self.editgroup_description, - extra=self.editgroup_extra), - entity_list=batch)) + self.api.create_fileset_auto_batch( + fatcat_openapi_client.FilesetAutoBatch( + editgroup=fatcat_openapi_client.Editgroup( + description=self.editgroup_description, extra=self.editgroup_extra + ), + entity_list=batch, + ) + ) |