aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/importers/jalc.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 13:57:18 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:46:07 -0700
commit5d29d1336afc90d3575a0379a9e9d9bdac8d1856 (patch)
treec22755cdf2615453ab1f3b7ddaf13becd946a63d /python/fatcat_tools/importers/jalc.py
parentcaf1cb316ed18820f3239a285ef14bf45ef963a2 (diff)
downloadfatcat-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/jalc.py')
-rw-r--r--python/fatcat_tools/importers/jalc.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/python/fatcat_tools/importers/jalc.py b/python/fatcat_tools/importers/jalc.py
index f540c264..2f10e533 100644
--- a/python/fatcat_tools/importers/jalc.py
+++ b/python/fatcat_tools/importers/jalc.py
@@ -193,6 +193,9 @@ class JalcImporter(EntityImporter):
doi = None
if record.doi:
doi = clean_doi(record.doi.string.strip().lower())
+ # TODO: following code is redundant with clean_doi()
+ if not doi:
+ return None
if doi.startswith("http://dx.doi.org/"):
doi = doi.replace("http://dx.doi.org/", "")
elif doi.startswith("https://dx.doi.org/"):
@@ -220,11 +223,11 @@ class JalcImporter(EntityImporter):
if date:
date = date.string
if len(date) == 10:
- release_date = datetime.datetime.strptime(
+ release_date_date = datetime.datetime.strptime(
date["completed-date"], DATE_FMT
).date()
- release_year = release_date.year
- release_date = release_date.isoformat()
+ release_year = release_date_date.year
+ release_date = release_date_date.isoformat()
elif len(date) == 4 and date.isdigit():
release_year = int(date)
@@ -252,7 +255,10 @@ class JalcImporter(EntityImporter):
# if we wanted the other ISSNs, would also need to uniq the list.
# But we only need one to lookup ISSN-L/container
issn = issn_list[0].string
- issnl = self.issn2issnl(issn)
+ if issn:
+ issnl = self.issn2issnl(issn)
+ else:
+ issnl = None
container_id = None
if issnl:
container_id = self.lookup_issnl(issnl)