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 285 of file Tools/PyUtils/python/Dso.py.

Constructor & Destructor Documentation

◆ __init__()

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

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

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

Member Function Documentation

◆ __buildRepository()

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

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

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

◆ __dups()

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

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

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

◆ __str__()

def python.Dso.PyDsoDb.__str__ (   self)

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

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

◆ _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 473 of file Tools/PyUtils/python/Dso.py.

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

◆ _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 466 of file Tools/PyUtils/python/Dso.py.

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

◆ capabilities()

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

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

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

◆ content()

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

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

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

◆ dictDuplicates()

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

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

417  def dictDuplicates(self, pedantic = False):
418  return self.__dups(self.db, pedantic)
419 

◆ duplicates()

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

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

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

◆ libs()

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

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

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

◆ pfDuplicates()

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

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

420  def pfDuplicates(self, pedantic = False):
421  return self.__dups(self.pf, pedantic)
422 

Member Data Documentation

◆ db

python.Dso.PyDsoDb.db

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

◆ dsoFiles

python.Dso.PyDsoDb.dsoFiles

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

◆ DsoMap

python.Dso.PyDsoDb.DsoMap
static

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

◆ dsoPath

python.Dso.PyDsoDb.dsoPath

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

◆ msg

python.Dso.PyDsoDb.msg

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

◆ name

python.Dso.PyDsoDb.name

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

◆ pf

python.Dso.PyDsoDb.pf

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

◆ PluginNamespace

python.Dso.PyDsoDb.PluginNamespace
static

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

◆ RootMap

python.Dso.PyDsoDb.RootMap
static

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


The documentation for this class was generated from the following file:
checkPlugins.capabilities
capabilities
Definition: checkPlugins.py:139
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:50
python.AthDsoLogger.fct
fct
Definition: AthDsoLogger.py:43
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:218
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:224
python.Dso._to_rflx_name
def _to_rflx_name(typename)
Definition: Tools/PyUtils/python/Dso.py:255
python.Dso._libName
def _libName(lib)
Definition: Tools/PyUtils/python/Dso.py:17
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:790
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
generateReferenceFile.duplicates
duplicates
Definition: generateReferenceFile.py:24