-
Notifications
You must be signed in to change notification settings - Fork 22
/
create_hlt_trigger_information_records.py
49 lines (39 loc) · 1.47 KB
/
create_hlt_trigger_information_records.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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Create CMS Trigger Information records.
"""
import glob
import os
TEMPLATE_FFT = """\
<datafield tag="FFT" ind1=" " ind2=" ">
<subfield code="a">/tmp/opendata.cern.ch-fft-file-cache/cms-trigger-information/%(filename)s</subfield>
</datafield>"""
TEMPLATE_TOC = """\
<tr><td>%(runs)s</td><td><a href="https://github.com/cms-sw/cmssw/tree/%(cmssw)s">%(cmssw)s</a></td><td><a href="files/%(filename)s">%(title)s</a></td></tr>"""
def main():
"""Do the main job."""
for line in open('./inputs/trigger-information.txt', 'r').readlines():
cmssw, title, runs = line.split(' ', 2)
runs = runs.strip()
runs = runs.replace('(run ', '')
runs = runs.replace('(runs ', '')
runs = runs.replace(')', '')
filename = title.replace('/', '_')[1:] + '.py'
if os.path.exists('../../opendata.cern.ch/invenio_opendata/testsuite/data/cms/cms-hlt-2011-configuration-files' + os.sep + filename):
if True:
print TEMPLATE_TOC % {
'filename': filename,
'cmssw': cmssw,
'title': title,
'runs': runs,
}
else:
print TEMPLATE_FFT % {
'filename': filename,
'cmssw': cmssw,
'title': title,
'runs': runs,
}
if __name__ == '__main__':
main()