38def response(resp):
39 results = []
40 json_data = loads(resp.text)
41
42 for record in json_data['records']:
43 published = datetime.strptime(record['publicationDate'], '%Y-%m-%d')
44 authors = [" ".join(author['creator'].split(', ')[::-1]) for author in record['creators']]
45 tags = record.get('genre')
46 if isinstance(tags, str):
47 tags = [tags]
48 results.append(
49 {
50 'template': 'paper.html',
51 'url': record['url'][0]['value'].replace('http://', 'https://', 1),
52 'title': record['title'],
53 'content': record['abstract'],
54 'comments': record['publicationName'],
55 'tags': tags,
56 'publishedDate': published,
57 'type': record.get('contentType'),
58 'authors': authors,
59
60 'publisher': record.get('publisher'),
61 'journal': record.get('publicationName'),
62 'volume': record.get('volume') or None,
63 'pages': '-'.join([x for x in [record.get('startingPage'), record.get('endingPage')] if x]),
64 'number': record.get('number') or None,
65 'doi': record.get('doi'),
66 'issn': [x for x in [record.get('issn')] if x],
67 'isbn': [x for x in [record.get('isbn')] if x],
68
69 }
70 )
71 return results