forked from UCATLAS/xAODAnaHelpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config
78 lines (68 loc) · 3.82 KB
/
config
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
#!/usr/bin/env python
################################################################################
# #
# Author: Giordon Stark #
# Date: 02-02-2015 #
# #
# #
# A config file which defines the template options available. This is #
# imported into xAH_scaffold.py to handle actual functionality. #
# #
# #
################################################################################
# key = type of code to scaffold
# value = list of files included in scaffolder
# type: pair, requires a source and header file to be placed in MyPackage/MyPackage/ and MyPackage/Root/
# type: util, requires a source file to be placed in MyPackage/util
# header/source: filename under templates/*
# append: generically, it's what is after 'Object' in the filename, excluding the extension, such as HistsAlgo
# -- also used internally to determine classes to pragma link in LinkDef, hence name classes the same as your filename
templates = {'plot': [
{'type': 'pair', 'header': 'ObjectHistsAlgo.h', 'source': 'ObjectHistsAlgo.cxx', 'append': 'HistsAlgo', 'linkdef': True},
{'type': 'pair', 'header': 'ObjectHists.h', 'source': 'ObjectHists.cxx', 'append': 'Hists'},
{'type': 'util', 'source': 'ObjectPlotExample.cxx', 'append': 'PlotExample'}
]
}
if __name__ == "__main__":
# running for testing purposes
from os import path
from sys import exit
try:
templates
except NameError:
print "Missing template configuration variable `templates`. This is problematic."
exit(1)
try:
missingFiles = 0
print "Inspecting defined scaffold patterns and files..."
for scaffold_type, files_to_scaffold in templates.iteritems():
print "{0}".format(scaffold_type)
for file_to_scaffold in files_to_scaffold:
if file_to_scaffold['type'] == 'pair':
# check for existing files
headerExist = sourceExist = False
headerExist = path.isfile(path.join('templates', file_to_scaffold['header']))
sourceExist = path.isfile(path.join('templates', file_to_scaffold['source']))
missingFiles += not(headerExist|sourceExist)
print "\tAppend: {0}".format(file_to_scaffold['append'])
print "\tHeader: {0}".format(file_to_scaffold['header'])
if not headerExist: print "\t\tDoes Not Exist!"
print "\tSource: {0}".format(file_to_scaffold['source'])
if not sourceExist: print "\t\tDoes Not Exist!"
print "\t","-"*10
elif file_to_scaffold['type'] == 'util':
# check for existing files
sourceExist = False
sourceExist = path.isfile(path.join('templates', file_to_scaffold['source']))
missingFiles += not(sourceExist)
print "\tAppend: {0}".format(file_to_scaffold['append'])
print "\tSource: {0}".format(file_to_scaffold['source'])
if not sourceExist: print "\t\tDoes Not Exist!"
print "\t","-"*10
except KeyError:
print "You are missing a key in one of the files. Please see the traceback below for more information."
raise
if missingFiles > 0:
print "Warning! One or more files do not exist but you have defined them in the templates. Please fix this before doing anything else."
exit(1)
print "If you're seeing this, things should be ok."