CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 The constructor. More...
 
def getSectionLines
 Helper function to retrieve crab config output lines for one section self: CrabConfigParser. More...
 
def writeCrabConfig
 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 
17  def __init__(self):
18  ConfigParser.__init__(self)
self.optionxform = str

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 PixelDCSObject< class >.items, DictTypes.SortedKeysDict.items(), EcalContainer< ESDetId, Item >.items(), EcalContainer< EBDetId, Item >.items(), EcalContainer< EcalScDetId, Item >.items(), EcalContainer< DetId, T >.items(), EcalContainer< EEDetId, Item >.items(), EcalContainer< EcalTrigTowerDetId, Item >.items(), AlignmentSurfaceDeformations.items(), betterConfigParser.AdaptedDict.items(), edm::ErrorObj.items(), FWTableViewManager.items(), betterConfigParser.BetterConfigParser.items(), svgfig.SVG.items(), and str.

Referenced by crabConfigParser.CrabConfigParser.writeCrabConfig().

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

Write CrabConfigParser object to file self: CrabConfigParser.

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

Member Data Documentation

crabConfigParser.CrabConfigParser.optionxform

Definition at line 18 of file crabConfigParser.py.