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'}
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
165 for piece
in classList:
167 className = spacesRE.sub (
'', piece.name)
172 className = stdRE.sub (
'', className)
175 for typedef, tdList
in typedefsDict.iteritems():
177 className = re.sub (alias, typedef, className)
178 classDict.setdefault (className, set()).add (filename)
180 if not options.lostDefs:
182 localObjects.append (className)
183 if options.lazyLostDefs
and not braketRE.search (className):
185 matchString =
r'\b' + className +
r'\b'
186 simpleObjectREs.append( (re.compile (matchString), className ) )
187 for className
in localObjects:
191 for equivRE
in regexList:
193 if equivRE[0].search (className):
196 for simpleRE
in simpleObjectREs:
197 if simpleRE[0].search (className):
199 if options.verbose
and simpleRE[1] != className:
200 print " Using %s to ignore %s" \
201 % (simpleRE[1], className)
203 if foundEquiv:
continue
204 for exRes
in explicitREs:
205 if exRes[0].
search(className):
206 dupProblems +=
" %s : %s\n" % (exRes[1], className)
209 if foundEquiv:
continue
210 for packageName
in xmlPackages:
213 if packagesREs[packageName].search (className):
214 dupProblems +=
" %s : %s\n" % (packageName, className)
218 print '\n%s\n%s\n' % (filename, dupProblems)
221 for name, fileSet
in sorted( classDict.iteritems() ):
222 if len (fileSet) < 2:
225 fileList = list (fileSet)
227 for filename
in fileList: