test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def parse
 

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 
25  def __init__(self,filename):
26  self.__parser=ConfigParser.ConfigParser()
27  self.__inifilename=filename
28  self.__defsectionname='NormDefinition'
self.__datasectionname='NormData'

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 
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)
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.