CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
cmsRelvalreport.Candles_file Class Reference

Public Member Functions

def __init__ (self, filename)
 
def get_commands_profilers_meta_list (self)
 

Public Attributes

 commands_profilers_meta_list
 

Detailed Description

Class to read the trivial ASCII file containing the candles

Definition at line 162 of file cmsRelvalreport.py.

Constructor & Destructor Documentation

def cmsRelvalreport.Candles_file.__init__ (   self,
  filename 
)

Definition at line 166 of file cmsRelvalreport.py.

166  def __init__(self, filename):
167 
169 
170  candlesfile=open(filename,'r')
171 
172  if filename[-3:]=='xml':
173  command=''
174  profiler=''
175  meta=''
176  db_meta=''
177  reuse=False
178 
179  from xml.dom import minidom
180 
181  # parse the config
182  xmldoc = minidom.parse(filename)
183 
184  # get the candles
185  candles_list = xmldoc.getElementsByTagName('candle')
186 
187  # a list of dictionaries to store the info
188  candles_dict_list=[]
189 
190  for candle in candles_list:
191  info_dict={}
192  for child in candle.childNodes:# iteration over candle node children
193  if 'nodeName' not in child.__dict__:# if just a text node skip!
194  #print 'CONTINUE!'
195  continue
196  # We pick the info from the node
197  tag_name=child.tagName
198  #print 'Manipulating a %s ...'%tag_name
199  data=child.firstChild.data
200  #print 'Found the data: %s !' %data
201  # and we put it in the dictionary
202  info_dict[tag_name]=data
203  # to store it in a list
204  candles_dict_list.append(info_dict)
205 
206  # and now process what was parsed
207 
208  for candle_dict in candles_dict_list:
209  # compulsory params!!
210  command=candle_dict['command']
211  profiler=candle_dict['profiler']
212  meta=candle_dict['meta']
213  # other params
214  try:
215  db_meta=candle_dict['db_meta']
216  except:
217  db_meta=None
218  try:
219  reuse=candle_dict['reuse']
220  except:
221  reuse=False
222 
223  self.commands_profilers_meta_list.append([command,profiler,meta,reuse,db_meta])
224 
225  # The file is a plain ASCII
226  else:
227  for candle in candlesfile.readlines():
228  # Some parsing of the file
229  if candle[0]!='#' and candle.strip(' \n\t')!='': # if not a comment or an empty line
230  if candle[-1]=='\n': #remove trail \n if it's there
231  candle=candle[:-1]
232  splitted_candle=candle.split('@@@') #separate
233 
234  # compulsory fields
235  command=splitted_candle[0]
236  profiler=splitted_candle[1].strip(' \t')
237  meta=splitted_candle[2].strip(' \t')
238  info=[command,profiler,meta]
239 
240  # FIXME: AN .ini or xml config??
241  # do we have something more?
242  len_splitted_candle=len(splitted_candle)
243  reuse=False
244  if len_splitted_candle>3:
245  # is it a reuse statement?
246  if 'reuse' in splitted_candle[3]:
247  reuse=True
248  info.append(reuse)
249  else:
250  info.append(reuse)
251 
252  # we have one more field or we hadn't a reuse in the last one
253  if len_splitted_candle>4 or (len_splitted_candle>3 and not reuse):
254  cmssw_scram_version_string=splitted_candle[-1].strip(' \t')
255  info.append(cmssw_scram_version_string)
256  else:
257  info.append(None)
258 
259 
260  self.commands_profilers_meta_list.append(info)
261 
def __init__(self, filename)

Member Function Documentation

def cmsRelvalreport.Candles_file.get_commands_profilers_meta_list (   self)

Member Data Documentation

cmsRelvalreport.Candles_file.commands_profilers_meta_list