diff options
| author | Vinay Goel <vinay@archive.org> | 2018-06-21 21:23:54 +0000 | 
|---|---|---|
| committer | Vinay Goel <vinay@archive.org> | 2018-06-21 21:23:54 +0000 | 
| commit | 7de80cd1641f575795067bcfa6aefca6eaa7f052 (patch) | |
| tree | 99c409839af604af3fa4a78808e8b5561b5a70ad /python | |
| parent | afc44f15c993cf64d7cd4554ab9410a172f2e1fc (diff) | |
| download | fatcat-7de80cd1641f575795067bcfa6aefca6eaa7f052.tar.gz fatcat-7de80cd1641f575795067bcfa6aefca6eaa7f052.zip | |
ORCID importer tweaks
Diffstat (limited to 'python')
| -rw-r--r-- | python/fatcat/orcid_importer.py | 18 | 
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, | 
