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']
12 _transtable = string.maketrans(
'<>&*,: ().',
'__rp__s___')
15 log = logging.getLogger(
'ConfigurableDb')
20 A singleton class holding informations about automatically generated 22 --> package holding that Configurable 23 --> library holding the components related to that Configurable 24 --> python module holding the Configurable 25 --> a dictionary of duplicates 36 def add(self, configurable, package, module, lib):
37 """Method to populate the Db. 38 It is called from the auto-generated Xyz_confDb.py files (genconf.cpp) 39 @param configurable: the name of the configurable being added 40 @param package: the name of the package which holds this Configurable 41 @param module: the name of the python module holding the Configurable 42 @param lib: the name of the library holding the component(s) (ie: the 43 C++ Gaudi component which is mapped by the Configurable) 45 cfg = {
'package': package,
'module': module,
'lib': lib}
46 if self.has_key(configurable):
48 if cfg[
'lib'] != self[configurable][
'lib']:
49 log.debug(
"dup!! [%s] p=%s m=%s lib=%s", configurable, package,
51 if self._duplicates.has_key(configurable):
56 log.debug(
"added [%s] p=%s m=%s lib=%s", configurable, package,
58 self[configurable] = cfg
65 for i, ll
in enumerate(f):
67 if l.startswith(
'#')
or len(l) <= 0:
72 pkg = line[0].split(
'.')[0]
75 self.
add(cname, pkg, module, lib)
79 "invalid line format: %s:%d: %r" % (fname, i + 1, ll))
106 """Helper function to load all ConfigurableDb files (modules) holding 107 informations about Configurables 111 from glob
import glob
112 from os.path
import join
as path_join
113 log.debug(
"loading confDb files...")
115 if sys.platform ==
'darwin':
116 pathlist = os.getenv(
"DYLD_LIBRARY_PATH",
"").split(os.pathsep)
118 pathlist = os.getenv(
"LD_LIBRARY_PATH",
"").split(os.pathsep)
119 for path
in pathlist:
120 if not os.path.isdir(path):
122 log.debug(
"walking in [%s]...", path)
125 path_join(path, f)
for f
in os.listdir(path)
126 if f.endswith(
'.confdb')
127 ]
if os.path.isfile(f)
130 mergedConfDbFiles = [
131 f
for f
in confDbFiles
if f.endswith(
'_merged.confdb')
133 if mergedConfDbFiles:
135 confDbFiles = mergedConfDbFiles
137 for confDb
in confDbFiles:
138 log.debug(
"\t-loading [%s]...", confDb)
140 cfgDb._loadModule(confDb)
141 except Exception, err:
142 log.warning(
"Could not load file [%s] !", confDb)
143 log.warning(
"Reason: %s", err)
145 log.debug(
"loading confDb files... [DONE]")
146 nPkgs = len(set([k[
'package']
for k
in cfgDb.values()]))
147 log.debug(
"loaded %i confDb packages", nPkgs)
152 confClass = className
155 confClass = string.translate(confClass, _transtable)
157 confClassInfo = cfgDb.get(confClass)
158 if not confClassInfo:
159 confClassInfo = cfgDb.get(confClass)
161 confMod = confClassInfo
and confClassInfo.get(
'module')
163 log.warning(
"%s: Class %s not in database", requester, className)
167 mod = __import__(confMod, globals(), locals(), confClass)
169 log.warning(
"%s: Module %s not found (needed for configurable %s)",
170 requester, confMod, className)
174 confClass = getattr(mod, confClass)
175 except AttributeError:
176 log.warning(
"%s: Configurable %s not found in module %s", requester,
180 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)