Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:31

0001 #!/usr/bin/env python3
0002 """
0003 _GetScenario_
0004 
0005 Util to retrieve a Scenario implementation
0006 Searches Impl directory for the named scenario and imports it
0007 
0008 
0009 """
0010 
0011 
0012 def getScenario(scenarioName):
0013     """
0014     _getScenario_
0015 
0016     Util to load the scenario implementation.
0017 
0018     Assumes that module exists at:
0019 
0020     Configuration.DataProcessing.Impl.<scenarioName>.py
0021     
0022     """
0023     moduleName = "Configuration.DataProcessing.Impl.%s" % scenarioName
0024     try:
0025         module = __import__(moduleName,
0026                             globals(), locals(), [scenarioName])#, -1)
0027     except ImportError as ex:
0028         msg = "Unable to load Scenario Module:\n"
0029         msg += "%s\n%s\n" % (moduleName, str(ex))
0030         raise RuntimeError(msg)
0031     instance = getattr(module, scenarioName, None)
0032     if instance == None:
0033         msg = "Unable to retrieve instance of Scenario class:"
0034         msg += "%s\n From Module\n%s" % (scenarioName, moduleName)
0035     return instance()
0036 
0037