aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-09-25 15:00:05 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-09-25 15:00:05 -0700
commitc1d0fea36ff88cd8c01fbf5fc7d871ac08ffef70 (patch)
tree9818951b70849b19f3f8f55504bb3a0ab955dc3c /python
parent747281b45ddc35312c6978e0a38a3145abc8883a (diff)
downloadfatcat-c1d0fea36ff88cd8c01fbf5fc7d871ac08ffef70.tar.gz
fatcat-c1d0fea36ff88cd8c01fbf5fc7d871ac08ffef70.zip
more crossref_importer fixes (ugh)
Diffstat (limited to 'python')
-rw-r--r--python/fatcat/crossref_importer.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/python/fatcat/crossref_importer.py b/python/fatcat/crossref_importer.py
index 8e179b69..10efe59c 100644
--- a/python/fatcat/crossref_importer.py
+++ b/python/fatcat/crossref_importer.py
@@ -195,11 +195,20 @@ class FatcatCrossrefImporter(FatcatImporter):
if max(len(contribs), len(refs), len(abstracts)) > 750:
return None
+ # release date parsing is amazingly complex
release_date = obj['issued']['date-parts'][0]
- if len(release_date) == 3:
+ if not release_date or not release_date[0]:
+ # got some NoneType, even though at least year is supposed to be set
+ release_date = None
+ elif len(release_date) == 3:
release_date = datetime.datetime(year=release_date[0], month=release_date[1], day=release_date[2])
else:
+ # only the year is actually required; mangle to first day for date
+ # (TODO: something better?)
release_date = datetime.datetime(year=release_date[0], month=1, day=1)
+ # convert to string ISO datetime format (if not null)
+ if release_date:
+ release_date = release_date.isoformat() + "Z"
re = fatcat_client.ReleaseEntity(
work_id=None,
@@ -216,7 +225,7 @@ class FatcatCrossrefImporter(FatcatImporter):
pmid=extids['pmid'],
pmcid=extids['pmcid'],
wikidata_qid=extids['wikidata_qid'],
- release_date=release_date.isoformat() + "Z",
+ release_date=release_date,
issue=obj.get('issue'),
volume=obj.get('volume'),
pages=obj.get('page'),