Skip to content

Commit 58b7fed

Browse files
committed
export endpoint format changes
1 parent 90c5157 commit 58b7fed

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

server/workers/api/src/apis/export.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from bibtexparser.bibdatabase import BibDatabase
77
import dateutil.parser as parser
88
import pytz
9+
import re
910

1011
export_ns = Namespace("export", description="metadata export API operations")
1112

@@ -20,15 +21,27 @@ def parse_date(date):
2021
parsed_date["day"] = str(dt.day)
2122
return parsed_date
2223

24+
def create_authorfield(authors_objects):
25+
authors = []
26+
for ao in authors_objects:
27+
if "lastName" in ao:
28+
author = ao["lastName"]
29+
if "lastName" in ao and "firstName" in ao:
30+
author = "{lastName}, {firstName}".format(**ao)
31+
authors.append(author)
32+
authorstring = " and ".join(authors)
33+
return authorstring
34+
2335
def transform2bibtex(metadata):
2436
# TODO: add mapping from resulttype to ARTICLETYPE
2537
# possible published_in parser
2638
# field renaming, e.g. paper_abstract to abstract
2739
# choose correct fields, e.g. author_string for author
2840
# use different field for ID
2941
title = metadata.get("title", "")
30-
author = metadata.get("authors", "")
42+
author = create_authorfield(metadata.get("authors_objects", []))
3143
doi = metadata.get("doi", "")
44+
doi = re.sub("https://|http://|dx.doi.org/|doi.org/", "", doi)
3245
id = metadata.get("id", "")
3346
published_in = metadata.get("published_in", "")
3447
url = metadata.get("list_link", {}).get("address", "")

0 commit comments

Comments
 (0)