|
Gaudi Framework, version v21r11 |
| Home | Generated: 30 Sep 2010 |
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 | |
| def ConfigurableDb::getConfigurable | ( | className, | ||
requester = '', |
||||
assumeCxxClass = True | ||||
| ) |
Definition at line 143 of file ConfigurableDb.py.
00143 : 00144 confClass=className 00145 if assumeCxxClass: 00146 # assume className is C++: --> translate to python 00147 confClass = string.translate( confClass, _transtable ) 00148 # see if I have it in my dictionary 00149 confClassInfo = cfgDb.get(confClass) 00150 if not confClassInfo: 00151 confClassInfo = cfgDb.get(confClass) 00152 # get the python module 00153 confMod = confClassInfo and confClassInfo.get('module') 00154 if not confMod: 00155 log.warning( "%s: Class %s not in database", requester, className ) 00156 return None 00157 # load the module 00158 try: 00159 mod = __import__(confMod,globals(),locals(),confClass) 00160 except ImportError: 00161 log.warning( "%s: Module %s not found (needed for configurable %s)", 00162 requester, confMod, className ) 00163 return None 00164 # get the class 00165 try: 00166 confClass = getattr(mod,confClass) 00167 except AttributeError: 00168 log.warning( "%s: Configurable %s not found in module %s", 00169 requester, confClass, confMod ) 00170 return None 00171 # Got it! 00172 log.debug( "%s: Found configurable %s in module %s", 00173 requester, confClass, confMod ) 00174 00175 return confClass return confClass
| def 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.
00092 : 00093 """Helper function to load all ConfigurableDb files (modules) holding 00094 informations about Configurables 00095 """ 00096 import os 00097 import sys 00098 from zipfile import is_zipfile, ZipFile 00099 from glob import glob 00100 from os.path import join as path_join 00101 log.debug( "importing confDb packages..." ) 00102 nFiles = 0 # counter of imported files 00103 for path in sys.path: 00104 log.debug( "walking in [%s]..." % path ) 00105 if not os.path.exists(path): 00106 continue 00107 # speed-up: <project>_merged_confDb.py files are installed as : 00108 # "/some/path/InstallArea/[<CMTCONFIG>/]python/<project>_merged_confDb.py" 00109 # so why bother wandering in other directories ? 00110 if "InstallArea" in path: 00111 if is_zipfile(path): 00112 # turn filename syntax into module syntax: remove path+extension and replace / with . (dot) 00113 confDbModules = [ os.path.splitext(f)[0].replace('/','.') 00114 for f in ZipFile(path).namelist() 00115 if f.endswith("_merged_confDb.py") or f.endswith("_merged_confDb.pyc") ] 00116 else: 00117 # turn filename syntax into module syntax: remove path+extension and replace / with . (dot) 00118 confDbModules = [ os.path.splitext( f[len(path)+1:] )[0].replace(os.sep,'.') 00119 for f in glob(path_join(path, "*_merged_confDb.py")) 00120 if os.path.isfile(f) ] 00121 else: 00122 continue 00123 for confDbModule in confDbModules: 00124 nFiles += 1 00125 log.debug( "\t-importing [%s]..." % confDbModule ) 00126 try: 00127 mod = __import__( confDbModule ) 00128 except ImportError, err: 00129 log.warning( "Could not import module [%s] !", confDbModule ) 00130 log.warning( "Reason: %s", err ) 00131 pass 00132 else: 00133 # don't need to keep the module 00134 del mod 00135 pass 00136 pass # loop over sys.path 00137 log.debug( "importing confDb packages... [DONE]" ) 00138 nPkgs = len( set([k['package'] for k in cfgDb.values()]) ) 00139 log.debug( "imported %i confDb packages" % nPkgs ) 00140 return nFiles 00141 00142 def getConfigurable( className, requester='', assumeCxxClass=True ):
| list ConfigurableDb::__all__ = [ 'CfgDb', 'cfgDb', 'loadConfigurableDb', 'getConfigurable' ] |
Definition at line 10 of file ConfigurableDb.py.
| tuple ConfigurableDb::_transtable = string.maketrans('<>&*,: ().', '__rp__s___') |
Definition at line 13 of file ConfigurableDb.py.
| tuple ConfigurableDb::cfgDb = CfgDb() |
| tuple ConfigurableDb::CfgDb = _Singleton() |
Definition at line 82 of file ConfigurableDb.py.
| tuple ConfigurableDb::log = logging.getLogger( 'ConfigurableDb' ) |
Definition at line 16 of file ConfigurableDb.py.