-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.py
124 lines (108 loc) · 3.94 KB
/
header.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import datetime
from string import Template
header_template = """% File generated by "$script"
% DO NOT MODIFY MANUALLY
%------------------------------------------------------------------
% Authors:
% Michel Abdalla
% Fabrice Benhamouda
%
% Date:
% $timestamp
%
%------------------------------------------------------------------
$conf_years_complete
%------------------------------------------------------------------
% Required files:
%
% 1) one of the following files:
% crypto.bib
% crypto_crossref.bib
% crypto_custom.bib
% 2) one of the following files:
% abbrev0.bib
% abbrev1.bib
% abbrev2.bib
% abbrev3.bib
%
%------------------------------------------------------------------
%------------------------------------------------------------------
% Labeling convention:
%
% Conference/Journal/Archive label + `:' +
% Author label +
% 2 last digits of publication year
%
% In case of collisions, add a different letter
% at the end of each label starting with `a'
%
%------------------------------------------------------------------
%------------------------------------------------------------------
% Conference labels:
%
${conf_labels}%
%------------------------------------------------------------------
%------------------------------------------------------------------
% Journal labels
%
% Journal of Crypto: JC
%
%------------------------------------------------------------------
%------------------------------------------------------------------
% Archive labels
%
% ePrint: EPRINT
%
%------------------------------------------------------------------
%------------------------------------------------------------------
% Author labels:
%
% - Single-author papers ==> Author's last name
% Example:
% author = "Adi Shamir" ==> Shamir
%
% - Papers with two or three authors ==> First 3 letters of each author's last name
% Examples:
% author = "Mihir Bellare and Phillip Rogaway" ==> BelRog
% author = "Michel Abdalla and Sara Miner and Chanathip Namprempre" ==> AbdMinNam
%
% - Papers with four or more authors ==> First letter of each author's last name (up to 6)
% Examples:
% author = "Kamel Bentahar and Pooya Farshim and John Malone-Lee and Nigel P. Smart" ==> BFMS
% author = "Don Coppersmith and Jean-Sebastien Coron and
% Fran\c{c}ois Grieu and Shai Halevi and
% Charanjit S. Jutla and David Naccache and
% Julien P. Stern" ==> CCGHJN
%
%------------------------------------------------------------------
"""
def get_header(config, script, conf_years=None):
timestamp = datetime.date.today().isoformat()
if conf_years is not None:
conf_years_complete = """%------------------------------------------------------------------
% List of complete conferences:
%""".split("\n")
for conf in sorted(iter(conf_years.keys()), key=lambda x: config.get_conf_name(x)):
(start, end) = conf_years[conf]
name = config.get_conf_name(conf)
conf_years_complete.append("% {}:{}{} - {}".format(name, " " * (16 - len(conf) - 1), start, end))
conf_years_complete = "\n".join(conf_years_complete)
conf_years_complete += """\n%
%------------------------------------------------------------------
"""
else:
conf_years_complete = ""
conf_labels = []
for conf_key in sorted(
iter(config.confs.keys()),
key=lambda x: config.get_conf_name(x)
):
conf_name = config.get_conf_name(conf_key)
conf_labels.append("% {}:{}{}\n".format(conf_name, " " * (16 - len(conf_name) - 1), conf_key))
conf_labels = ''.join(conf_labels)
return Template(header_template).substitute(
script=script,
timestamp=timestamp,
conf_years_complete=conf_years_complete,
conf_labels=conf_labels
)