aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Goel <vinay@archive.org>2018-06-21 21:23:54 +0000
committerVinay Goel <vinay@archive.org>2018-06-21 21:23:54 +0000
commit7de80cd1641f575795067bcfa6aefca6eaa7f052 (patch)
tree99c409839af604af3fa4a78808e8b5561b5a70ad
parentafc44f15c993cf64d7cd4554ab9410a172f2e1fc (diff)
downloadfatcat-7de80cd1641f575795067bcfa6aefca6eaa7f052.tar.gz
fatcat-7de80cd1641f575795067bcfa6aefca6eaa7f052.zip
ORCID importer tweaks
-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,