Skip to content

Commit c76d31a

Browse files
committed
deploy: 18eba15
1 parent 77ff64e commit c76d31a

2 files changed

Lines changed: 803 additions & 1371 deletions

File tree

bin/arxiv_to_publications_correct.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,28 @@
3636
id = data['author'][0]['family'] + 'EtAl' + str(data['issued']['date-parts'][0][0])
3737
else:
3838
id = data['author'][0]['family'] + str(data['issued']['date-parts'][0][0])
39-
if id != id_db:
40-
print(f'Note: ID generated with new DOI ({id}) differs from the original in database ({id_db}). Keeping original ID.')
39+
id = id.replace(" ", "_")
4140

4241
entries = db.get_entry_dict()
4342
assert entries[id_db]["ENTRYTYPE"] == 'unpublished', "original entry in bib file was NOT unpublished !"
4443
db.entries.remove(entries[id_db])
4544

45+
# Check for duplicate keys in the remaining database and add letter suffixes if needed
46+
remaining = db.get_entry_dict()
47+
id_orig = id
48+
letters = 'bcdefghijklmnopqrstuvwxyz'
49+
i = 0
50+
while id in remaining:
51+
print(f'Key {id} already exists, augmenting with letter suffix.')
52+
id = id_orig + letters[i]
53+
i += 1
54+
55+
if id != id_db:
56+
print(f'Note: ID updated from {id_db} to {id} to reflect the publication year.')
57+
4658
bType, *rest1 = bib.split("{")
4759
oldID, *rest2 = rest1[0].split(",")
48-
bib = "{".join([bType] + [','.join([id_db]+rest2)] + rest1[1:])
60+
bib = "{".join([bType] + [','.join([id]+rest2)] + rest1[1:])
4961
bib_db = bibtexparser.loads(bib)
5062
db.entries.extend(bib_db.get_entry_list())
5163

0 commit comments

Comments
 (0)