89 """ Searches through the requested directory looking at 90 'classes_def.xml' files looking for duplicate Reflex definitions.""" 92 classNameRE = re.compile (
r'class\s+name\s*=\s*"([^"]*)"')
93 spacesRE = re.compile (
r'\s+')
94 stdRE = re.compile (
r'std::')
95 srcClassNameRE = re.compile (
r'(\w+)/src/classes_def.*[.]xml')
96 ignoreSrcRE = re.compile (
r'.*/FWCore/Skeletons/scripts/mkTemplates/.+')
97 braketRE = re.compile (
r'<.+>')
98 print(
"Searching for 'classes_def.xml' in '%s'." % os.path.join(os.environ.get(
'CMSSW_BASE'),
'src'))
100 for srcDir
in [os.environ.get(
'CMSSW_BASE'),os.environ.get(
'CMSSW_RELEASE_BASE')]:
101 if not len(srcDir):
continue 102 for xml
in getoutput (
'cd '+os.path.join(srcDir,
'src')+
'; find . -name "*classes_def*.xml" -follow -print').split (
'\n'):
103 if xml
and (
not xml
in xmlFiles):
106 pprint.pprint (xmlFiles)
112 for item
in equivDict:
114 for equiv
in item[pack]:
115 explicitREs.append( (re.compile(
r'\b' + equiv +
r'\b'),pack))
117 for filename
in xmlFiles:
118 if (
not filename)
or (ignoreSrcRE.match(filename)):
continue 119 match = srcClassNameRE.search (filename)
120 if not match:
continue 121 packageName = match.group(1)
122 xmlPackages.append (packageName)
123 matchString =
r'\b' + packageName +
r'\b' 124 packagesREs[packageName] = re.compile (matchString)
125 equivList = equivREs.setdefault (packageName, [])
126 for item
in equivDict:
127 for equiv
in item.get (packageName, []):
128 matchString = re.compile(
r'\b' + equiv +
r'\b')
129 equivList.append( (matchString, equiv) )
130 equivList.append( (packagesREs[packageName], packageName) )
132 ncdict = {
'class' :
'className',
'function' :
'functionName'}
133 for filename
in xmlFiles:
134 if (
not filename)
or (ignoreSrcRE.match(filename)):
continue 141 lostMatch = srcClassNameRE.search (filename)
143 exceptName = lostMatch.group (1)
144 regexList = equivREs[exceptName]
145 xcount = len(regexList)-1
146 if not regexList[xcount][0].search (exceptName):
147 print(
'%s not found in' % exceptName, end=
' ')
148 print(regexList[xcount][0])
152 print(
"filename", filename)
154 filepath = os.path.join(os.environ.get(
'CMSSW_BASE'),
'src',filename)
155 if not os.path.exists(filepath):
156 filepath = os.path.join(os.environ.get(
'CMSSW_RELEASE_BASE'),
'src',filename)
157 xmlObj = xml2obj (filename = filepath,
159 nameChangeDict = ncdict)
160 except Exception
as detail:
161 print(
"File %s is malformed XML. Please fix." % filename)
165 classList = xmlObj.selection.className
168 classList = xmlObj.className
171 print(
"**** SKIPPING '%s' - Doesn't seem to have proper information." % filename)
174 classList = xmlObj.functionName
176 print(
"**** SKIPPING '%s' - Dosen't seem to have proper information(not class/function)." % filename)
178 for piece
in classList:
180 className = spacesRE.sub (
'', piece.name)
185 className = stdRE.sub (
'', className)
188 for typedef, tdList
in typedefsDict.items():
190 className = re.sub (alias, typedef, className)
191 classDict.setdefault (className, set()).add (filename)
193 if not options.lostDefs:
195 localObjects.append (className)
196 if options.lazyLostDefs
and not braketRE.search (className):
198 matchString =
r'\b' + className +
r'\b' 199 simpleObjectREs.append( (re.compile (matchString), className ) )
200 for className
in localObjects:
204 for equivRE
in regexList:
206 if equivRE[0].search (className):
209 for simpleRE
in simpleObjectREs:
210 if simpleRE[0].search (className):
212 if options.verbose
and simpleRE[1] != className:
213 print(
" Using %s to ignore %s" \
214 % (simpleRE[1], className))
216 if foundEquiv:
continue 217 for exRes
in explicitREs:
218 if exRes[0].
search(className):
219 lostProblems +=
" %s : %s\n" % (exRes[1], className)
222 if foundEquiv:
continue 223 for packageName
in xmlPackages:
226 if packagesREs[packageName].search (className):
227 lostProblems +=
" %s : %s\n" % (packageName, className)
231 print(f
'\n{filename} defines the following dictionaries that should be defined in another package\n{lostProblems}\n')
234 for name, fileSet
in sorted( classDict.items() ):
235 if len (fileSet) < 2:
237 print(f
"{name} is defined in more than one package")
238 fileList = sorted (fileSet)
239 for filename
in fileList:
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)