summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2020-06-29 19:43:09 +0200
committerMartin Czygan <martin.czygan@gmail.com>2020-06-29 19:43:09 +0200
commit9f0e3f2af03161337b86308db0d1142b158282db (patch)
treed693068634bfa2ecb7e82990ea586a09b1895585 /python
parented1893bbc1e5e26c095a5e1f6ba3d1b15a959bab (diff)
downloadfatcat-9f0e3f2af03161337b86308db0d1142b158282db.tar.gz
fatcat-9f0e3f2af03161337b86308db0d1142b158282db.zip
datacite: hard cast possible date value to string
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_tools/importers/datacite.py2
-rw-r--r--python/tests/import_datacite.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py
index d998f266..98393451 100644
--- a/python/fatcat_tools/importers/datacite.py
+++ b/python/fatcat_tools/importers/datacite.py
@@ -1027,7 +1027,7 @@ def parse_datacite_dates(dates):
)
def parse_item(item):
- result, value, year_only = None, item.get('date', '') or '', False
+ result, value, year_only = None, str(item.get('date', '')) or '', False
release_date, release_month, release_year = None, None, None
for layout, granularity in common_patterns:
diff --git a/python/tests/import_datacite.py b/python/tests/import_datacite.py
index c9210ea4..afee06cc 100644
--- a/python/tests/import_datacite.py
+++ b/python/tests/import_datacite.py
@@ -174,6 +174,7 @@ def test_parse_datacite_dates():
Case('empty list is None', [], (None, None, None)),
Case('empty item is None', [{}], (None, None, None)),
Case('year only yields year only', [{'date': '2019'}], (None, None, 2019)),
+ Case('int year', [{'date': 2019}], (None, None, 2019)),
Case('first wins', [{'date': '2019'}, {'date': '2020'}], (None, None, 2019)),
Case('skip bogus year', [{'date': 'abc'}, {'date': '2020'}], (None, None, 2020)),
Case('first with type', [