CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
generateWrappers Namespace Reference

Functions

def declareCondWrappers
 
def declareXMLCondWrappers
 
def generateBuildFile
 
def generateClassesHeader
 
def generateDict
 
def generateWrapper
 
def getClasses
 
def guessClasses
 
def guessPackage
 
def walkPlugins
 

Variables

string wrapperDeclarationFooter
 
string wrapperDeclarationHeader
 

Function Documentation

def generateWrappers.declareCondWrappers (   package)

Definition at line 72 of file generateWrappers.py.

References mergeVDriftHistosByStation.file, and getClasses().

Referenced by generateDict().

72 
73 def declareCondWrappers(package):
74  _newch = file('../../CondFormats/'+package+'/src/classes_new.h','w')
75  for line in file('../../CondFormats/'+package+'/src/classes.h'):
76  if (line.find('wrapper declarations')>0) : break
77  _newch.write(line)
78  _newch.write(wrapperDeclarationHeader)
79  _n=0
80  for cl in getClasses(package):
81  _newch.write(' pool::Ptr<'+cl+' > p'+str(_n)+';\n')
82  _newch.write(' cond::DataWrapper<'+cl+' > dw'+str(_n)+';\n')
83  _n=_n+1
84  _newch.write(wrapperDeclarationFooter)
85  _newch.close()
def generateWrappers.declareXMLCondWrappers (   package)

Definition at line 86 of file generateWrappers.py.

References mergeVDriftHistosByStation.file, and getClasses().

Referenced by generateDict().

86 
87 def declareXMLCondWrappers(package):
88  _wrapperComment = '<-- wrapper declarations -->\n'
89  _newxml = file('../../CondFormats/'+package+'/src/classes_def_new.xml','w')
90  for line in file('../../CondFormats/'+package+'/src/classes_def.xml'):
91  if (line.find('wrapper declarations')>0) : break
92  _newch.write(line)
93  _newch.write_(wrapperComment)
94  for cl in getClasses(package):
95  _newch.write(' <class name="pool::Ptr<'+cl+' >"/>\n')
96  _newch.write(' <class name="cond::DataWrapper<'+cl+' >"/>\n')
97  _newch.close()
98 
99 
100 
def generateWrappers.generateBuildFile (   package,
  classes 
)

Definition at line 101 of file generateWrappers.py.

References mergeVDriftHistosByStation.file, and python.rootplot.root2matplotlib.replace().

102 def generateBuildFile(package,classes) :
103  f = file('plugins/BuildFile','w')
104  f.seek(0,2)
105  s = string.Template(buildfileTemplate)
106  for classname in classes:
107  f.write(s.substitute(_PACKAGE_=package, _CLASS_NAME_=classname).replace('-',''))
def generateWrappers.generateClassesHeader (   package)

Definition at line 33 of file generateWrappers.py.

References mergeVDriftHistosByStation.file, and guessClasses().

33 
34 def generateClassesHeader(package):
35  _header = '/* Condition Objects'
36  _footer = '\n */\n\n#include "CondFormats/Common/interface/PayloadWrapper.h"\n\n'
37  _leader = '\n * '
38 
39  _classes = guessClasses()
40 
41  _newch = file('../../CondFormats/'+package+'/src/classes_new.h','w')
42  _newch.write(_header)
43  for cl in _classes :
44  _newch.write(_leader+cl)
45  _newch.write(_footer)
46  for line in file('../../CondFormats/'+package+'/src/classes.h'):
47  _newch.write(line)
48  _newch.close()
def generateWrappers.generateDict (   package)

Definition at line 117 of file generateWrappers.py.

References declareCondWrappers(), and declareXMLCondWrappers().

118 def generateDict(package):
119  os.system('cd ../../;cvs co CondFormats/'+package)
120  declareCondWrappers(package)
121  declareXMLCondWrappers(package)
122 
def generateWrappers.generateWrapper (   package,
  classes 
)

Definition at line 108 of file generateWrappers.py.

References mergeVDriftHistosByStation.file.

109 def generateWrapper(package,classes) :
110  s = string.Template(wrapperTemplate)
111  for classname in classes:
112  f = file('plugins/'+classname+'PyWrapper.cc','w')
113  print "generating file:", f.name
114  f.write(s.substitute(_PACKAGE_=package, _CLASS_NAME_=classname, _HEADER_FILE_=classname))
115  f.close()
116 
def generateWrappers.getClasses (   package)

Definition at line 49 of file generateWrappers.py.

References mergeVDriftHistosByStation.file, and spr.find().

Referenced by declareCondWrappers(), and declareXMLCondWrappers().

49 
50 def getClasses(package) :
51  _header = 'Condition Objects'
52  _ret = []
53  _ch = file('../../CondFormats/'+package+'/src/classes.h')
54  if (_ch.readline().find(_header)<0) :
55  print 'comment header not found in '+package
56  return _ret
57  for line in _ch:
58  if (line.find('*/')>0) : break
59  _ret.append(line[3:].rstrip())
60  _ch.close()
61  return _ret
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def generateWrappers.guessClasses ( )

Definition at line 25 of file generateWrappers.py.

References mergeVDriftHistosByStation.file.

Referenced by generateClassesHeader().

25 
26 def guessClasses() :
27  _ret = []
28  lines = ( line for line in file('src/plugin.cc') if line[0:3]=='REG')
29  for line in lines:
30  _ret.append(line[line.find(',')+1:line.find(')')])
31  return _ret
32 
# generate the comment in classes.h
def generateWrappers.guessPackage ( )

Definition at line 17 of file generateWrappers.py.

References mergeVDriftHistosByStation.file.

17 
18 def guessPackage() :
19  lines = ( line for line in file('src/plugin.cc')
20  if (line.find('CondFormats')>0 and line.find('DataRecord')<0)
21  )
22  _f = lines.next()
23  _f = _f[_f.find('CondFormats/')+len('CondFormats/'):]
24  return _f[:_f.find('/')]
def generateWrappers.walkPlugins (   a)

Definition at line 7 of file generateWrappers.py.

References reco.if().

7 
8 def walkPlugins(a):
9  for dir in os.listdir('.'):
10  if(dir.find('Plugins')<0) : continue
11  os.chdir(dir)
12  a.act()
13  os.chdir('../')
14 
15 
16 # All those below run in CondCore/XyzPlugin directory
if(dp >Float(M_PI)) dp-

Variable Documentation

string generateWrappers.wrapperDeclarationFooter
Initial value:
1 = """
2  };
3 }
4 """

Definition at line 67 of file generateWrappers.py.

string generateWrappers.wrapperDeclarationHeader
Initial value:
1 = """
2 // wrapper declarations
3 namespace {
4  struct wrappers {
5 """

Definition at line 62 of file generateWrappers.py.