FIX bib_oneliner not robust to missing year.

main
Olivier Mangin 11 years ago
parent ad29b27412
commit 3e8b780e84

@ -11,6 +11,7 @@ def person_repr(p):
' '.join(p.last(abbr=False)), ' '.join(p.last(abbr=False)),
' '.join(p.lineage(abbr=True))] if s) ' '.join(p.lineage(abbr=True))] if s)
def short_authors(bibentry): def short_authors(bibentry):
try: try:
authors = [p for p in bibentry['author']] authors = [p for p in bibentry['author']]
@ -24,17 +25,17 @@ def short_authors(bibentry):
def bib_oneliner(bibentry): def bib_oneliner(bibentry):
authors = short_authors(bibentry) authors = short_authors(bibentry)
journal, journal_field = '', 'journal' journal = ''
if 'journal' in bibentry: if 'journal' in bibentry:
journal = bibentry['journal']['name'] journal = bibentry['journal']['name']
elif bibentry['type'] == 'inproceedings': elif bibentry['type'] == 'inproceedings':
journal = bibentry.get('booktitle', '') journal = bibentry.get('booktitle', '')
return u'{authors} \"{title}\" {journal} ({year})'.format( return u'{authors} \"{title}\" {journal} {year}'.format(
authors=color.dye(authors, color.cyan), authors=color.dye(authors, color.cyan),
title=bibentry['title'], title=bibentry['title'],
journal=color.dye(journal, color.yellow), journal=color.dye(journal, color.yellow),
year=bibentry['year'], year='({})'.format(bibentry['year']) if 'year' in bibentry else '',
) )

Loading…
Cancel
Save