Skip to content

Commit a436d1f

Browse files
committed
TL: fixed arXiv script
1 parent f66bba8 commit a436d1f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/arxiv_to_publications_correct.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
author["given"] = ''
4949
authors = " and ".join([author['given'] + ' ' + author['family'] for author in data["author"]])
5050
candidate_title = re.sub('[^A-Za-z0-9]+', '', data['title'])
51-
existing_title = re.sub('[^A-Za-z0-9]+', '', d[id]['title'])
52-
if authors == d[id]['author'] and candidate_title == existing_title:
51+
existing_title = re.sub('[^A-Za-z0-9]+', '', d[id].get('title', ""))
52+
if authors == d[id].get('author', "") and candidate_title == existing_title:
5353
print(f'I detected a duplicate based on the key {id}, the list of authors and the title for {url}. '
5454
f'I will ignore this entry. If this is wrong, sorry for that..\n\n')
5555
duplicate = True
@@ -69,7 +69,9 @@
6969
# print(f"removing {item['ID']}")
7070
db.entries.remove(item)
7171

72-
bib = re.sub(r'(@[a-z]*{)(.*),', r'\1' + id + ',', bib)
72+
bType, *rest1 = bib.split("{")
73+
oldID, *rest2 = rest1[0].split(",")
74+
bib = "{".join([bType] + [','.join([id]+rest2)] + rest1[1:])
7375
bib_db = bibtexparser.loads(bib)
7476
db.entries.extend(bib_db.get_entry_list())
7577
else:

0 commit comments

Comments
 (0)