CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
crabConfigParser.CrabConfigParser Class Reference

The CrabConfigParser class. More...

Inheritance diagram for crabConfigParser.CrabConfigParser:

Public Member Functions

def __init__ (self)
 The constructor. More...
 
def getSectionLines (self, section)
 Helper function to retrieve crab config output lines for one section self: CrabConfigParser. More...
 
def writeCrabConfig (self, filename)
 Write CrabConfigParser object to file self: CrabConfigParser. More...
 

Public Attributes

 optionxform
 

Detailed Description

The CrabConfigParser class.

This class extends the python ConfigParser class and adds functions to output crab3 config files

Definition at line 13 of file crabConfigParser.py.

Constructor & Destructor Documentation

def crabConfigParser.CrabConfigParser.__init__ (   self)

The constructor.

Definition at line 16 of file crabConfigParser.py.

16  def __init__(self):
17  ConfigParser.__init__(self)
18  self.optionxform = str
def __init__(self)
The constructor.

Member Function Documentation

def crabConfigParser.CrabConfigParser.getSectionLines (   self,
  section 
)

Helper function to retrieve crab config output lines for one section self: CrabConfigParser.

Parameters
self:Theobject pointer. section: string
section:Thesection name. : list of strings
Returns
: Lines for one section in crab3 config file

Definition at line 49 of file crabConfigParser.py.

References objects.autophobj.float, createfilelist.int, PixelDCSObject< T >.items, DictTypes.SortedKeysDict.items(), EcalContainer< EcalTrigTowerDetId, Item >.items(), EcalContainer< EBDetId, EcalMappingElement >.items(), EcalContainer< DetId, T >.items(), EcalContainer< EcalScDetId, EcalChannelStatusCode >.items(), EcalContainer< EBDetId, EcalDQMStatusCode >.items(), EcalContainer< EBDetId, EcalPulseSymmCovariance >.items(), EcalContainer< EEDetId, EcalDQMStatusCode >.items(), EcalContainer< EBDetId, EcalPulseShape >.items(), EcalContainer< EEDetId, EcalMGPAGainRatio >.items(), EcalContainer< EBDetId, EcalTimeDependentCorrections::Values >.items(), EcalContainer< EEDetId, EcalLaserAPDPNRatios::EcalLaserAPDPNpair >.items(), EcalContainer< EEDetId, EcalMappingElement >.items(), EcalContainer< EBDetId, EcalXtalGroupId >.items(), EcalContainer< EEDetId, EcalTimeDependentCorrections::Values >.items(), EcalContainer< EBDetId, EcalTPGCrystalStatusCode >.items(), EcalContainer< EEDetId, EcalChannelStatusCode >.items(), EcalContainer< EcalTrigTowerDetId, EcalDQMStatusCode >.items(), EcalContainer< EBDetId, float >.items(), EcalContainer< EcalScDetId, EcalDQMStatusCode >.items(), EcalContainer< EBDetId, EcalChannelStatusCode >.items(), EcalContainer< ESDetId, Item >.items(), EcalContainer< EcalScDetId, Item >.items(), EcalContainer< EEDetId, EcalPulseCovariance >.items(), EcalContainer< EBDetId, EcalMGPAGainRatio >.items(), EcalContainer< EEDetId, EcalPedestal >.items(), EcalContainer< EEDetId, float >.items(), EcalContainer< EcalTrigTowerDetId, EcalDAQStatusCode >.items(), EcalContainer< EEDetId, EcalXtalGroupId >.items(), EcalContainer< EBDetId, EcalTPGPedestal >.items(), EcalContainer< EcalScDetId, EcalDAQStatusCode >.items(), EcalContainer< EBDetId, Item >.items(), EcalContainer< EBDetId, EcalPedestal >.items(), EcalContainer< EEDetId, EcalTPGCrystalStatusCode >.items(), EcalContainer< EBDetId, EcalTPGLinearizationConstant >.items(), EcalContainer< EcalTrigTowerDetId, EcalChannelStatusCode >.items(), EcalContainer< EEDetId, EcalTPGPedestal >.items(), EcalContainer< EBDetId, EcalLaserAPDPNRatios::EcalLaserAPDPNpair >.items(), EcalContainer< EBDetId, EcalPulseCovariance >.items(), EcalContainer< EEDetId, EcalPulseSymmCovariance >.items(), EcalContainer< EEDetId, EcalTPGLinearizationConstant >.items(), EcalContainer< EEDetId, EcalPulseShape >.items(), EcalContainer< EEDetId, Item >.items(), betterConfigParser.AdaptedDict.items(), AlignmentSurfaceDeformations.items(), edm::ErrorObj.items(), FWTableViewManager.items(), tensorflow::NTSession::ExecutorsAndKeys.items, tensorflow::TBBSession::ExecutorsAndKeys.items, betterConfigParser.BetterConfigParser.items(), argparse.HelpFormatter._Section.items, python.rootplot.argparse.HelpFormatter._Section.items, svgfig.SVG.items(), and harvestTrackValidationPlots.str.

Referenced by crabConfigParser.CrabConfigParser.writeCrabConfig().

49  def getSectionLines(self,section):
50  sectionLines = []
51  sectionLines.append('\nconfig.section_("%s")'%section)
52  configItems = self.items(section)
53  for configItem in configItems:
54  if not isinstance(configItem[1], basestring):
55  sectionLines.append('config.%s.%s = %s'%(section,configItem[0],configItem[1]))
56  elif "True" in configItem[1] or "False" in configItem[1]:
57  sectionLines.append('config.%s.%s = %s'%(section,configItem[0],configItem[1]))
58  else:
59  parsed = False
60  if configItem[0]=="runRange" :
61  sectionLines.append('config.%s.%s = \'%s\''%(section,configItem[0],configItem[1]))
62  parsed = True
63  if not parsed:
64  try:
65  sectionLines.append('config.%s.%s = %d'%(section,configItem[0],int(configItem[1])))
66  parsed = True
67  except:
68  pass
69  if not parsed:
70  try:
71  sectionLines.append('config.%s.%s = %.2f'%(section,configItem[0],float(configItem[1])))
72  parsed = True
73  except:
74  pass
75  if not parsed:
76  if type(configItem[1]) == list:
77  sectionLines.append('config.%s.%s = %s'%(section,configItem[0],str(configItem[1])))
78  parsed = True
79  if not parsed:
80  sectionLines.append('config.%s.%s = \'%s\''%(section,configItem[0],configItem[1]))
81 
82  return sectionLines
83 
def getSectionLines(self, section)
Helper function to retrieve crab config output lines for one section self: CrabConfigParser.
def crabConfigParser.CrabConfigParser.writeCrabConfig (   self,
  filename 
)

Write CrabConfigParser object to file self: CrabConfigParser.

Parameters
selfThe object pointer. filename: string
filenameThe name of the output crab3 config file.

Definition at line 24 of file crabConfigParser.py.

References crabConfigParser.CrabConfigParser.getSectionLines(), join(), and DDCutTubsFromPoints.sections.

24  def writeCrabConfig(self,filename):
25  sections = self.sections()
26  fixedsections = ['General','JobType','Data','Site','User','Debug']
27  outlines = []
28  # Add inital header for crab config file
29  outlines.append('from WMCore.Configuration import Configuration \n')
30  outlines.append('config = Configuration()')
31  # we will first add the main crab3 config sections in the given order
32  for fixedsection in fixedsections:
33  if fixedsection in sections:
34  outlines.extend(self.getSectionLines(fixedsection))
35  sections.remove(fixedsection)
36  # add additional sections (may be added in future crab3 versions ?)
37  for section in sections:
38  outlines.extend(self.getSectionLines(section))
39  #print filename
40  with open(filename,'wb') as outfile:
41  outfile.write('\n'.join(outlines) + '\n')
def writeCrabConfig(self, filename)
Write CrabConfigParser object to file self: CrabConfigParser.
def getSectionLines(self, section)
Helper function to retrieve crab config output lines for one section self: CrabConfigParser.
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

crabConfigParser.CrabConfigParser.optionxform

Definition at line 18 of file crabConfigParser.py.