CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
normFileParser.normFileParser Class Reference

norm file format spec lines beginning with a semicolon ';' a pound sign '#' or the letters 'REM' (uppercase or lowercase) will be ignored. More...

Inheritance diagram for normFileParser.normFileParser:

Public Member Functions

def __init__ (self, filename)
 
def parse (self)
 

Private Attributes

 __datasectionname
 
 __defsectionname
 
 __inifilename
 
 __parser
 

Detailed Description

norm file format spec lines beginning with a semicolon ';' a pound sign '#' or the letters 'REM' (uppercase or lowercase) will be ignored.

section uppercase [NORMDEFINITION] #section required only if first create name=HFtest #priority to commandline –name option if present comment= lumitype= istypedefault= [NORMDATA Since] # section required since= corrector= norm_occ1= norm_occ2= amodetag= egev= comment= ...

Definition at line 24 of file normFileParser.py.

Constructor & Destructor Documentation

def normFileParser.normFileParser.__init__ (   self,
  filename 
)

Definition at line 25 of file normFileParser.py.

25  def __init__(self,filename):
26  self.__parser=ConfigParser.ConfigParser()
27  self.__inifilename=filename
28  self.__defsectionname='NormDefinition'
29  self.__datasectionname='NormData'
def __init__(self, filename)

Member Function Documentation

def normFileParser.normFileParser.parse (   self)
output:
   [ {defoption:value},[{dataoption:value}] ]

Definition at line 30 of file normFileParser.py.

References normFileParser.normFileParser.__datasectionname, normFileParser.normFileParser.__defsectionname, and normFileParser.normFileParser.__inifilename.

30  def parse(self):
31  '''
32  output:
33  [ {defoption:value},[{dataoption:value}] ]
34  '''
35  if not os.path.exists(self.__inifilename) or not os.path.isfile(self.__inifilename):
36  raise ValueError(self.__inifilename+' is not a file or does not exist')
37  self.__parser.read(self.__inifilename)
38  result=[]
39  defsectionResult={}
40  datasectionResult=[]
41  sections=self.__parser.sections()
42  for section in sections:
43  thisectionresult={}
44  options=self.__parser.options(section)
45  for o in options:
46  try:
47  thisectionresult[o]=self.__parser.get(section,o)
48  except:
49  continue
50  if section==self.__defsectionname:
51  defsectionResult=thisectionresult
52  elif self.__datasectionname in section:
53  datasectionResult.append(thisectionresult)
54  return [defsectionResult,datasectionResult]

Member Data Documentation

normFileParser.normFileParser.__datasectionname
private

Definition at line 29 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__defsectionname
private

Definition at line 28 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__inifilename
private

Definition at line 27 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__parser
private

Definition at line 26 of file normFileParser.py.