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
|
#!/usr/bin/env python3
import sys
import types
import re
# global options
enableWarnings = False
if '-w' in sys.argv:
sys.argv.remove('-w')
enableWarnings = True
if len(sys.argv) != 2:
print("usage: %s [-w] menu.py" % sys.argv[0])
sys.exit(1)
# whitelist paths exempt from validation
whitelist = [
'HLTriggerFirstPath',
'HLTriggerFinalPath',
'Status_OnCPU',
'Status_OnGPU',
]
# load the menu and get the "process" object
menu = types.ModuleType('menu')
name = sys.argv[1]
exec(open(name).read(), globals(), menu.__dict__)
process = menu.process
# get all paths
paths = process.paths_()
# keep track of prescaler names, and of duplicates
prescalerNames = set()
duplicateNames = set()
# prescaler name generator
generatePrescalerName = re.compile(r'^HLT_|_v\d+$|_')
# loop over all paths and look for duplicate prescaler modules
for path in paths:
if path in whitelist:
continue
goodLabel = 'hltPre' + generatePrescalerName.sub('', path)
found = False
for module in paths[path].moduleNames():
if module in process.filters_(): # found a filter
if process.filters_()[module].type_() == 'HLTPrescaler': # it's a prescaler
if found:
print('ERROR: path %s has more than one HLTPrescaler module' % path)
found = True
label = process.filters_()[module].label()
if enableWarnings and label != goodLabel:
print('WARNING: path %s has an HLTPrescaler module labaled "%s", while the suggested label is "%s"' % (path, label, goodLabel))
if label in prescalerNames:
duplicateNames.add(label)
else:
prescalerNames.add(label)
if not found:
print('ERROR: path %s dos not have an HLTPrescaler module' % path)
# print the duplicate prescales, and the affected paths
for label in duplicateNames:
print('ERROR: prescale "%s" is shared by the paths' % label)
for path in paths:
if label in paths[path].moduleNames():
print('\t%s' % path)
print()
|