summaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/importers/datacite.py
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2019-12-31 03:17:10 +0100
committerMartin Czygan <martin.czygan@gmail.com>2019-12-31 03:17:10 +0100
commit0c6332792d23f7bd5dd9508f28ffb7ddaee741f6 (patch)
tree2f67434eccdb465c4b3a10d2b7179744bf564b03 /python/fatcat_tools/importers/datacite.py
parentd951c59c1086f0cdda8683e1dd9083d9512886f3 (diff)
downloadfatcat-0c6332792d23f7bd5dd9508f28ffb7ddaee741f6.tar.gz
fatcat-0c6332792d23f7bd5dd9508f28ffb7ddaee741f6.zip
datacite: isascii was added in 3.7, only
Diffstat (limited to 'python/fatcat_tools/importers/datacite.py')
-rw-r--r--python/fatcat_tools/importers/datacite.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py
index b16f333a..fc97b1e3 100644
--- a/python/fatcat_tools/importers/datacite.py
+++ b/python/fatcat_tools/importers/datacite.py
@@ -181,6 +181,12 @@ LICENSE_SLUG_MAP = {
# Note: Some URLs pointing to licensing terms are not in WB yet (but would be nice).
}
+# TODO(martin): drop this after 3.7 upgrade
+try:
+ isascii = str.isascii # new in 3.7, https://docs.python.org/3/library/stdtypes.html#str.isascii
+except AttributeError:
+ isascii = lambda s: len(s) == len(s.encode())
+
class DataciteImporter(EntityImporter):
"""
@@ -270,7 +276,7 @@ class DataciteImporter(EntityImporter):
attributes = obj['attributes']
doi = clean_doi(attributes.get('doi', '').lower())
- if not doi.isascii():
+ if not isascii(doi):
print('[{}] skipping non-ascii doi for now'.format(doi))
return None