File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments