ATLAS Offline Software
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
python.Dso.PyDsoDb Class Reference
Inheritance diagram for python.Dso.PyDsoDb:
Collaboration diagram for python.Dso.PyDsoDb:

Public Member Functions

def __init__ (self, name="DsoDb")
 
def __str__ (self)
 
def duplicates (self, libName, pedantic=False)
 
def dictDuplicates (self, pedantic=False)
 
def pfDuplicates (self, pedantic=False)
 
def capabilities (self, libName)
 
def libs (self, detailedDump=False)
 
def content (self, pedantic)
 

Public Attributes

 name
 
 db
 
 pf
 
 msg
 
 dsoPath
 
 dsoFiles
 

Static Public Attributes

 RootMap
 
 DsoMap
 
 PluginNamespace
 

Private Member Functions

def __buildRepository (self)
 
def __dups (self, db, pedantic)
 
def _to_rootmap_name (self, typename)
 
def _to_rflx_name (self, typename)
 

Detailed Description

The repository of 'rootmap' files (location, content,...)

Definition at line 283 of file Tools/PyUtils/python/Dso.py.

Constructor & Destructor Documentation

◆ __init__()

def python.Dso.PyDsoDb.__init__ (   self,
  name = "DsoDb" 
)

Definition at line 291 of file Tools/PyUtils/python/Dso.py.

291  def __init__(self, name = "DsoDb"):
292  object.__init__(self)
293  self.name = name
294  self.db = { } # repository of components
295  self.pf = { } # repository of known components to the plugin svc
296 
297  import PyUtils.Logging as _L
298  self.msg = _L.logging.getLogger('DsoDb')
299 
300  self.dsoPath = os.environ['LD_LIBRARY_PATH']
301  self.__buildRepository()
302  return
303 

Member Function Documentation

◆ __buildRepository()

def python.Dso.PyDsoDb.__buildRepository (   self)
private

Definition at line 304 of file Tools/PyUtils/python/Dso.py.

304  def __buildRepository(self):
305  msg = self.msg
306  self.dsoFiles = set()
307  dsoPath = [p for p in self.dsoPath.split( os.pathsep )
308  if not p.startswith(os.environ['ROOTSYS'])]
309  for path in dsoPath:
310  if not os.path.exists(path): continue
311  dir_content = None
312  try:
313  dir_content = os.listdir(path)
314  except Exception:
315  # try again...
316  try:
317  dir_content = os.listdir(path)
318  except Exception as err:
319  msg.warning("caught:\n%s", err)
320  if dir_content is None:
321  msg.warning("could not run os.listdir on [%s]", path)
322  dir_content = []
323  dsoFiles = [ f for f in dir_content
324  if f.endswith(self.RootMap) ]
325  for dsoFile in dsoFiles:
326  dsoFile = os.path.join( path, dsoFile )
327  if os.path.exists(dsoFile):
328  line_nbr = -1
329  self.dsoFiles.add(dsoFile)
330  for line in open(dsoFile, 'r'):
331  line_nbr += 1
332  line = line.strip()
333  if len(line) <= 0 or line[0] == "#":
334  continue
335  line = line.split()
336  # Note that as of LCG-55, rootmaps have the following
337  # format: 'symbol': libDict.so [listOfLinkedLibs.so...]
338  # we are only interested in libDict.so...
339  try:
340  dsoKey, libName = line[0], line[1]
341  except Exception as err:
342  msg.warning(
343  'could not parse %s:%i', dsoFile, line_nbr
344  )
345  msg.warning(
346  '(some) reflex-dicts may fail to be auto-loaded'
347  )
348  msg.warning(err)
349  continue
350  dsoKey = dsoKey\
351  .replace("Library.", "")\
352  .replace( ":", "" )\
353  .replace( "@", ":" )\
354  .replace( "-", " " )
355  if dsoKey.startswith( self.PluginNamespace ):
356  db = self.pf
357  else:
358  db = self.db
359  if dsoKey not in db: db[dsoKey] = list()
360  if _is_rootcint_dict (libName):
361  #print "## discarding [%s]..." % libName
362  continue
363  libName = os.path.join(path, _libName(libName))
364  db[dsoKey].append(libName)
365  pass # loop over dso-lines
366  pass # loop over dsoFiles
367  pass # iter over dsoPath
368  return
369 

◆ __dups()

def python.Dso.PyDsoDb.__dups (   self,
  db,
  pedantic 
)
private

Definition at line 382 of file Tools/PyUtils/python/Dso.py.

382  def __dups(self, db, pedantic):
383  dups = {}
384  for k in db.keys():
385  if len(db[k]) == 1: continue
386  if pedantic: libs = db[k]
387  else:
388  baseLibs = set()
389  libs = []
390  for lib in db[k]:
391  if os.path.basename(lib) not in baseLibs:
392  libs.append(lib)
393  baseLibs.add(os.path.basename(lib))
394  pass
395  pass
396  if len(libs) > 1:
397  dups[k] = [ lib for lib in libs ]
398  return dups
399 

◆ __str__()

def python.Dso.PyDsoDb.__str__ (   self)

Definition at line 370 of file Tools/PyUtils/python/Dso.py.

370  def __str__(self):
371  s = os.linesep.join( [
372  "+--- %s ---" % self.name,
373  "|nbr of lib components: %i" % len(self.db.keys()),
374  "|nbr of pf components: %i" % len(self.pf.keys()),
375  "|nbr of dso files: %i" % len(self.dsoFiles),
376  "|nbr of known libs: %i" % len(self.libs()),
377  "+-------------------------"
378  ] )
379 
380  return s
381 

◆ _to_rflx_name()

def python.Dso.PyDsoDb._to_rflx_name (   self,
  typename 
)
private
helper method to massage a typename into something understandable
by reflex (which doesn't understand the same thing than rootmaps).

Definition at line 471 of file Tools/PyUtils/python/Dso.py.

471  def _to_rflx_name (self, typename):
472  """helper method to massage a typename into something understandable
473  by reflex (which doesn't understand the same thing than rootmaps).
474  """
475  return _to_rflx_name(typename)
476 

◆ _to_rootmap_name()

def python.Dso.PyDsoDb._to_rootmap_name (   self,
  typename 
)
private
helper method to massage a typename into something understandable
by the rootmap files

Definition at line 464 of file Tools/PyUtils/python/Dso.py.

464  def _to_rootmap_name(self, typename):
465  """
466  helper method to massage a typename into something understandable
467  by the rootmap files
468  """
469  return _to_rootmap_name(typename)
470 

◆ capabilities()

def python.Dso.PyDsoDb.capabilities (   self,
  libName 
)

Definition at line 421 of file Tools/PyUtils/python/Dso.py.

421  def capabilities(self, libName):
422  libName = _libName(libName)
423  caps = set()
424  for db in [self.db, self.pf]:
425  for k in db.keys():
426  if libName in [ os.path.basename(lib) for lib in db[k] ]:
427  caps.add( k )
428  caps = [ cap for cap in caps ]
429  caps.sort()
430  if len(caps) == 0:
431  print ("::: ERROR: No such library [%s] in dsoDb !!" % libName)
432  raise ValueError ("")
433  return caps
434 

◆ content()

def python.Dso.PyDsoDb.content (   self,
  pedantic 
)

Definition at line 447 of file Tools/PyUtils/python/Dso.py.

447  def content(self, pedantic):
448  d = {}
449  for db in [self.pf, self.db]:
450  for k in db.keys():
451  if pedantic: libs = db[k]
452  else:
453  baseLibs = set()
454  libs = []
455  for lib in db[k]:
456  if os.path.basename(lib) not in baseLibs:
457  libs.append(lib)
458  baseLibs.add(os.path.basename(lib))
459  pass
460  pass
461  d[k] = [ lib for lib in libs ]
462  return d
463 

◆ dictDuplicates()

def python.Dso.PyDsoDb.dictDuplicates (   self,
  pedantic = False 
)

Definition at line 415 of file Tools/PyUtils/python/Dso.py.

415  def dictDuplicates(self, pedantic = False):
416  return self.__dups(self.db, pedantic)
417 

◆ duplicates()

def python.Dso.PyDsoDb.duplicates (   self,
  libName,
  pedantic = False 
)

Definition at line 400 of file Tools/PyUtils/python/Dso.py.

400  def duplicates(self, libName, pedantic = False):
401  caps = self.capabilities(libName)
402  dups = {}
403  for dupDb in [ self.dictDuplicates(pedantic),
404  self.pfDuplicates(pedantic) ]:
405  for k in dupDb:
406  if k in caps:
407  if k not in dups: dups[k] = []
408  dups[k] += [ lib for lib in dupDb[k]
409  if libName not in os.path.basename(lib) ]
410  dups.keys().sort()
411  for k in dups.keys():
412  dups[k].sort()
413  return dups
414 

◆ libs()

def python.Dso.PyDsoDb.libs (   self,
  detailedDump = False 
)

Definition at line 435 of file Tools/PyUtils/python/Dso.py.

435  def libs(self, detailedDump = False):
436  if detailedDump: fct = lambda x : x
437  else: fct = os.path.basename
438  libs = set()
439  for db in [self.pf, self.db]:
440  for k in db.keys():
441  for lib in db[k]:
442  libs.add(fct(lib))
443  libs = [ lib for lib in libs ]
444  libs.sort()
445  return libs
446 

◆ pfDuplicates()

def python.Dso.PyDsoDb.pfDuplicates (   self,
  pedantic = False 
)

Definition at line 418 of file Tools/PyUtils/python/Dso.py.

418  def pfDuplicates(self, pedantic = False):
419  return self.__dups(self.pf, pedantic)
420 

Member Data Documentation

◆ db

python.Dso.PyDsoDb.db

Definition at line 294 of file Tools/PyUtils/python/Dso.py.

◆ dsoFiles

python.Dso.PyDsoDb.dsoFiles

Definition at line 306 of file Tools/PyUtils/python/Dso.py.

◆ DsoMap

python.Dso.PyDsoDb.DsoMap
static

Definition at line 288 of file Tools/PyUtils/python/Dso.py.

◆ dsoPath

python.Dso.PyDsoDb.dsoPath

Definition at line 300 of file Tools/PyUtils/python/Dso.py.

◆ msg

python.Dso.PyDsoDb.msg

Definition at line 298 of file Tools/PyUtils/python/Dso.py.

◆ name

python.Dso.PyDsoDb.name

Definition at line 293 of file Tools/PyUtils/python/Dso.py.

◆ pf

python.Dso.PyDsoDb.pf

Definition at line 295 of file Tools/PyUtils/python/Dso.py.

◆ PluginNamespace

python.Dso.PyDsoDb.PluginNamespace
static

Definition at line 289 of file Tools/PyUtils/python/Dso.py.

◆ RootMap

python.Dso.PyDsoDb.RootMap
static

Definition at line 287 of file Tools/PyUtils/python/Dso.py.


The documentation for this class was generated from the following file:
checkPlugins.capabilities
capabilities
Definition: checkPlugins.py:137
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
LArG4ShowerLibProcessing.libs
list libs
Definition: LArG4ShowerLibProcessing.py:49
python.AthDsoLogger.fct
fct
Definition: AthDsoLogger.py:42
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
grepfile.content
string content
Definition: grepfile.py:56
python.Dso._to_rootmap_name
def _to_rootmap_name(typename)
Definition: Tools/PyUtils/python/Dso.py:216
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.Dso._to_rflx_name
def _to_rflx_name(typename)
Definition: Tools/PyUtils/python/Dso.py:253
python.Dso._libName
def _libName(lib)
Definition: Tools/PyUtils/python/Dso.py:15
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
generateReferenceFile.duplicates
duplicates
Definition: generateReferenceFile.py:24