3 """A singleton holding informations on the whereabouts of all the automatically 4 generated Configurables. 5 This repository of (informations on) Configurables is used by the PropertyProxy 6 class to locate Configurables and feed the JobOptionsSvc. It could also be used 7 to feed the AthenaEmacs module...""" 9 __all__ = [
'CfgDb',
'cfgDb',
'loadConfigurableDb',
'getConfigurable']
13 _transtable = str.maketrans(
'<>&*,: ().',
'__rp__s___')
14 except AttributeError:
16 _transtable = string.maketrans(
'<>&*,: ().',
'__rp__s___')
19 log = logging.getLogger(
'ConfigurableDb')
24 A singleton class holding informations about automatically generated 26 --> package holding that Configurable 27 --> library holding the components related to that Configurable 28 --> python module holding the Configurable 29 --> a dictionary of duplicates 40 def add(self, configurable, package, module, lib):
41 """Method to populate the Db. 42 It is called from the auto-generated Xyz_confDb.py files (genconf.cpp) 43 @param configurable: the name of the configurable being added 44 @param package: the name of the package which holds this Configurable 45 @param module: the name of the python module holding the Configurable 46 @param lib: the name of the library holding the component(s) (ie: the 47 C++ Gaudi component which is mapped by the Configurable) 49 cfg = {
'package': package,
'module': module,
'lib': lib}
50 if configurable
in self:
52 if cfg[
'lib'] != self[configurable][
'lib']:
53 log.debug(
"dup!! [%s] p=%s m=%s lib=%s", configurable, package,
60 log.debug(
"added [%s] p=%s m=%s lib=%s", configurable, package,
62 self[configurable] = cfg
69 for i, ll
in enumerate(f):
71 if l.startswith(
'#')
or len(l) <= 0:
76 pkg = line[0].split(
'.')[0]
79 self.
add(cname, pkg, module, lib)
83 "invalid line format: %s:%d: %r" % (fname, i + 1, ll))
110 """Helper function to load all ConfigurableDb files (modules) holding 111 informations about Configurables 115 from glob
import glob
116 from os.path
import join
as path_join
117 log.debug(
"loading confDb files...")
119 pathlist = os.getenv(
"LD_LIBRARY_PATH",
"").split(os.pathsep)
120 for path
in pathlist:
121 if not os.path.isdir(path):
123 log.debug(
"walking in [%s]...", path)
126 path_join(path, f)
for f
in os.listdir(path)
127 if f.endswith(
'.confdb')
128 ]
if os.path.isfile(f)
131 mergedConfDbFiles = [
132 f
for f
in confDbFiles
if f.endswith(
'_merged.confdb')
134 if mergedConfDbFiles:
136 confDbFiles = mergedConfDbFiles
138 for confDb
in confDbFiles:
139 log.debug(
"\t-loading [%s]...", confDb)
141 cfgDb._loadModule(confDb)
142 except Exception
as err:
143 log.warning(
"Could not load file [%s] !", confDb)
144 log.warning(
"Reason: %s", err)
146 log.debug(
"loading confDb files... [DONE]")
147 nPkgs = len(set([k[
'package']
for k
in cfgDb.values()]))
148 log.debug(
"loaded %i confDb packages", nPkgs)
153 confClass = className
157 confClass = str.translate(confClass, _transtable)
158 except AttributeError:
160 confClass = string.translate(confClass, _transtable)
162 confClassInfo = cfgDb.get(confClass)
163 if not confClassInfo:
164 confClassInfo = cfgDb.get(confClass)
166 confMod = confClassInfo
and confClassInfo.get(
'module')
168 log.warning(
"%s: Class %s not in database", requester, className)
172 mod = __import__(confMod, globals(), locals(), confClass)
174 log.warning(
"%s: Module %s not found (needed for configurable %s)",
175 requester, confMod, className)
179 confClass = getattr(mod, confClass)
180 except AttributeError:
181 log.warning(
"%s: Configurable %s not found in module %s", requester,
185 log.debug(
"%s: Found configurable %s in module %s", requester, confClass,
def _loadModule(self, fname)
def add(self, configurable, package, module, lib)
def getConfigurable(className, requester='', assumeCxxClass=True)