CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
python.read_provenance.filereader Class Reference

Public Member Functions

def __init__ (self)
 
def readfile (self, nomefile)
 
def startswith (self, line)
 

Public Attributes

 aList
 

Detailed Description

Definition at line 1 of file read_provenance.py.

Constructor & Destructor Documentation

def python.read_provenance.filereader.__init__ (   self)

Definition at line 3 of file read_provenance.py.

3  def __init__(self):
4  self.aList=['Module', 'ESSource']
5 

Member Function Documentation

def python.read_provenance.filereader.readfile (   self,
  nomefile 
)

Definition at line 13 of file read_provenance.py.

References python.read_provenance.filereader.startswith().

13  def readfile(self,nomefile):
14  "Reads the file line by line and searches for the begin and the end of each Module block"
15  aFile = open(nomefile)
16  module = []
17  source = []
18  file_modules = {}
19  insideModuleBlock = False
20  insideParameterBlock = False
21  for line in aFile.readlines():
22  if self.startswith(line):
23  if insideParameterBlock:
24  file_modules[key]=module
25  insideParameterBlock = False
26  #print line[:-1]
27  module=[]
28  module.append(line[:-1])
29  key=line[line.index(':')+2:-1]
30  #print key
31  insideModuleBlock = True
32  insideParameterBlock = False
33  elif (line.startswith(' parameters')) and insideModuleBlock:
34  insideParameterBlock = True
35  module.append(line[:-1])
36  #print line[:-1]
37  elif line.startswith('ESModule') and insideParameterBlock:
38  file_modules[key]=module
39  insideParameterBlock = False
40  insideModuleBlock = False
41  elif (insideParameterBlock):
42  module.append(line[:-1])
43  #print line[:-1]
44 
45 
46  return file_modules
47 
48 
def python.read_provenance.filereader.startswith (   self,
  line 
)

Definition at line 6 of file read_provenance.py.

References python.read_provenance.filereader.aList.

Referenced by python.read_provenance.filereader.readfile(), and python.readProv.filereader.readfile().

6  def startswith(self,line):
7  "Checks if the first word of the line starts with any of the aList elements"
8  for item in self.aList:
9  if line.startswith(item):
10  return True
11  return False
12 

Member Data Documentation

python.read_provenance.filereader.aList