From 5b376b98ca6fe8e9f75a42c807786a2aa9a52d94 Mon Sep 17 00:00:00 2001 From: Vinay Goel Date: Thu, 21 Jun 2018 21:24:13 +0000 Subject: crossref importer tweaks and fixes --- python/fatcat/crossref_importer.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/fatcat/crossref_importer.py b/python/fatcat/crossref_importer.py index ea6b1a2c..06c162f0 100644 --- a/python/fatcat/crossref_importer.py +++ b/python/fatcat/crossref_importer.py @@ -18,17 +18,28 @@ class FatcatCrossrefImporter(FatcatImporter): returns a ReleaseEntity """ + # This work is out of scope if it doesn't have authors or a title + if (not 'author' in obj) or (not 'title' in obj): + return None + # contribs contribs = [] for i, am in enumerate(obj['author']): creator_id = None if 'ORCID' in am.keys(): creator_id = self.lookup_orcid(am['ORCID'].split('/')[-1]) + # Sorry humans :( + if am.get('given') and am.get('family'): + raw_name = "{} {}".format(am['given'], am['family']) + elif am.get('family'): + raw_name = am['family'] + else: + # TODO: defaults back to a pseudo-null value + raw_name = am.get('given', '') contribs.append(fatcat_client.ReleaseContrib( creator_id=creator_id, index=i+1, - # Sorry humans :( - raw="{} {}".format(am['given'], am['family']), + raw=raw_name, role="author")) # container @@ -45,7 +56,6 @@ class FatcatCrossrefImporter(FatcatImporter): issnl=issnl, publisher=publisher, name=obj['container-title'][0]) - print("created container: {}".format(issnl)) # references refs = [] -- cgit v1.2.3