Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /CondCore/Utilities/scripts/cmscond_list_esrecord is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python3
0002 import os,fnmatch,string
0003 from optparse import OptionParser
0004 class listESrecord:
0005     def __init__(self):
0006         """
0007         Search in 
0008         usage: %prog [options]
0009         -l, --local: search in local CMSSW_BASE (optional.If not specified will search in $CMSSW_RELEASE_BASE)
0010         -s, --subsystem: search for the given subsystem (optional. If not specified will search in all directories match pattern CondCore/[Subsystem]Plugins 
0011         -v, --verbose: switch on verbose mode
0012         -h, --help: print usage
0013         """
0014         self.__cmsswbase='$CMSSW_BASE'
0015         self.__cmsswreleasebase='$CMSSW_RELEASE_BASE'
0016         self.__local=False
0017         self.__verbose=False
0018         self.__plugindir=[]
0019     def parsecmdln(self):
0020         """
0021         Parse command line
0022         """
0023         usage = "usage: \%prog [options] \n"
0024         parser = OptionParser()
0025         parser.add_option("-l","--local",action="store_true",dest="islocal",
0026                           help="search in local CMSSW_BASE (optional.If not specified will search in $CMSSW_RELEASE_BASE")
0027         parser.add_option("-s","--subsystem",action="store",dest="subsystem",
0028                           help="search for the given subsystem (optional. If not specified will search in all directories match pattern CondCore/[Subsystem]Plugins")
0029         parser.add_option("-v","--verbose",action="store_true",dest="verbose",
0030                           help="verbose mode")
0031         
0032         (options, args) = parser.parse_args()
0033         if options.islocal :
0034             self.__local=True
0035         if options.subsystem :
0036             searchdir=''
0037             if self.__local is True:
0038                 searchdir=os.path.expandvars(self.__cmsswbase)
0039             else:
0040                 searchdir=os.path.expandvars(self.__cmsswreleasebase)
0041             plugindir=options.subsystem+'Plugins'
0042             searchdir=os.path.join(searchdir,'src','CondCore',plugindir)
0043             self.__plugindir.append(searchdir)
0044         else :
0045             searchdir=''
0046             if self.__local is True:
0047                 searchdir=os.path.expandvars(self.__cmsswbase)
0048             else:
0049                 searchdir=os.path.expandvars(self.__cmsswreleasebase)
0050             searchdir=os.path.join(searchdir,'src','CondCore')
0051             plugindirs=fnmatch.filter(os.listdir(searchdir),'*Plugins')
0052             for dir in plugindirs:
0053                 r=os.path.join(searchdir,dir)
0054                 self.__plugindir.append(r)
0055     def parsePluginfiles(self):
0056         """Loop over plugin dir and parse plugindir/src/plugin.cc
0057         """
0058         print 'found in ',self.__plugindir
0059         print 'EventSetup record \t type'
0060         print '###################################################'
0061         for d in self.__plugindir:
0062             mydir=os.path.join(d,'src')
0063             pluginfiles=fnmatch.filter(os.listdir(mydir),'*.cc')
0064             for pluginfile in pluginfiles:
0065                 f=open(os.path.join(mydir,pluginfile),'r',-1)
0066                 lines=f.read().split('\n')
0067                 for line in lines:
0068                    cleanline=('').join(line.split(' '))
0069                    result=self.parseCondPlugin(cleanline)
0070                    if result is not None:
0071                        print result[0],'\t',result[1]
0072                 f.close()
0073     def parseCondPlugin(self,dataproxy):
0074         """
0075         dataproxy:REGISTER_PLUGIN(recordnae,objectname)
0076         """
0077         pos=dataproxy.find("REGISTER_PLUGIN(")
0078         if pos is -1:
0079             return None
0080         pos=pos+len('REGISTER_PLUGIN(')
0081         closeb=dataproxy.rfind(')')
0082         subs=dataproxy[pos:closeb]
0083         result=subs.split(',')
0084         return result
0085 if __name__ == "__main__":
0086     me=listESrecord()
0087     me.parsecmdln()
0088     me.parsePluginfiles()
0089