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

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

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

◆ searchDuplicatePlugins()

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

Definition at line 249 of file duplicateReflexLibrarySearch.py.

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

References print(), and submitPVValidationJobs.split().

Variable Documentation

◆ action

duplicateReflexLibrarySearch.action

Definition at line 280 of file duplicateReflexLibrarySearch.py.

◆ args

duplicateReflexLibrarySearch.args

Definition at line 307 of file duplicateReflexLibrarySearch.py.

◆ default

duplicateReflexLibrarySearch.default

Definition at line 281 of file duplicateReflexLibrarySearch.py.

◆ dest

duplicateReflexLibrarySearch.dest

Definition at line 280 of file duplicateReflexLibrarySearch.py.

◆ dumpGroup

duplicateReflexLibrarySearch.dumpGroup

Definition at line 279 of file duplicateReflexLibrarySearch.py.

◆ equivDict

duplicateReflexLibrarySearch.equivDict

Definition at line 36 of file duplicateReflexLibrarySearch.py.

◆ help

duplicateReflexLibrarySearch.help

Definition at line 282 of file duplicateReflexLibrarySearch.py.

◆ ignoreEdmDP

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 85 of file duplicateReflexLibrarySearch.py.

◆ lostDefs

duplicateReflexLibrarySearch.lostDefs

Definition at line 311 of file duplicateReflexLibrarySearch.py.

◆ options

duplicateReflexLibrarySearch.options

Definition at line 307 of file duplicateReflexLibrarySearch.py.

◆ parser

duplicateReflexLibrarySearch.parser

Definition at line 275 of file duplicateReflexLibrarySearch.py.

◆ type

duplicateReflexLibrarySearch.type

Definition at line 297 of file duplicateReflexLibrarySearch.py.

◆ typedefsDict

duplicateReflexLibrarySearch.typedefsDict

Definition at line 18 of file duplicateReflexLibrarySearch.py.

◆ xmlGroup

duplicateReflexLibrarySearch.xmlGroup

Definition at line 278 of file duplicateReflexLibrarySearch.py.

submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
duplicateReflexLibrarySearch.searchClassDefXml
def searchClassDefXml()
Definition: duplicateReflexLibrarySearch.py:90
duplicateReflexLibrarySearch.searchDuplicatePlugins
def searchDuplicatePlugins()
Definition: duplicateReflexLibrarySearch.py:249