CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GetScenario.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """
3 _GetScenario_
4 
5 Util to retrieve a Scenario implementation
6 Searches Impl directory for the named scenario and imports it
7 
8 
9 """
10 
11 
12 def getScenario(scenarioName):
13  """
14  _getScenario_
15 
16  Util to load the scenario implementation.
17 
18  Assumes that module exists at:
19 
20  Configuration.DataProcessing.Impl.<scenarioName>.py
21 
22  """
23  moduleName = "Configuration.DataProcessing.Impl.%s" % scenarioName
24  try:
25  module = __import__(moduleName,
26  globals(), locals(), [scenarioName])#, -1)
27  except ImportError as ex:
28  msg = "Unable to load Scenario Module:\n"
29  msg += "%s\n%s\n" % (moduleName, str(ex))
30  raise RuntimeError(msg)
31  instance = getattr(module, scenarioName, None)
32  if instance == None:
33  msg = "Unable to retrieve instance of Scenario class:"
34  msg += "%s\n From Module\n%s" % (scenarioName, moduleName)
35  return instance()
36 
37 
static PFTauRenderPlugin instance
def getScenario
Definition: GetScenario.py:12
#define str(s)