00001
00002
00003
00004
00005
00006 import string
00007
00008
00009
00010 __version__ = '5.0.0'
00011 __author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'
00012
00013 __all__ = [ 'Algorithm', 'Service', 'AlgTool' ]
00014
00015
00016 from Logging import logging
00017 log = logging.getLogger( 'OldStyleConfig' )
00018
00019
00020 def _compatLookup( name, klass ):
00021 parts = string.split( name, '/' )
00022 if (len(parts) > 2) :
00023 msg = 'invalid argument name = "%s", must be of the form "type[/name]"' % name
00024 log.error( msg )
00025 raise RuntimeError( msg )
00026
00027 import ConfigurableDb
00028 cls = ConfigurableDb.getConfigurable( parts[0] )
00029 if not cls or not issubclass( cls, klass ):
00030 msg = 'unable to locate configurable for type "%s"' % parts[0]
00031 log.error( msg )
00032 raise TypeError( msg )
00033
00034 if len(parts) == 1:
00035 return cls()
00036 else:
00037 return cls(parts[1])
00038
00039 _algConfigurables = {}
00040 def Algorithm( name ):
00041 import Configurable
00042 result = _compatLookup( name, Configurable.ConfigurableAlgorithm )
00043 if result:
00044 global _algConfigurables
00045 _algConfigurables[ name ] = result
00046 return result
00047
00048 Algorithm.configurables = _algConfigurables
00049
00050
00051 _svcConfigurables = {}
00052 def Service( name ):
00053 import Configurable
00054 result = _compatLookup( name, Configurable.ConfigurableService )
00055 if result:
00056 global _svcConfigurables
00057 _svcConfigurables[ name ] = result
00058 return result
00059
00060 Service.configurables = _svcConfigurables
00061
00062
00063 _atlConfigurables = {}
00064 def AlgTool( name ):
00065 import Configurable
00066 result = _compatLookup( name, Configurable.ConfigurableAlgTool )
00067 if result:
00068 global _atlConfigurables
00069 _atlConfigurables[ name ] = result
00070 return result
00071
00072 AlgTool.configurabls = _atlConfigurables