diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 13:57:18 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 16:46:07 -0700 |
commit | 5d29d1336afc90d3575a0379a9e9d9bdac8d1856 (patch) | |
tree | c22755cdf2615453ab1f3b7ddaf13becd946a63d /python/fatcat_tools/importers/jstor.py | |
parent | caf1cb316ed18820f3239a285ef14bf45ef963a2 (diff) | |
download | fatcat-5d29d1336afc90d3575a0379a9e9d9bdac8d1856.tar.gz fatcat-5d29d1336afc90d3575a0379a9e9d9bdac8d1856.zip |
typing: relatively simple type check fixes
These mostly add new variable names so that existing variables aren't
overwritten with a new type; delay coercing '{}' or '[]' to 'None' until
the last minute; adding is-not-None checks to conditional clauses; and
similar small changes.
Diffstat (limited to 'python/fatcat_tools/importers/jstor.py')
-rw-r--r-- | python/fatcat_tools/importers/jstor.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/python/fatcat_tools/importers/jstor.py b/python/fatcat_tools/importers/jstor.py index 0a6eec65..2c8aa0a4 100644 --- a/python/fatcat_tools/importers/jstor.py +++ b/python/fatcat_tools/importers/jstor.py @@ -52,6 +52,8 @@ class JstorImporter(EntityImporter): self.read_issn_map_file(issn_map_file) def map_container_type(self, crossref_type: Optional[str]) -> Optional[str]: + if not crossref_type: + return None return CONTAINER_TYPE_MAP.get(crossref_type) def want(self, raw_record: Any) -> bool: @@ -75,7 +77,12 @@ class JstorImporter(EntityImporter): elif title and not title.get_text(): title = None - if not title and release_type.startswith("review") and article_meta.product.source: + if ( + not title + and release_type + and release_type.startswith("review") + and article_meta.product.source + ): title = "Review: {}".format( article_meta.product.source.replace("\n", " ").get_text() ) @@ -240,8 +247,6 @@ class JstorImporter(EntityImporter): # pubmed: retraction refs if extra_jstor: extra["jstor"] = extra_jstor - if not extra: - extra = None re = fatcat_openapi_client.ReleaseEntity( # work_id @@ -270,7 +275,7 @@ class JstorImporter(EntityImporter): # name, type, publisher, issnl # extra: issnp, issne, original_name, languages, country container_id=container_id, - extra=extra, + extra=extra or None, ) return re |