summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/fatcat/orcid_importer.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/python/fatcat/orcid_importer.py b/python/fatcat/orcid_importer.py
index fb4716df..a480be16 100644
--- a/python/fatcat/orcid_importer.py
+++ b/python/fatcat/orcid_importer.py
@@ -11,6 +11,14 @@ def value_or_none(e):
e = e.get('value')
if type(e) == str and len(e) == 0:
e = None
+ # TODO: this is probably bogus; patched in desperation; remove?
+ if e:
+ try:
+ e.encode()
+ except UnicodeEncodeError:
+ # Invalid JSON?
+ print("BAD UNICODE")
+ return None
return e
class FatcatOrcidImporter(FatcatImporter):
@@ -29,7 +37,15 @@ class FatcatOrcidImporter(FatcatImporter):
display = value_or_none(name.get('credit-name'))
if display is None:
# TODO: sorry human beings
- display = "{} {}".format(given, sur)
+ if given and sur:
+ display = "{} {}".format(given, sur)
+ elif sur:
+ display = sur
+ elif given:
+ display = given
+ else:
+ # must have *some* name
+ return None
ce = fatcat_client.CreatorEntity(
orcid=obj['orcid-identifier']['path'],
given_name=given,