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 23 of file normFileParser.py.

Constructor & Destructor Documentation

def normFileParser.normFileParser.__init__ (   self,
  filename 
)

Definition at line 24 of file normFileParser.py.

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

Member Function Documentation

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

Definition at line 29 of file normFileParser.py.

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

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

Member Data Documentation

normFileParser.normFileParser.__datasectionname
private

Definition at line 28 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__defsectionname
private

Definition at line 27 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__inifilename
private

Definition at line 26 of file normFileParser.py.

Referenced by normFileParser.normFileParser.parse().

normFileParser.normFileParser.__parser
private

Definition at line 25 of file normFileParser.py.