Functions | |
def | searchClassDefXml |
def | searchDuplicatePlugins |
Variables | |
string | action = 'store_true' |
default = False, | |
tuple | dumpGroup = optparse.OptionGroup(parser, "EdmPluginDump options") |
equivDict = \ | |
string | help = "Search for duplicate definitions" |
dictionary | ignoreEdmDP |
tuple | parser |
typedefsDict = \ | |
tuple | xmlGroup = optparse.OptionGroup(parser, "ClassDef XML options") |
def duplicateReflexLibrarySearch::searchClassDefXml | ( | ) |
Searches through the requested directory looking at 'classes_def.xml' files looking for duplicate Reflex definitions.
Definition at line 78 of file duplicateReflexLibrarySearch.py.
00079 : 00080 """ Searches through the requested directory looking at 00081 'classes_def.xml' files looking for duplicate Reflex definitions.""" 00082 # compile necessary RE statements 00083 classNameRE = re.compile (r'class\s+name\s*=\s*"([^"]*)"') 00084 spacesRE = re.compile (r'\s+') 00085 stdRE = re.compile (r'std::') 00086 srcClassNameRE = re.compile (r'(\w+)/src/classes_def.xml') 00087 ignoreSrcRE = re.compile (r'.*/FWCore/Skeletons/scripts/mkTemplates/.+') 00088 braketRE = re.compile (r'<.+>') 00089 print "Searching for 'classes_def.xml' in '%s'." % os.path.join(os.environ.get('CMSSW_BASE'),'src') 00090 xmlFiles = [] 00091 for srcDir in [os.environ.get('CMSSW_BASE'),os.environ.get('CMSSW_RELEASE_BASE')]: 00092 if not len(srcDir): continue 00093 for xml in commands.getoutput ('cd '+os.path.join(srcDir,'src')+'; find . -name "*classes_def.xml" -print').split ('\n'): 00094 if xml and (not xml in xmlFiles): 00095 xmlFiles.append(xml) 00096 if options.showXMLs: 00097 pprint.pprint (xmlFiles) 00098 # try and figure out the names of the packages 00099 xmlPackages = [] 00100 packagesREs = {} 00101 equivREs = {} 00102 explicitREs = [] 00103 for item in equivDict: 00104 for pack in item: 00105 for equiv in item[pack]: 00106 explicitREs.append( (re.compile(r'\b' + equiv + r'\b'),pack)) 00107 if options.lostDefs: 00108 for filename in xmlFiles: 00109 if (not filename) or (ignoreSrcRE.match(filename)): continue 00110 match = srcClassNameRE.search (filename) 00111 if not match: continue 00112 packageName = match.group(1) 00113 xmlPackages.append (packageName) 00114 matchString = r'\b' + packageName + r'\b' 00115 packagesREs[packageName] = re.compile (matchString) 00116 equivList = equivREs.setdefault (packageName, []) 00117 for item in equivDict: 00118 for equiv in item.get (packageName, []): 00119 matchString = re.compile(r'\b' + equiv + r'\b') 00120 equivList.append( (matchString, equiv) ) 00121 equivList.append( (packagesREs[packageName], packageName) ) 00122 classDict = {} 00123 ncdict = {'class' : 'className'} 00124 for filename in xmlFiles: 00125 if (not filename) or (ignoreSrcRE.match(filename)): continue 00126 dupProblems = '' 00127 exceptName = '' 00128 regexList = [] 00129 localObjects = [] 00130 simpleObjectREs = [] 00131 if options.lostDefs: 00132 lostMatch = srcClassNameRE.search (filename) 00133 if lostMatch: 00134 exceptName = lostMatch.group (1) 00135 regexList = equivREs[exceptName] 00136 xcount = len(regexList)-1 00137 if not regexList[xcount][0].search (exceptName): 00138 print '%s not found in' % exceptName, 00139 print regexList[xcount][0] 00140 sys.exit() 00141 else: continue 00142 if options.verbose: 00143 print "filename", filename 00144 try: 00145 filepath = os.path.join(os.environ.get('CMSSW_BASE'),'src',filename) 00146 if not os.path.exists(filepath): 00147 filepath = os.path.join(os.environ.get('CMSSW_RELEASE_BASE'),'src',filename) 00148 xmlObj = xml2obj (filename = filepath, 00149 filtering = True, 00150 nameChangeDict = ncdict) 00151 except Exception as detail: 00152 print "File %s is malformed XML. Please fix." % filename 00153 print " ", detail 00154 continue 00155 try: 00156 classList = xmlObj.selection.className 00157 except: 00158 try: 00159 classList = xmlObj.className 00160 except: 00161 # this isn't a real classes_def.xml file. Skip it 00162 print "**** SKIPPING '%s' - Doesn't seem to have proper information." % filename 00163 continue 00164 for piece in classList: 00165 try: 00166 className = spacesRE.sub ('', piece.name) 00167 except: 00168 # must be one of these class pattern things. Skip it 00169 #print " skipping %s" % filename, piece.__repr__() 00170 continue 00171 className = stdRE.sub ('', className) 00172 # print " ", className 00173 # Now get rid of any typedefs 00174 for typedef, tdList in typedefsDict.iteritems(): 00175 for alias in tdList: 00176 className = re.sub (alias, typedef, className) 00177 classDict.setdefault (className, set()).add (filename) 00178 # should we check for lost definitions? 00179 if not options.lostDefs: 00180 continue 00181 localObjects.append (className) 00182 if options.lazyLostDefs and not braketRE.search (className): 00183 #print " ", className 00184 matchString = r'\b' + className + r'\b' 00185 simpleObjectREs.append( (re.compile (matchString), className ) ) 00186 for className in localObjects: 00187 # if we see our name (or equivalent) here, then let's 00188 # skip complaining about this 00189 foundEquiv = False 00190 for equivRE in regexList: 00191 #print "searching %s for %s" % (equivRE[1], className) 00192 if equivRE[0].search (className): 00193 foundEquiv = True 00194 break 00195 for simpleRE in simpleObjectREs: 00196 if simpleRE[0].search (className): 00197 foundEquiv = True 00198 if options.verbose and simpleRE[1] != className: 00199 print " Using %s to ignore %s" \ 00200 % (simpleRE[1], className) 00201 break 00202 if foundEquiv: continue 00203 for exRes in explicitREs: 00204 if exRes[0].search(className): 00205 dupProblems += " %s : %s\n" % (exRes[1], className) 00206 foundEquiv = True 00207 break 00208 if foundEquiv: continue 00209 for packageName in xmlPackages: 00210 # don't bother looking for the name of this 00211 # package in this package 00212 if packagesREs[packageName].search (className): 00213 dupProblems += " %s : %s\n" % (packageName, className) 00214 break 00215 # for piece 00216 if dupProblems: 00217 print '\n%s\n%s\n' % (filename, dupProblems) 00218 # for filename 00219 if options.dups: 00220 for name, fileSet in sorted( classDict.iteritems() ): 00221 if len (fileSet) < 2: 00222 continue 00223 print name 00224 fileList = list (fileSet) 00225 fileList.sort() 00226 for filename in fileList: 00227 print " ", filename 00228 print 00229 # for name, fileSet 00230 # if not noDups 00231 #pprint.pprint (classDict) 00232
def duplicateReflexLibrarySearch::searchDuplicatePlugins | ( | ) |
Searches the edmpluginFile to find any duplicate plugins.
Definition at line 233 of file duplicateReflexLibrarySearch.py.
00234 : 00235 """ Searches the edmpluginFile to find any duplicate 00236 plugins.""" 00237 edmpluginFile = os.path.join(os.environ.get('CMSSW_BASE'),'lib',os.environ.get('SCRAM_ARCH'),'.edmplugincache') 00238 if len (os.environ.get('CMSSW_RELEASE_BASE')): 00239 edmpluginFile = edmpluginFile+ ' ' + os.path.join(os.environ.get('CMSSW_RELEASE_BASE'),'lib',os.environ.get('SCRAM_ARCH'),'.edmplugincache') 00240 cmd = "cat %s | awk '{print $2\" \"$1}' | sort | uniq | awk '{print $1}' | sort | uniq -c | grep '2 ' | awk '{print $2}'" % edmpluginFile 00241 output = commands.getoutput (cmd).split('\n') 00242 for line in output: 00243 if ignoreEdmDP.has_key(line): continue 00244 line = line.replace("*","\*") 00245 cmd = "cat %s | grep ' %s ' | awk '{print $1}' | sort | uniq " % (edmpluginFile,line) 00246 out1 = commands.getoutput (cmd).split('\n') 00247 print line 00248 for plugin in out1: 00249 if plugin: 00250 print " **"+plugin+"**" 00251 print
string duplicateReflexLibrarySearch::action = 'store_true' |
Definition at line 266 of file duplicateReflexLibrarySearch.py.
string duplicateReflexLibrarySearch::default = False, |
Definition at line 260 of file duplicateReflexLibrarySearch.py.
tuple duplicateReflexLibrarySearch::dumpGroup = optparse.OptionGroup(parser, "EdmPluginDump options") |
Definition at line 258 of file duplicateReflexLibrarySearch.py.
Definition at line 33 of file duplicateReflexLibrarySearch.py.
string duplicateReflexLibrarySearch::help = "Search for duplicate definitions" |
Definition at line 261 of file duplicateReflexLibrarySearch.py.
dictionary duplicateReflexLibrarySearch::ignoreEdmDP |
00001 { 00002 'LCGReflex/__gnu_cxx::__normal_iterator<std::basic_string<char>*,std::vector<std::basic_string<char>%>%>' : 1, 00003 '' : 1 00004 }
Definition at line 73 of file duplicateReflexLibrarySearch.py.
00001 optparse.OptionParser("Usage: %prog [options]\n"\ 00002 "Searches classes_def.xml for wrong/duplicate "\ 00003 "definitions")
Definition at line 254 of file duplicateReflexLibrarySearch.py.
Definition at line 15 of file duplicateReflexLibrarySearch.py.
tuple duplicateReflexLibrarySearch::xmlGroup = optparse.OptionGroup(parser, "ClassDef XML options") |
Definition at line 257 of file duplicateReflexLibrarySearch.py.