CMS 3D CMS Logo

Classes | Public Member Functions | Public Attributes

python::readProv::filereader Class Reference

List of all members.

Classes

class  Module

Public Member Functions

def __init__
def readfile
def startswith

Public Attributes

 aList

Detailed Description

Definition at line 4 of file readProv.py.


Constructor & Destructor Documentation

def python::readProv::filereader::__init__ (   self)

Definition at line 11 of file readProv.py.

00012                       :
00013         self.aList=['Module', 'ESSource']
        

Member Function Documentation

def python::readProv::filereader::readfile (   self,
  nomefile 
)

Definition at line 21 of file readProv.py.

00022                                :
00023         "Reads the file line by line and searches for the begin and the end of each Module block"       
00024         aFile = open(nomefile)
00025         module=[]
00026         value=[]
00027         file_modules = {}
00028         processHistory=False
00029         processing=False
00030         insideModuleBlock = False
00031         insideParameterBlock = False
00032         nprocess=-1
00033         key=''
00034         for line in aFile.readlines():
00035             if line.startswith("Processing History:"):
00036                 value=[]
00037                 processHistory=True
00038             elif (not line.startswith('---------Event')) and processHistory:
00039                 splitLine= line.split()
00040                 if splitLine[3]=='[2]':
00041                     processing=True
00042                     value.append(line)
00043                 elif  processing:
00044                     value.append(line)
00045             elif line.startswith('---------Event') and processing:
00046                 file_modules['Processing']=value
00047                 processHistory=False
00048                 processing=False
00049             elif self.startswith(line):
00050                 if  insideParameterBlock:
00051                     module.append(tuple(value))
00052                     file_modules[key].append(module)
00053                     insideParameterBlock = False
00054                     insideModuleBlock = False  ###controllare
00055                 value=[]
00056                 module=[]
00057                 splitLine= line.split()
00058                 key=splitLine[-1]
00059                 if key not in file_modules.keys():
00060                     file_modules[key]=[]
00061                 module.append(splitLine[-2])
00062                 value.append(line[:-1])
00063                 insideModuleBlock = True
00064                 insideParameterBlock = False
00065             elif (line.startswith(' parameters')) and insideModuleBlock:
00066                 insideParameterBlock = True
00067                 value.append(line[:-1])
00068             elif line.startswith('ESModule') and insideParameterBlock:
00069                 module.append(tuple(value))
00070                 file_modules[key].append(module)
00071                 insideParameterBlock = False
00072                 insideModuleBlock = False
00073             #elif line=='}' and insideParameterBlock:
00074                 #module.append(tuple(value))
00075                 #file_modules[key].append(module)
00076                 #insideParameterBlock = False
00077                 #insideModuleBlock = False
00078             elif (insideParameterBlock):
00079                 value.append(line[:-1])
00080             
00081         if   insideParameterBlock:
00082             module.append(tuple(value))
00083             file_modules[key].append(module)
00084             insideParameterBlock = False
00085             insideModuleBlock = False 
00086 
00087         
00088         return file_modules 
00089                                                                                                                         
def python::readProv::filereader::startswith (   self,
  line 
)

Definition at line 14 of file readProv.py.

00015                              :
00016         "Checks if the first word of the line starts with any of the aList elements"
00017         for item in self.aList:
00018             if line.startswith(item):
00019                 return True
00020         return False    


Member Data Documentation

Definition at line 11 of file readProv.py.