Public Member Functions | |
def | __init__ |
def | createFile |
def | dumpPython |
def | extract |
def | parse |
def | pythonFileName |
def | pythonFileRoot |
def | pythonModuleName |
Public Attributes | |
filename |
For injection purposes, pretend this is a new parameter type then have a post process step which strips these out
Definition at line 449 of file parseConfig.py.
def parseConfig::_IncludeNode::__init__ | ( | self, | ||
filename | ||||
) |
def parseConfig::_IncludeNode::createFile | ( | self, | ||
overwrite | ||||
) |
Definition at line 512 of file parseConfig.py.
00512 : 00513 import os 00514 import os.path 00515 pythonName = self.pythonFileName() 00516 cmsswSrc = os.path.expandvars("$CMSSW_BASE/src/") 00517 cmsswReleaseSrc = os.path.expandvars("$CMSSW_RELEASE_BASE/src/") 00518 if overwrite or (not os.path.exists(cmsswSrc+pythonName) and \ 00519 not os.path.exists(cmsswReleaseSrc+pythonName)): 00520 # need to check out my own version 00521 cwd = os.getcwd() 00522 os.chdir(cmsswSrc) 00523 pythonDir = os.path.dirname(pythonName) 00524 #os.system("cvs co "+pythonDir) 00525 if overwrite and os.path.exists(pythonName): 00526 os.remove(pythonName) 00527 if not os.path.exists(pythonName): 00528 # have to make it myself 00529 if not os.path.exists(pythonDir): 00530 #print "Making " + pythonDir 00531 os.makedirs(pythonDir) 00532 #os.system("scramv1 build") 00533 f=open(pythonName, 'w') 00534 f.write(dumpCff(self.filename)) 00535 f.close() 00536 os.chdir(pythonDir) 00537 os.chdir(cwd) 00538 00539 class _IncludeFromNode(_IncludeNode):
def parseConfig::_IncludeNode::dumpPython | ( | self, | ||
options | ||||
) |
Definition at line 506 of file parseConfig.py.
00506 : 00507 if options.isCfg: 00508 #return "import "+self.pythonModuleName()+"\nprocess.extend("+self.pythonModuleName()+")\n" 00509 return "process.load(\"" + self.pythonModuleName() + "\")\n" 00510 else: 00511 return "from "+self.pythonModuleName()+" import *" def createFile(self, overwrite):
def parseConfig::_IncludeNode::extract | ( | self, | ||
label, | ||||
otherFiles, | ||||
recurseFiles, | ||||
parser, | ||||
validator, | ||||
recursor | ||||
) |
reads in the file with name 'fileName' making sure it does not recursively include itself by looking in 'otherFiles' then applies the 'parser' to the contents of the file, runs the validator and then applies the recursor to see if other files must now be included
Reimplemented in parseConfig::_IncludeFromNode.
Definition at line 476 of file parseConfig.py.
00476 : 00477 """reads in the file with name 'fileName' making sure it does not recursively include itself 00478 by looking in 'otherFiles' then applies the 'parser' to the contents of the file, 00479 runs the validator and then applies the recursor to see if other files must now be included""" 00480 fileName = self.filename 00481 if fileName in recurseFiles: 00482 raise RuntimeError('the file '+fileName+' eventually includes itself') 00483 if fileName in otherFiles: 00484 return list() 00485 newRecurseFiles = recurseFiles.copy() 00486 newRecurseFiles.add(fileName) 00487 otherFiles.add(fileName) 00488 values = self.parse(parser, validator) 00489 values =recursor(values,otherFiles,newRecurseFiles) 00490 try: 00491 values = validator(values) 00492 except pp.ParseException, e: 00493 raise RuntimeError('after including all other files,include file '+fileName+' had the parsing error \n'+str(e)) 00494 except Exception, e: 00495 raise RuntimeError('after including all other files, include file '+fileName+' had the error \n'+str(e)) 00496 return values 00497 def pythonFileRoot(self):
def parseConfig::_IncludeNode::parse | ( | self, | ||
parser, | ||||
validator | ||||
) |
Only the top-level nodes. No recursion
Definition at line 455 of file parseConfig.py.
00455 : 00456 """Only the top-level nodes. No recursion""" 00457 global _fileStack 00458 _fileStack.append(self.filename) 00459 try: 00460 #factory = _fileFactory 00461 #f = factory(fileName) 00462 f = _fileFactory(self.filename) 00463 try: 00464 values = parser(f) 00465 values = validator(values) 00466 except pp.ParseException, e: 00467 raise RuntimeError('include file '+self.filename+' had the parsing error \n'+str(e)) 00468 except Exception, e: 00469 raise RuntimeError('include file '+self.filename+' had the error \n'+str(e)) 00470 return values 00471 finally: 00472 _fileStack.pop() 00473 00474 00475 def extract(self, label, otherFiles,recurseFiles,parser,validator,recursor):
def parseConfig::_IncludeNode::pythonFileName | ( | self | ) |
Definition at line 501 of file parseConfig.py.
00501 : 00502 return self.pythonFileRoot().replace('/data/','/python/').replace('/test/','/python/test/')+".py" def pythonModuleName(self):
def parseConfig::_IncludeNode::pythonFileRoot | ( | self | ) |
Definition at line 498 of file parseConfig.py.
00498 : 00499 # translate, e.g., "SimMuon/DT/data/my-mod.cfi" to "SimMuon/DT/data/my_mod_cfi" 00500 return self.filename.replace('.','_').replace('-','_') def pythonFileName(self):
def parseConfig::_IncludeNode::pythonModuleName | ( | self | ) |
Definition at line 503 of file parseConfig.py.
00503 : 00504 # we want something like "SimMuon.DT.mod_cfi" 00505 return self.pythonFileRoot().replace('/','.').replace('.data.','.') def dumpPython(self, options):
Definition at line 454 of file parseConfig.py.