CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Configuration/DataProcessing/python/GetScenario.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 _GetScenario_
00004 
00005 Util to retrieve a Scenario implementation
00006 Searches Impl directory for the named scenario and imports it
00007 
00008 
00009 """
00010 
00011 
00012 def getScenario(scenarioName):
00013     """
00014     _getScenario_
00015 
00016     Util to load the scenario implementation.
00017 
00018     Assumes that module exists at:
00019 
00020     Configuration.DataProcessing.Impl.<scenarioName>.py
00021     
00022     """
00023     moduleName = "Configuration.DataProcessing.Impl.%s" % scenarioName
00024     try:
00025         module = __import__(moduleName,
00026                             globals(), locals(), [scenarioName])#, -1)
00027     except ImportError, ex:
00028         msg = "Unable to load Scenario Module:\n"
00029         msg += "%s\n%s\n" % (moduleName, str(ex))
00030         raise RuntimeError, msg
00031     instance = getattr(module, scenarioName, None)
00032     if instance == None:
00033         msg = "Unable to retrieve instance of Scenario class:"
00034         msg += "%s\n From Module\n%s" % (scenarioName, moduleName)
00035     return instance()
00036 
00037