updated oneliner and colors

main
Fabien Benureau 10 years ago
parent 9fe568805c
commit 3989a13359

@ -19,8 +19,8 @@ ok = green
error = red error = red
normal = grey normal = grey
citekey = purple citekey = purple
filepath = cyan filepath = bold
tag = blue tag = cyan
def dye(s, color=end, bold=False): def dye(s, color=end, bold=False):
assert color[0] == '\033' assert color[0] == '\033'

@ -16,7 +16,7 @@ def short_authors(bibentry):
try: try:
authors = [p for p in bibentry['author']] authors = [p for p in bibentry['author']]
if len(authors) < 3: if len(authors) < 3:
return ', '.join(authors) return ' and '.join(authors)
else: else:
return authors[0] + (' et al.' if len(authors) > 1 else '') return authors[0] + (' et al.' if len(authors) > 1 else '')
except KeyError: # When no author is defined except KeyError: # When no author is defined
@ -31,7 +31,7 @@ def bib_oneliner(bibentry):
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}z \"{title}\"{journal}{year}'.format(
authors=color.dye(authors, color.grey, bold=True), authors=color.dye(authors, color.grey, bold=True),
title=bibentry['title'], title=bibentry['title'],
journal=color.dye(journal, color.yellow), journal=color.dye(journal, color.yellow),
@ -53,9 +53,8 @@ def paper_oneliner(p, citekey_only = False):
return p.citekey return p.citekey
else: else:
bibdesc = bib_oneliner(p.bibentry) bibdesc = bib_oneliner(p.bibentry)
tags = '' if len(p.tags) == 0 else '| {}'.format(
','.join(color.dye(t, color.tag) for t in sorted(p.tags)))
return u'[{citekey}] {descr} {tags}'.format( return u'[{citekey}] {descr} {tags}'.format(
citekey=color.dye(p.citekey, color.purple), citekey=color.dye(p.citekey, color.purple),
descr=bibdesc, descr=bibdesc, tags=tags)
tags=color.dye(' '.join(sorted(p.tags)),
color.tag, bold=False),
)

Loading…
Cancel
Save