Skip to content
Snippets Groups Projects
Commit a1a16e44 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

python 3.4 compatibility

parent edc9a57b
Branches
Tags
1 merge request!1Wizard form
...@@ -169,7 +169,7 @@ def get_doi_info(doi): ...@@ -169,7 +169,7 @@ def get_doi_info(doi):
:return: publication metadata (title, journal name, publication year, authors list). :return: publication metadata (title, journal name, publication year, authors list).
:rtype: dict :rtype: dict
""" """
resp = requests.get(f'http://dx.doi.org/{doi}', headers={'Accept':'application/vnd.citationstyles.csl+json'}) resp = requests.get('http://dx.doi.org/%s' % doi, headers={'Accept':'application/vnd.citationstyles.csl+json'})
resp.raise_for_status() resp.raise_for_status()
json_data = resp.json() json_data = resp.json()
title = json_data['title'] title = json_data['title']
...@@ -185,18 +185,18 @@ def get_doi_info(doi): ...@@ -185,18 +185,18 @@ def get_doi_info(doi):
else: else:
biblio_year = json_data['published-online']['date-parts'][0][0] biblio_year = json_data['published-online']['date-parts'][0][0]
except KeyError as e: except KeyError as e:
print(f'http://dx.doi.org/{doi}') print('http://dx.doi.org/%s' % doi)
print(json_data) print(json_data)
raise e raise e
authors_list = [] authors_list = []
for author_data in json_data['author']: for author_data in json_data['author']:
try: try:
if 'family' in author_data: if 'family' in author_data:
authors_list.append(f'{author_data["family"]} {author_data.get("given","")}') authors_list.append('%s %s' % (author_data["family"], author_data.get("given", "")))
else: else:
authors_list.append(author_data['name']) authors_list.append(author_data['name'])
except KeyError as e: except KeyError as e:
print(f'http://dx.doi.org/{doi}') print('http://dx.doi.org/%s' % doi)
print(json_data) print(json_data)
raise e raise e
authors = ', '.join(authors_list) authors = ', '.join(authors_list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment