CMS 3D CMS Logo

Functions
edm::boost_python Namespace Reference

Functions

void makeParameterSets (std::string const &configtext, std::unique_ptr< edm::ParameterSet > &main)
 essentially the same as the previous method More...
 
std::unique_ptr< edm::ParameterSetreadConfig (std::string const &config)
 
std::unique_ptr< edm::ParameterSetreadConfig (std::string const &config, int argc, char *argv[])
 same, but with arguments More...
 
std::unique_ptr< edm::ParameterSetreadPSetsFrom (std::string const &fileOrString)
 

Function Documentation

void edm::boost_python::makeParameterSets ( std::string const &  configtext,
std::unique_ptr< edm::ParameterSet > &  main 
)

essentially the same as the previous method

Definition at line 55 of file MakeParameterSets.cc.

References makeParameterSets(), and PythonProcessDesc::parameterSet().

Referenced by edm::ServiceRegistry::createServicesFromConfig(), and edm::makeParameterSets().

56  {
57  PythonProcessDesc pythonProcessDesc(configtext);
58  main = pythonProcessDesc.parameterSet();
59  }
Definition: main.py:1
std::unique_ptr< edm::ParameterSet > edm::boost_python::readConfig ( std::string const &  config)

Definition at line 43 of file MakeParameterSets.cc.

References PythonProcessDesc::parameterSet(), and readConfig().

Referenced by edm::readConfig().

43  {
44  PythonProcessDesc pythonProcessDesc(config);
45  return pythonProcessDesc.parameterSet();
46  }
Definition: config.py:1
std::unique_ptr< edm::ParameterSet > edm::boost_python::readConfig ( std::string const &  config,
int  argc,
char *  argv[] 
)

same, but with arguments

Definition at line 49 of file MakeParameterSets.cc.

References PythonProcessDesc::parameterSet(), and readConfig().

Referenced by XMLConfigReader::setEventsFile().

49  {
50  PythonProcessDesc pythonProcessDesc(config, argc, argv);
51  return pythonProcessDesc.parameterSet();
52  }
Definition: config.py:1
std::unique_ptr< edm::ParameterSet > edm::boost_python::readPSetsFrom ( std::string const &  fileOrString)

finds all the PSets used in the top level module referred as a file or as a string containing python commands. These PSets are bundled into a top level PSet from which they can be retrieved

Definition at line 62 of file MakeParameterSets.cc.

References edm::python::initializeModule(), makePSetsFromFile(), makePSetsFromString(), resolutioncreator_cfi::object, PythonParameterSet::pset(), edm::pythonToCppException(), and readPSetsFrom().

Referenced by main(), MakeVersionedSelector< reco::Muon >::operator()(), and edm::readPSetsFrom().

62  {
64 
65  boost::python::object mainModule = object(handle<>(borrowed(PyImport_AddModule(const_cast<char*>("__main__")))));
66 
67  boost::python::object mainNamespace = mainModule.attr("__dict__");
68  PythonParameterSet theProcessPSet;
69  mainNamespace["topPSet"] = ptr(&theProcessPSet);
70 
71  try {
72  // if it ends with py, it's a file
73  if(module.substr(module.size()-3) == ".py") {
74  makePSetsFromFile(module,mainNamespace);
75  } else {
76  makePSetsFromString(module,mainNamespace);
77  }
78  }
79  catch( error_already_set const& ) {
80  pythonToCppException("Configuration");
81  Py_Finalize();
82  }
83  return std::make_unique<edm::ParameterSet>(ParameterSet(theProcessPSet.pset()));
84  }
static void makePSetsFromString(std::string const &module, boost::python::object &mainNamespace)
void pythonToCppException(const std::string &iType)
Definition: PythonWrapper.cc:6
edm::ParameterSet & pset()
void initializeModule()
Definition: vlib.h:208
static void makePSetsFromFile(std::string const &fileName, boost::python::object &mainNamespace)