CMS 3D CMS Logo

Functions | Variables
duplicateReflexLibrarySearch Namespace Reference

Functions

def searchClassDefXml ()
 
def searchDuplicatePlugins ()
 

Variables

 action
 
 args
 
 default
 
 dest
 
 dumpGroup
 
 equivDict
 
 help
 
 ignoreEdmDP
 
 lostDefs
 
 options
 
 parser
 
 type
 
 typedefsDict
 
 xmlGroup
 

Function Documentation

◆ searchClassDefXml()

def duplicateReflexLibrarySearch.searchClassDefXml ( )
Searches through the requested directory looking at
'classes_def.xml' files looking for duplicate Reflex definitions.

Definition at line 89 of file duplicateReflexLibrarySearch.py.

89 def searchClassDefXml ():
90  """ Searches through the requested directory looking at
91  'classes_def.xml' files looking for duplicate Reflex definitions."""
92  # compile necessary RE statements
93  classNameRE = re.compile (r'class\s+name\s*=\s*"([^"]*)"')
94  spacesRE = re.compile (r'\s+')
95  stdRE = re.compile (r'std::')
96  srcClassNameRE = re.compile (r'(\w+)/src/classes_def.*[.]xml')
97  ignoreSrcRE = re.compile (r'.*/FWCore/Skeletons/scripts/mkTemplates/.+')
98  braketRE = re.compile (r'<.+>')
99  print("Searching for 'classes_def.xml' in '%s'." % os.path.join(os.environ.get('CMSSW_BASE'),'src'))
100  xmlFiles = []
101  for srcDir in [os.environ.get('CMSSW_BASE'),os.environ.get('CMSSW_RELEASE_BASE')]:
102  if not len(srcDir): continue
103  for xml in getoutput ('cd '+os.path.join(srcDir,'src')+'; find . -name "*classes_def*.xml" -follow -print').split ('\n'):
104  if xml and (not xml in xmlFiles):
105  xmlFiles.append(xml)
106  if options.showXMLs:
107  pprint.pprint (xmlFiles)
108  # try and figure out the names of the packages
109  xmlPackages = []
110  packagesREs = {}
111  equivREs = {}
112  explicitREs = []
113  for item in equivDict:
114  for pack in item:
115  for equiv in item[pack]:
116  explicitREs.append( (re.compile(r'\b' + equiv + r'\b'),pack))
117  if options.lostDefs:
118  for filename in xmlFiles:
119  if (not filename) or (ignoreSrcRE.match(filename)): continue
120  match = srcClassNameRE.search (filename)
121  if not match: continue
122  packageName = match.group(1)
123  xmlPackages.append (packageName)
124  matchString = r'\b' + packageName + r'\b'
125  packagesREs[packageName] = re.compile (matchString)
126  equivList = equivREs.setdefault (packageName, [])
127  for item in equivDict:
128  for equiv in item.get (packageName, []):
129  matchString = re.compile(r'\b' + equiv + r'\b')
130  equivList.append( (matchString, equiv) )
131  equivList.append( (packagesREs[packageName], packageName) )
132  classDict = {}
133  ncdict = {'class' : 'className', 'function' : 'functionName'}
134  for filename in xmlFiles:
135  if (not filename) or (ignoreSrcRE.match(filename)): continue
136  dupProblems = ''
137  exceptName = ''
138  regexList = []
139  localObjects = []
140  simpleObjectREs = []
141  if options.lostDefs:
142  lostMatch = srcClassNameRE.search (filename)
143  if lostMatch:
144  exceptName = lostMatch.group (1)
145  regexList = equivREs[exceptName]
146  xcount = len(regexList)-1
147  if not regexList[xcount][0].search (exceptName):
148  print('%s not found in' % exceptName, end=' ')
149  print(regexList[xcount][0])
150  sys.exit()
151  else: continue
152  if options.verbose:
153  print("filename", filename)
154  try:
155  filepath = os.path.join(os.environ.get('CMSSW_BASE'),'src',filename)
156  if not os.path.exists(filepath):
157  filepath = os.path.join(os.environ.get('CMSSW_RELEASE_BASE'),'src',filename)
158  xmlObj = xml2obj (filename = filepath,
159  filtering = True,
160  nameChangeDict = ncdict)
161  except Exception as detail:
162  print("File %s is malformed XML. Please fix." % filename)
163  print(" ", detail)
164  continue
165  try:
166  classList = xmlObj.selection.className
167  except:
168  try:
169  classList = xmlObj.className
170  except:
171  # this isn't a real classes_def.xml file. Skip it
172  print("**** SKIPPING '%s' - Doesn't seem to have proper information." % filename)
173  continue
174  if not classList:
175  classList = xmlObj.functionName
176  if not classList:
177  print("**** SKIPPING '%s' - Dosen't seem to have proper information(not class/function)." % filename)
178  continue
179  for piece in classList:
180  try:
181  className = spacesRE.sub ('', piece.name)
182  except:
183  # must be one of these class pattern things. Skip it
184  #print " skipping %s" % filename, piece.__repr__()
185  continue
186  className = stdRE.sub ('', className)
187  # print " ", className
188  # Now get rid of any typedefs
189  for typedef, tdList in six.iteritems(typedefsDict):
190  for alias in tdList:
191  className = re.sub (alias, typedef, className)
192  classDict.setdefault (className, set()).add (filename)
193  # should we check for lost definitions?
194  if not options.lostDefs:
195  continue
196  localObjects.append (className)
197  if options.lazyLostDefs and not braketRE.search (className):
198  #print " ", className
199  matchString = r'\b' + className + r'\b'
200  simpleObjectREs.append( (re.compile (matchString), className ) )
201  for className in localObjects:
202  # if we see our name (or equivalent) here, then let's
203  # skip complaining about this
204  foundEquiv = False
205  for equivRE in regexList:
206  #print "searching %s for %s" % (equivRE[1], className)
207  if equivRE[0].search (className):
208  foundEquiv = True
209  break
210  for simpleRE in simpleObjectREs:
211  if simpleRE[0].search (className):
212  foundEquiv = True
213  if options.verbose and simpleRE[1] != className:
214  print(" Using %s to ignore %s" \
215  % (simpleRE[1], className))
216  break
217  if foundEquiv: continue
218  for exRes in explicitREs:
219  if exRes[0].search(className):
220  dupProblems += " %s : %s\n" % (exRes[1], className)
221  foundEquiv = True
222  break
223  if foundEquiv: continue
224  for packageName in xmlPackages:
225  # don't bother looking for the name of this
226  # package in this package
227  if packagesREs[packageName].search (className):
228  dupProblems += " %s : %s\n" % (packageName, className)
229  break
230  # for piece
231  if dupProblems:
232  print('\n%s\n%s\n' % (filename, dupProblems))
233  # for filename
234  if options.dups:
235  for name, fileSet in sorted( six.iteritems(classDict) ):
236  if len (fileSet) < 2:
237  continue
238  print(name)
239  fileList = sorted (fileSet)
240  for filename in fileList:
241  print(" ", filename)
242  print()
243  # for name, fileSet
244  # if not noDups
245  #pprint.pprint (classDict)
246 
247 

References edm.print(), and cond::persistency.search().

◆ searchDuplicatePlugins()

def duplicateReflexLibrarySearch.searchDuplicatePlugins ( )
Searches the edmpluginFile to find any duplicate
plugins.

Definition at line 248 of file duplicateReflexLibrarySearch.py.

249  """ Searches the edmpluginFile to find any duplicate
250  plugins."""
251  edmpluginFile = ''
252  libenv = 'LD_LIBRARY_PATH'
253  if os.environ.get('SCRAM_ARCH').startswith('osx'): libenv = 'DYLD_FALLBACK_LIBRARY_PATH'
254  biglib = '/biglib/'+os.environ.get('SCRAM_ARCH')
255  for libdir in os.environ.get(libenv).split(':'):
256  if libdir.endswith(biglib): continue
257  if os.path.exists(libdir+'/.edmplugincache'): edmpluginFile = edmpluginFile + ' ' + libdir+'/.edmplugincache'
258  if edmpluginFile == '': edmpluginFile = os.path.join(os.environ.get('CMSSW_BASE'),'lib',os.environ.get('SCRAM_ARCH'),'.edmplugincache')
259  cmd = "cat %s | awk '{print $2\" \"$1}' | sort | uniq | awk '{print $1}' | sort | uniq -c | grep '2 ' | awk '{print $2}'" % edmpluginFile
260  output = getoutput (cmd).split('\n')
261  for line in output:
262  if line in ignoreEdmDP: continue
263  line = line.replace("*","\*")
264  cmd = "cat %s | grep ' %s ' | awk '{print $1}' | sort | uniq " % (edmpluginFile,line)
265  out1 = getoutput (cmd).split('\n')
266  print(line)
267  for plugin in out1:
268  if plugin:
269  print(" **"+plugin+"**")
270  print()
271 

References edm.print(), and cms::dd.split().

Variable Documentation

◆ action

duplicateReflexLibrarySearch.action

Definition at line 279 of file duplicateReflexLibrarySearch.py.

◆ args

duplicateReflexLibrarySearch.args

Definition at line 306 of file duplicateReflexLibrarySearch.py.

◆ default

duplicateReflexLibrarySearch.default

Definition at line 280 of file duplicateReflexLibrarySearch.py.

◆ dest

duplicateReflexLibrarySearch.dest

Definition at line 279 of file duplicateReflexLibrarySearch.py.

◆ dumpGroup

duplicateReflexLibrarySearch.dumpGroup

Definition at line 278 of file duplicateReflexLibrarySearch.py.

◆ equivDict

duplicateReflexLibrarySearch.equivDict

Definition at line 36 of file duplicateReflexLibrarySearch.py.

◆ help

duplicateReflexLibrarySearch.help

Definition at line 281 of file duplicateReflexLibrarySearch.py.

◆ ignoreEdmDP

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 84 of file duplicateReflexLibrarySearch.py.

◆ lostDefs

duplicateReflexLibrarySearch.lostDefs

Definition at line 310 of file duplicateReflexLibrarySearch.py.

◆ options

duplicateReflexLibrarySearch.options

Definition at line 306 of file duplicateReflexLibrarySearch.py.

◆ parser

duplicateReflexLibrarySearch.parser

Definition at line 274 of file duplicateReflexLibrarySearch.py.

◆ type

duplicateReflexLibrarySearch.type

Definition at line 296 of file duplicateReflexLibrarySearch.py.

◆ typedefsDict

duplicateReflexLibrarySearch.typedefsDict

Definition at line 18 of file duplicateReflexLibrarySearch.py.

◆ xmlGroup

duplicateReflexLibrarySearch.xmlGroup

Definition at line 277 of file duplicateReflexLibrarySearch.py.

cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:19
duplicateReflexLibrarySearch.searchClassDefXml
def searchClassDefXml()
Definition: duplicateReflexLibrarySearch.py:89
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
duplicateReflexLibrarySearch.searchDuplicatePlugins
def searchDuplicatePlugins()
Definition: duplicateReflexLibrarySearch.py:248