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

References cond::persistency.search().

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

duplicateReflexLibrarySearch.help

Definition at line 277 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 79 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 15 of file duplicateReflexLibrarySearch.py.

duplicateReflexLibrarySearch.xmlGroup

Definition at line 273 of file duplicateReflexLibrarySearch.py.