CMS 3D CMS Logo

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

Classes

class  Module
 

Public Member Functions

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

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.

11  def __init__(self):
12  self.aList=['Module', 'ESSource']
13 

Member Function Documentation

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

Definition at line 21 of file readProv.py.

References mps_setup.append, python.read_provenance.filereader.startswith(), and python.readProv.filereader.startswith().

21  def readfile(self,nomefile):
22  "Reads the file line by line and searches for the begin and the end of each Module block"
23  aFile = open(nomefile)
24  module=[]
25  value=[]
26  file_modules = {}
27  processHistory=False
28  processing=False
29  insideModuleBlock = False
30  insideParameterBlock = False
31  nprocess=-1
32  key=''
33  for line in aFile.readlines():
34  if line.startswith("Processing History:"):
35  value=[]
36  processHistory=True
37  elif (not line.startswith('---------Event')) and processHistory:
38  splitLine= line.split()
39  if splitLine[3]=='[2]':
40  processing=True
41  value.append(line)
42  elif processing:
43  value.append(line)
44  elif line.startswith('---------Event') and processing:
45  file_modules['Processing']=value
46  processHistory=False
47  processing=False
48  elif self.startswith(line):
49  if insideParameterBlock:
50  module.append(tuple(value))
51  file_modules[key].append(module)
52  insideParameterBlock = False
53  insideModuleBlock = False ###controllare
54  value=[]
55  module=[]
56  splitLine= line.split()
57  key=splitLine[-1]
58  if key not in file_modules.keys():
59  file_modules[key]=[]
60  module.append(splitLine[-2])
61  value.append(line[:-1])
62  insideModuleBlock = True
63  insideParameterBlock = False
64  elif (line.startswith(' parameters')) and insideModuleBlock:
65  insideParameterBlock = True
66  value.append(line[:-1])
67  elif line.startswith('ESModule') and insideParameterBlock:
68  module.append(tuple(value))
69  file_modules[key].append(module)
70  insideParameterBlock = False
71  insideModuleBlock = False
72  #elif line=='}' and insideParameterBlock:
73  #module.append(tuple(value))
74  #file_modules[key].append(module)
75  #insideParameterBlock = False
76  #insideModuleBlock = False
77  elif (insideParameterBlock):
78  value.append(line[:-1])
79 
80  if insideParameterBlock:
81  module.append(tuple(value))
82  file_modules[key].append(module)
83  insideParameterBlock = False
84  insideModuleBlock = False
85 
86 
87  return file_modules
88 
89 
def readfile(self, nomefile)
Definition: readProv.py:21
def startswith(self, line)
Definition: readProv.py:14
def python.readProv.filereader.startswith (   self,
  line 
)

Definition at line 14 of file readProv.py.

References python.read_provenance.filereader.aList, and python.readProv.filereader.aList.

Referenced by python.readProv.filereader.readfile().

14  def startswith(self,line):
15  "Checks if the first word of the line starts with any of the aList elements"
16  for item in self.aList:
17  if line.startswith(item):
18  return True
19  return False
20 
def startswith(self, line)
Definition: readProv.py:14

Member Data Documentation

python.readProv.filereader.aList

Definition at line 12 of file readProv.py.

Referenced by python.readProv.filereader.startswith().