aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/importers/datacite.py
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2020-07-24 10:11:37 +0000
committerMartin Czygan <martin@archive.org>2020-07-24 10:11:37 +0000
commit8b00843af1366cf019c896057706ace4afff27ba (patch)
tree86fc58bf26f07e272aa27e989f3ab6b4cfef2090 /python/fatcat_tools/importers/datacite.py
parent2170e5ff46dfb2bba9bf26196de3c3774c16cd4a (diff)
parentfc93f35996cab23984d9a45f1a411b8776e437bf (diff)
downloadfatcat-8b00843af1366cf019c896057706ace4afff27ba.tar.gz
fatcat-8b00843af1366cf019c896057706ace4afff27ba.zip
Merge branch 'bnewbold-more-lint-fixes' into 'master'
more lint fixes See merge request webgroup/fatcat!69
Diffstat (limited to 'python/fatcat_tools/importers/datacite.py')
-rw-r--r--python/fatcat_tools/importers/datacite.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py
index ebb29feb..f93362d6 100644
--- a/python/fatcat_tools/importers/datacite.py
+++ b/python/fatcat_tools/importers/datacite.py
@@ -191,12 +191,6 @@ LICENSE_SLUG_MAP = {
"//spdx.org/licenses/OGL-Canada-2.0.json": "OGL-Canada",
}
-# 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):
"""
@@ -287,7 +281,7 @@ class DataciteImporter(EntityImporter):
print('skipping record without a DOI', file=sys.stderr)
return
- if not isascii(doi):
+ if not str.isascii(doi):
print('[{}] skipping non-ascii doi for now'.format(doi))
return None
@@ -466,7 +460,7 @@ class DataciteImporter(EntityImporter):
try:
_ = int(first_page) < int(last_page)
pages = '{}-{}'.format(first_page, last_page)
- except ValueError as err:
+ except ValueError as err: # noqa: F841
# TODO(martin): This is more debug than info.
# print('[{}] {}'.format(doi, err), file=sys.stderr)
pass
@@ -478,11 +472,11 @@ class DataciteImporter(EntityImporter):
license_slug = None
license_extra = []
- for l in attributes.get('rightsList', []):
- slug = lookup_license_slug(l.get('rightsUri'))
+ for lic in attributes.get('rightsList', []):
+ slug = lookup_license_slug(lic.get('rightsUri'))
if slug:
license_slug = slug
- license_extra.append(l)
+ license_extra.append(lic)
# Release type. Try to determine the release type from a variety of
# types supplied in datacite. The "attributes.types.resourceType" is
@@ -524,7 +518,7 @@ class DataciteImporter(EntityImporter):
value = attributes.get('language', '') or ''
try:
language = pycountry.languages.lookup(value).alpha_2
- except (LookupError, AttributeError) as err:
+ except (LookupError, AttributeError) as err: # noqa: F841
pass
# TODO(martin): Print this on debug level, only.
# print('[{}] language lookup miss for {}: {}'.format(doi, value, err), file=sys.stderr)
@@ -549,7 +543,7 @@ class DataciteImporter(EntityImporter):
if isinstance(text, list):
try:
text = "\n".join(text)
- except TypeError as err:
+ except TypeError:
continue # Bail out, if it is not a list of strings.
# Limit length.
@@ -760,7 +754,7 @@ class DataciteImporter(EntityImporter):
i = 0
for c in creators:
if not set_index:
- i = None
+ i = None
nameType = c.get('nameType', '') or ''
if nameType in ('', 'Personal'):
creator_id = None