SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 6a0a4303 authored by Boris Ponsioen's avatar Boris Ponsioen
Browse files

Removes error handling in get_crossref_test temporarily

parent 5591e33e
No related branches found
No related tags found
No related merge requests found
...@@ -22,8 +22,8 @@ def get_crossref_test(cursor='*'): ...@@ -22,8 +22,8 @@ def get_crossref_test(cursor='*'):
batches = 2000 batches = 2000
for i in range(0,batches): for i in range(0,batches):
print("Batch %s" % (i, ))
print("-------------------------------") print("-------------------------------")
print("Batch %s" % (i, ))
print(cursor) print(cursor)
params = {'cursor': cursor, 'rows': rows, 'mailto': 'b.g.t.ponsioen@uva.nl'} params = {'cursor': cursor, 'rows': rows, 'mailto': 'b.g.t.ponsioen@uva.nl'}
...@@ -74,40 +74,41 @@ def parse_crossref_citable(citable_item): ...@@ -74,40 +74,41 @@ def parse_crossref_citable(citable_item):
return return
if not Citable.objects(doi=doi): if not Citable.objects(doi=doi):
try: # try:
# Parse certain fields for storage on top level in document # Parse certain fields for storage on top level in document
# Blame the convoluted joining and looping on CR # Blame the convoluted joining and looping on CR
if 'reference' in citable_item: if 'reference' in citable_item:
references_with_doi = [ref for ref in citable_item['reference'] if 'DOI' in ref] references_with_doi = [ref for ref in citable_item['reference'] if 'DOI' in ref]
references = [ref['DOI'].lower() for ref in references_with_doi] references = [ref['DOI'].lower() for ref in references_with_doi]
else: else:
references = [] references = []
authors = [] authors = []
for author_names in citable_item['author']: for author_names in citable_item['author']:
author = [] author = []
if 'given' in author_names: if 'given' in author_names:
author.append(author_names['given']) author.append(author_names['given'])
if 'family' in author_names: if 'family' in author_names:
author.append(author_names['family']) author.append(author_names['family'])
authors.append(' '.join(author)) authors.append(' '.join(author))
publisher = citable_item['publisher'] publisher = citable_item['publisher']
title = citable_item['title'][0] title = citable_item['title'][0]
publication_date = '-'.join([str(date_part) for date_part in citable_item['issued']['date-parts'][0]]) publication_date = '-'.join([str(date_part) for date_part in citable_item['issued']['date-parts'][0]])
if 'license' in citable_item: if 'license' in citable_item:
license = citable_item['license'][0]['URL'] license = citable_item['license'][0]['URL']
else: else:
license = '' license = ''
return CitableWithDOI(doi=doi, references=references, authors=authors, publisher=publisher, title=title, return CitableWithDOI(doi=doi, references=references, authors=authors, publisher=publisher, title=title,
publication_date=publication_date, license=license, metadata=citable_item) publication_date=publication_date, license=license, metadata=citable_item)
except BaseException as e: # except BaseException as e:
print(e) # print("Error!")
# raise # print(e)
except e: # # raise
print("Error: ", e) # except e:
print(citable_item) # print("Error: ", e)
# print(citable_item)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment