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


Constructor & Destructor Documentation

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

Definition at line 166 of file cmsRelvalreport.py.

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

00265                                               :
00266         return self.commands_profilers_meta_list
            

Member Data Documentation

Definition at line 166 of file cmsRelvalreport.py.