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 | Public Attributes
cmsRelvalreport.Candles_file Class Reference

Public Member Functions

def __init__
 
def get_commands_profilers_meta_list
 

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.

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

Member Function Documentation

def cmsRelvalreport.Candles_file.get_commands_profilers_meta_list (   self)

Definition at line 264 of file cmsRelvalreport.py.

References cmsRelvalreport.Candles_file.commands_profilers_meta_list.

Member Data Documentation

cmsRelvalreport.Candles_file.commands_profilers_meta_list

Definition at line 168 of file cmsRelvalreport.py.

Referenced by cmsRelvalreport.Candles_file.get_commands_profilers_meta_list().