forked from alshedivat/al-folio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4890c9
commit 9c61f4f
Showing
3 changed files
with
2,630 additions
and
2,655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import bibtexparser | ||
|
||
|
||
def add_field_if_author_in_entry(bibtex_path, author_name, new_field, new_field_value): | ||
with open(bibtex_path) as bibtex_file: | ||
bib_database = bibtexparser.load(bibtex_file) | ||
|
||
for entry in bib_database.entries: | ||
if 'author' in entry and author_name in entry['author']: | ||
entry[new_field] = new_field_value | ||
|
||
with open(bibtex_path, 'w') as bibtex_file: | ||
bibtexparser.dump(bib_database, bibtex_file) | ||
|
||
|
||
# Usage | ||
add_field_if_author_in_entry( | ||
'papers.bib', 'Nolan', 'abbr', 'NOLAN') |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.