forked from hhexiy/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_cv_pubs.py
62 lines (57 loc) · 2.51 KB
/
generate_cv_pubs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
from pub_data import *
from people import *
from venue import *
venue_format = '\\textit{{{name} ({abr})}}, {year}'
def gen_title(pub):
return '{}'.format(pub['title'])
def gen_author(pub):
s = []
for author in pub['author']:
symbol = ''
if author in pub.get('equal', []):
symbol = '*'
name, _ = people.get(author, (author, None))
if author == 'me':
name = '\\textbf{{{name}}}'.format(name=name)
name = name.replace('é', "\\'e")
if symbol:
name = '{}$^{}$'.format(name, symbol)
s.append(name)
return '{} and {}'.format(', '.join(s[:-1]), s[-1])
def gen_venue(pub):
name, abr = venue.get(pub['venue'], (pub['venue'], pub['venue']))
if pub['type'] == 'arxiv':
return '\\textit{{{name}:{index} preprint}}, {year}'.format(name=name, index=pub['index'], year=pub['year'])
elif pub['type'] == 'workshop':
name, link = venue.get(pub['ws'], (pub['ws'], ''))
return '\\textit{{{venue} Workshop on {name}}}, {year}'.format(venue=abr, name=name, year=pub['year'])
elif pub['type'] == 'demo':
return '\\textit{{{name} ({abr}) demo, {year}}}'.format(name=name, abr=abr, year=pub['year'])
elif pub['type'] == 'journal':
return '\\textit{{{name} ({abr}) {vol}:{page}, {year}}}'.format(name=name, abr=abr, year=pub['year'], vol=pub['vol'], page=pub['page'])
elif abr:
return venue_format.format(name=name, abr=abr, year=pub['year'])
else:
return '\\textit{{{name}}}, {year}'.format(name=name, year=pub['year'])
pubs = sorted(pubs, key=lambda p: p['year'], reverse=True)
with open('conference.tex', 'w') as fconf, open('workshop.tex', 'w') as fwork, open('arxiv.tex', 'w') as farxiv, open('journal.tex', 'w') as fjournal:
fouts = {
'conference': fconf,
'workshop': fwork,
'arxiv': farxiv,
'journal': fjournal,
}
for i, pub in enumerate(pubs):
if pub['type'] in fouts:
if 'notes' in pub:
format_str = '{author}. {title}. {venue}. ({notes})\n\n'
else:
format_str = '{author}. {title}. {venue}.\n\n'
pub_str = format_str.format(
title=gen_title(pub),
author=gen_author(pub),
venue=gen_venue(pub),
notes=pub.get('notes'))
pub_str = pub_str.replace('&', '\\&')
fouts[pub['type']].write(pub_str)