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 self.has_key(configurable):
52 if cfg[
'lib'] != self[configurable][
'lib']:
53 log.debug(
"dup!! [%s] p=%s m=%s lib=%s", configurable, package,
55 if self._duplicates.has_key(configurable):
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 if sys.platform ==
'darwin':
120 pathlist = os.getenv(
"DYLD_LIBRARY_PATH",
"").split(os.pathsep)
122 pathlist = os.getenv(
"LD_LIBRARY_PATH",
"").split(os.pathsep)
123 for path
in pathlist:
124 if not os.path.isdir(path):
126 log.debug(
"walking in [%s]...", path)
129 path_join(path, f)
for f
in os.listdir(path)
130 if f.endswith(
'.confdb')
131 ]
if os.path.isfile(f)
134 mergedConfDbFiles = [
135 f
for f
in confDbFiles
if f.endswith(
'_merged.confdb')
137 if mergedConfDbFiles:
139 confDbFiles = mergedConfDbFiles
141 for confDb
in confDbFiles:
142 log.debug(
"\t-loading [%s]...", confDb)
144 cfgDb._loadModule(confDb)
145 except Exception
as err:
146 log.warning(
"Could not load file [%s] !", confDb)
147 log.warning(
"Reason: %s", err)
149 log.debug(
"loading confDb files... [DONE]")
150 nPkgs = len(set([k[
'package']
for k
in cfgDb.values()]))
151 log.debug(
"loaded %i confDb packages", nPkgs)
156 confClass = className
160 confClass = str.translate(confClass, _transtable)
161 except AttributeError:
163 confClass = string.translate(confClass, _transtable)
165 confClassInfo = cfgDb.get(confClass)
166 if not confClassInfo:
167 confClassInfo = cfgDb.get(confClass)
169 confMod = confClassInfo
and confClassInfo.get(
'module')
171 log.warning(
"%s: Class %s not in database", requester, className)
175 mod = __import__(confMod, globals(), locals(), confClass)
177 log.warning(
"%s: Module %s not found (needed for configurable %s)",
178 requester, confMod, className)
182 confClass = getattr(mod, confClass)
183 except AttributeError:
184 log.warning(
"%s: Configurable %s not found in module %s", requester,
188 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)