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

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

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

◆ searchDuplicatePlugins()

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

Definition at line 247 of file duplicateReflexLibrarySearch.py.

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

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

Variable Documentation

◆ action

duplicateReflexLibrarySearch.action

Definition at line 278 of file duplicateReflexLibrarySearch.py.

◆ args

duplicateReflexLibrarySearch.args

Definition at line 305 of file duplicateReflexLibrarySearch.py.

◆ default

duplicateReflexLibrarySearch.default

Definition at line 279 of file duplicateReflexLibrarySearch.py.

◆ dest

duplicateReflexLibrarySearch.dest

Definition at line 278 of file duplicateReflexLibrarySearch.py.

◆ dumpGroup

duplicateReflexLibrarySearch.dumpGroup

Definition at line 277 of file duplicateReflexLibrarySearch.py.

◆ equivDict

duplicateReflexLibrarySearch.equivDict

Definition at line 32 of file duplicateReflexLibrarySearch.py.

◆ help

duplicateReflexLibrarySearch.help

Definition at line 280 of file duplicateReflexLibrarySearch.py.

◆ ignoreEdmDP

duplicateReflexLibrarySearch.ignoreEdmDP

Definition at line 83 of file duplicateReflexLibrarySearch.py.

◆ lostDefs

duplicateReflexLibrarySearch.lostDefs

Definition at line 309 of file duplicateReflexLibrarySearch.py.

◆ options

duplicateReflexLibrarySearch.options

Definition at line 305 of file duplicateReflexLibrarySearch.py.

◆ parser

duplicateReflexLibrarySearch.parser

Definition at line 273 of file duplicateReflexLibrarySearch.py.

◆ type

duplicateReflexLibrarySearch.type

Definition at line 295 of file duplicateReflexLibrarySearch.py.

◆ typedefsDict

duplicateReflexLibrarySearch.typedefsDict

Definition at line 14 of file duplicateReflexLibrarySearch.py.

◆ xmlGroup

duplicateReflexLibrarySearch.xmlGroup

Definition at line 276 of file duplicateReflexLibrarySearch.py.