| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
GaudiKernel.ConfigurableDb Namespace Reference

## Classes
class | _CfgDb
class | _Singleton

## Functions
def | loadConfigurableDb
| Helper function to load all ConfigurableDb files holding informations.
def | getConfigurable

## Variables
list | __all__ [ 'CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable' ]
tuple | _transtable string.maketrans('<>&*,: ().', '__rp__s___')
tuple | log logging.getLogger( 'ConfigurableDb' )
tuple | CfgDb _Singleton()
tuple | cfgDb CfgDb()
| default name for CfgDb instance

## Function Documentation

def GaudiKernel.ConfigurableDb.getConfigurable | ( |  | className,
|  |  | requester = `''`,
|  |  | assumeCxxClass = `True`
| ) |  |

Definition at line 137 of file ConfigurableDb.py.

137
138 def getConfigurable( className, requester='', assumeCxxClass=True ):
139 confClass=className
140 if assumeCxxClass:
141 # assume className is C++: --> translate to python
142 confClass = string.translate( confClass, _transtable )
143 # see if I have it in my dictionary
144 confClassInfo = cfgDb.get(confClass)
145 if not confClassInfo:
146 confClassInfo = cfgDb.get(confClass)
147 # get the python module
148 confMod = confClassInfo and confClassInfo.get('module')
149 if not confMod:
150 log.warning( "%s: Class %s not in database", requester, className )
151 return None
152 # load the module
153 try:
154 mod = __import__(confMod,globals(),locals(),confClass)
155 except ImportError:
156 log.warning( "%s: Module %s not found (needed for configurable %s)",
157 requester, confMod, className )
158 return None
159 # get the class
160 try:
161 confClass = getattr(mod,confClass)
162 except AttributeError:
163 log.warning( "%s: Configurable %s not found in module %s",
164 requester, confClass, confMod )
165 return None
166 # Got it!
167 log.debug( "%s: Found configurable %s in module %s",
168 requester, confClass, confMod )
169
170 return confClass

def GaudiKernel.ConfigurableDb.loadConfigurableDb | ( |  | ) |

Helper function to load all ConfigurableDb files holding informations.

    Helper function to load all ConfigurableDb files (modules) holding
    informations about Configurables

Definition at line 92 of file ConfigurableDb.py.

92
93 def loadConfigurableDb():
94 """Helper function to load all ConfigurableDb files (modules) holding
95 informations about Configurables
96 """
97 import os
98 import sys
99 from zipfile import is_zipfile, ZipFile
100 from glob import glob
101 from os.path import join as path_join
102 log.debug( "importing confDb packages..." )
103 nFiles = 0 # counter of imported files
104 for path in sys.path:
105 log.debug( "walking in [%s]..." % path )
106 if not os.path.exists(path):
107 continue
108 if is_zipfile(path):
109 # turn filename syntax into module syntax: remove path+extension and replace / with . (dot)
110 confDbModules = [ os.path.splitext(f)[0].replace('/','.')
111 for f in ZipFile(path).namelist()
112 if f.endswith("_merged_confDb.py") or f.endswith("_merged_confDb.pyc") ]
113 else:
114 # turn filename syntax into module syntax: remove path+extension and replace / with . (dot)
115 confDbModules = [ os.path.splitext( f[len(path)+1:] )[0].replace(os.sep,'.')
116 for f in glob(path_join(path, "*_merged_confDb.py"))
117 if os.path.isfile(f) ]
118 for confDbModule in confDbModules:
119 nFiles += 1
120 log.debug( "\t-importing [%s]..." % confDbModule )
121 try:
122 mod = __import__( confDbModule )
123 except ImportError, err:
124 log.warning( "Could not import module [%s] !", confDbModule )
125 log.warning( "Reason: %s", err )
126 pass
127 else:
128 # don't need to keep the module
129 del mod
130 pass
131 pass # loop over sys.path
132 log.debug( "importing confDb packages... [DONE]" )
133 nPkgs = len( set([k['package'] for k in cfgDb.values()]) )
134 log.debug( "imported %i confDb packages" % nPkgs )
135 return nFiles
136

## Variable Documentation

list GaudiKernel.ConfigurableDb.__all__ [ 'CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable' ]

Definition at line 10 of file ConfigurableDb.py.

tuple GaudiKernel.ConfigurableDb._transtable string.maketrans('<>&*,: ().', '__rp__s___')

Definition at line 13 of file ConfigurableDb.py.

tuple GaudiKernel.ConfigurableDb.CfgDb _Singleton()

Definition at line 82 of file ConfigurableDb.py.

tuple GaudiKernel.ConfigurableDb.cfgDb CfgDb()

default name for CfgDb instance

Definition at line 89 of file ConfigurableDb.py.

tuple GaudiKernel.ConfigurableDb.log logging.getLogger( 'ConfigurableDb' )

Definition at line 16 of file ConfigurableDb.py.