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

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

Definition at line 87 of file duplicateReflexLibrarySearch.py.

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

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

Definition at line 246 of file duplicateReflexLibrarySearch.py.

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

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

Variable Documentation

duplicateReflexLibrarySearch.action

Definition at line 277 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.args

Definition at line 304 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.default

Definition at line 278 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.dest

Definition at line 277 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.dumpGroup

Definition at line 276 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.equivDict

Definition at line 35 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.help

Definition at line 279 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 82 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.lostDefs

Definition at line 308 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.options

Definition at line 304 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.parser

Definition at line 272 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.type

Definition at line 294 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.typedefsDict

Definition at line 17 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.xmlGroup

Definition at line 275 of file duplicateReflexLibrarySearch.py.