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 85 of file duplicateReflexLibrarySearch.py.

References cond::persistency.search().

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

Definition at line 244 of file duplicateReflexLibrarySearch.py.

References split.

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

Variable Documentation

duplicateReflexLibrarySearch.action

Definition at line 275 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.args

Definition at line 302 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.default

Definition at line 276 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.dest

Definition at line 275 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.dumpGroup

Definition at line 274 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.equivDict

Definition at line 34 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.help

Definition at line 277 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 80 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.lostDefs

Definition at line 306 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.options

Definition at line 302 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.parser

Definition at line 270 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.type

Definition at line 292 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.typedefsDict

Definition at line 16 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.xmlGroup

Definition at line 273 of file duplicateReflexLibrarySearch.py.