81 """ Searches through the requested directory looking at
82 'classes_def.xml' files looking for duplicate Reflex definitions."""
84 classNameRE = re.compile (
r'class\s+name\s*=\s*"([^"]*)"')
85 spacesRE = re.compile (
r'\s+')
86 stdRE = re.compile (
r'std::')
87 srcClassNameRE = re.compile (
r'(\w+)/src/classes_def.xml')
88 ignoreSrcRE = re.compile (
r'.*/FWCore/Skeletons/scripts/mkTemplates/.+')
89 braketRE = re.compile (
r'<.+>')
90 print "Searching for 'classes_def.xml' in '%s'." % os.path.join(os.environ.get(
'CMSSW_BASE'),
'src')
92 for srcDir
in [os.environ.get(
'CMSSW_BASE'),os.environ.get(
'CMSSW_RELEASE_BASE')]:
93 if not len(srcDir):
continue
94 for xml
in commands.getoutput (
'cd '+os.path.join(srcDir,
'src')+
'; find . -name "*classes_def.xml" -follow -print').split (
'\n'):
95 if xml
and (
not xml
in xmlFiles):
98 pprint.pprint (xmlFiles)
104 for item
in equivDict:
106 for equiv
in item[pack]:
107 explicitREs.append( (re.compile(
r'\b' + equiv +
r'\b'),pack))
109 for filename
in xmlFiles:
110 if (
not filename)
or (ignoreSrcRE.match(filename)):
continue
111 match = srcClassNameRE.search (filename)
112 if not match:
continue
113 packageName = match.group(1)
114 xmlPackages.append (packageName)
115 matchString =
r'\b' + packageName +
r'\b'
116 packagesREs[packageName] = re.compile (matchString)
117 equivList = equivREs.setdefault (packageName, [])
118 for item
in equivDict:
119 for equiv
in item.get (packageName, []):
120 matchString = re.compile(
r'\b' + equiv +
r'\b')
121 equivList.append( (matchString, equiv) )
122 equivList.append( (packagesREs[packageName], packageName) )
124 ncdict = {
'class' :
'className',
'function' :
'functionName'}
125 for filename
in xmlFiles:
126 if (
not filename)
or (ignoreSrcRE.match(filename)):
continue
133 lostMatch = srcClassNameRE.search (filename)
135 exceptName = lostMatch.group (1)
136 regexList = equivREs[exceptName]
137 xcount = len(regexList)-1
138 if not regexList[xcount][0].search (exceptName):
139 print '%s not found in' % exceptName,
140 print regexList[xcount][0]
144 print "filename", filename
146 filepath = os.path.join(os.environ.get(
'CMSSW_BASE'),
'src',filename)
147 if not os.path.exists(filepath):
148 filepath = os.path.join(os.environ.get(
'CMSSW_RELEASE_BASE'),
'src',filename)
149 xmlObj = xml2obj (filename = filepath,
151 nameChangeDict = ncdict)
152 except Exception
as detail:
153 print "File %s is malformed XML. Please fix." % filename
157 classList = xmlObj.selection.className
160 classList = xmlObj.className
163 print "**** SKIPPING '%s' - Doesn't seem to have proper information." % filename
166 classList = xmlObj.functionName
168 print "**** SKIPPING '%s' - Dosen't seem to have proper information(not class/function)." % filename
170 for piece
in classList:
172 className = spacesRE.sub (
'', piece.name)
177 className = stdRE.sub (
'', className)
180 for typedef, tdList
in typedefsDict.iteritems():
182 className = re.sub (alias, typedef, className)
183 classDict.setdefault (className, set()).add (filename)
185 if not options.lostDefs:
187 localObjects.append (className)
188 if options.lazyLostDefs
and not braketRE.search (className):
190 matchString =
r'\b' + className +
r'\b'
191 simpleObjectREs.append( (re.compile (matchString), className ) )
192 for className
in localObjects:
196 for equivRE
in regexList:
198 if equivRE[0].search (className):
201 for simpleRE
in simpleObjectREs:
202 if simpleRE[0].search (className):
204 if options.verbose
and simpleRE[1] != className:
205 print " Using %s to ignore %s" \
206 % (simpleRE[1], className)
208 if foundEquiv:
continue
209 for exRes
in explicitREs:
210 if exRes[0].
search(className):
211 dupProblems +=
" %s : %s\n" % (exRes[1], className)
214 if foundEquiv:
continue
215 for packageName
in xmlPackages:
218 if packagesREs[packageName].search (className):
219 dupProblems +=
" %s : %s\n" % (packageName, className)
223 print '\n%s\n%s\n' % (filename, dupProblems)
226 for name, fileSet
in sorted( classDict.iteritems() ):
227 if len (fileSet) < 2:
230 fileList = list (fileSet)
232 for filename
in fileList: