CMS 3D CMS Logo

Public Member Functions | Public Attributes

cmsRelvalreport::Candles_file Class Reference

List of all members.

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 161 of file cmsRelvalreport.py.


Constructor & Destructor Documentation

def cmsRelvalreport::Candles_file::__init__ (   self,
  filename 
)

Definition at line 165 of file cmsRelvalreport.py.

00166                                 :
00167         
00168         self.commands_profilers_meta_list=[]    
00169     
00170         candlesfile=open(filename,'r')
00171         
00172         if filename[-3:]=='xml':
00173             command=''
00174             profiler=''
00175             meta=''
00176             db_meta=''
00177             reuse=False    
00178             
00179             from xml.dom import minidom
00180             
00181             # parse the config
00182             xmldoc = minidom.parse(filename)
00183             
00184             # get the candles
00185             candles_list = xmldoc.getElementsByTagName('candle')
00186             
00187             # a list of dictionaries to store the info
00188             candles_dict_list=[]
00189             
00190             for candle in candles_list:
00191                 info_dict={}
00192                 for child in candle.childNodes:# iteration over candle node children
00193                     if not child.__dict__.has_key('nodeName'):# if just a text node skip!
00194                         #print 'CONTINUE!'
00195                         continue
00196                     # We pick the info from the node
00197                     tag_name=child.tagName
00198                     #print 'Manipulating a %s ...'%tag_name
00199                     data=child.firstChild.data
00200                     #print 'Found the data: %s !' %data
00201                     # and we put it in the dictionary
00202                     info_dict[tag_name]=data
00203                 # to store it in a list
00204                 candles_dict_list.append(info_dict)
00205             
00206             # and now process what was parsed
00207                         
00208             for candle_dict in candles_dict_list:
00209                 # compulsory params!!
00210                 command=candle_dict['command']
00211                 profiler=candle_dict['profiler']
00212                 meta=candle_dict['meta']
00213                 # other params
00214                 try:
00215                     db_meta=candle_dict['db_meta']
00216                 except:
00217                     db_meta=None
00218                 try:
00219                     reuse=candle_dict['reuse']
00220                 except:
00221                     reuse=False    
00222                             
00223                 self.commands_profilers_meta_list.append([command,profiler,meta,reuse,db_meta])
00224         
00225         # The file is a plain ASCII
00226         else:
00227             for candle in candlesfile.readlines():
00228                 # Some parsing of the file
00229                 if candle[0]!='#' and candle.strip(' \n\t')!='': # if not a comment or an empty line
00230                     if candle[-1]=='\n': #remove trail \n if it's there
00231                         candle=candle[:-1] 
00232                     splitted_candle=candle.split('@@@') #separate
00233                     
00234                     # compulsory fields
00235                     command=splitted_candle[0]
00236                     profiler=splitted_candle[1].strip(' \t')
00237                     meta=splitted_candle[2].strip(' \t')        
00238                     info=[command,profiler,meta]
00239                     
00240                     # FIXME: AN .ini or xml config??
00241                     # do we have something more?
00242                     len_splitted_candle=len(splitted_candle)
00243                     reuse=False
00244                     if len_splitted_candle>3:
00245                         # is it a reuse statement?
00246                         if 'reuse' in splitted_candle[3]:
00247                             reuse=True
00248                         info.append(reuse)
00249                     else:
00250                         info.append(reuse)               
00251                     
00252                     # we have one more field or we hadn't a reuse in the last one    
00253                     if len_splitted_candle>4 or (len_splitted_candle>3 and not reuse):
00254                         cmssw_scram_version_string=splitted_candle[-1].strip(' \t')
00255                         info.append(cmssw_scram_version_string)
00256                     else:
00257                         info.append(None)
00258     
00259                         
00260                     self.commands_profilers_meta_list.append(info)
                    

Member Function Documentation

def cmsRelvalreport::Candles_file::get_commands_profilers_meta_list (   self)

Definition at line 263 of file cmsRelvalreport.py.

00264                                               :
00265         return self.commands_profilers_meta_list
            

Member Data Documentation

Definition at line 165 of file cmsRelvalreport.py.