| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

OldStyleConfig.py

Go to the documentation of this file.
00001 # Stolen from:
00002 # File: AthenaCommon/python/OldStyleConfig.py
00003 # Author: Wim Lavrijsen (WLavrijsen@lbl.gov)
00004 # Incorporated to Daya Bay by bv@bnl.gov Thu Sep 18 12:16:02 2008
00005 
00006 import string
00007 
00008 
00009 ### data ---------------------------------------------------------------------
00010 __version__ = '5.0.0'
00011 __author__  = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'
00012 
00013 __all__ = [ 'Algorithm', 'Service', 'AlgTool' ]
00014 
00015 ## for messaging
00016 from Logging import logging
00017 log = logging.getLogger( 'OldStyleConfig' )
00018 
00019 ### old style configuration is now disallowed; forward if possible, or FATAL
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
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:13:00 2011 for DybPython by doxygen 1.4.7