ATLAS Offline Software
Loading...
Searching...
No Matches
python.Dso.PyDsoDb Class Reference
Inheritance diagram for python.Dso.PyDsoDb:
Collaboration diagram for python.Dso.PyDsoDb:

Public Member Functions

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

Public Attributes

 name = name
dict db = { }
dict pf = { }
 msg = _L.logging.getLogger('DsoDb')
 dsoPath = os.environ['LD_LIBRARY_PATH']
 dsoFiles = set()

Static Public Attributes

str RootMap = "rootmap"
str DsoMap = "dsomap"
str PluginNamespace = "__pf__"

Protected Member Functions

 _to_rootmap_name (self, typename)
 _to_rflx_name (self, typename)

Private Member Functions

 __buildRepository (self)
 __dups (self, db, pedantic)

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __init__()

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

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

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

Member Function Documentation

◆ __buildRepository()

python.Dso.PyDsoDb.__buildRepository ( self)
private

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

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

◆ __dups()

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

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

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

◆ __str__()

python.Dso.PyDsoDb.__str__ ( self)

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

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

◆ _to_rflx_name()

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

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

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

◆ _to_rootmap_name()

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

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

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

◆ capabilities()

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

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

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

◆ content()

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

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

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

◆ dictDuplicates()

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

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

413 def dictDuplicates(self, pedantic = False):
414 return self.__dups(self.db, pedantic)
415

◆ duplicates()

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

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

398 def duplicates(self, libName, pedantic = False):
399 caps = self.capabilities(libName)
400 dups = {}
401 for dupDb in [ self.dictDuplicates(pedantic),
402 self.pfDuplicates(pedantic) ]:
403 for k in dupDb:
404 if k in caps:
405 if k not in dups: dups[k] = []
406 dups[k] += [ lib for lib in dupDb[k]
407 if libName not in os.path.basename(lib) ]
408 dups.keys().sort()
409 for k in dups.keys():
410 dups[k].sort()
411 return dups
412
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ libs()

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

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

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

◆ pfDuplicates()

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

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

416 def pfDuplicates(self, pedantic = False):
417 return self.__dups(self.pf, pedantic)
418

Member Data Documentation

◆ db

python.Dso.PyDsoDb.db = { }

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

◆ dsoFiles

python.Dso.PyDsoDb.dsoFiles = set()

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

◆ DsoMap

str python.Dso.PyDsoDb.DsoMap = "dsomap"
static

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

◆ dsoPath

python.Dso.PyDsoDb.dsoPath = os.environ['LD_LIBRARY_PATH']

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

◆ msg

python.Dso.PyDsoDb.msg = _L.logging.getLogger('DsoDb')

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

◆ name

python.Dso.PyDsoDb.name = name

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

◆ pf

python.Dso.PyDsoDb.pf = { }

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

◆ PluginNamespace

python.Dso.PyDsoDb.PluginNamespace = "__pf__"
static

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

◆ RootMap

str python.Dso.PyDsoDb.RootMap = "rootmap"
static

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


The documentation for this class was generated from the following file: