Skip to content
Snippets Groups Projects
Commit f290b4ad authored by Wim Lavrijsen's avatar Wim Lavrijsen
Browse files

allow user options in addition to python module

git-svn-id: http://root.cern.ch/svn/root/trunk@46806 27541ba8-7e3a-0410-8455-c3a389f83636
parent b73a2eff
No related branches found
No related tags found
No related merge requests found
...@@ -72,7 +72,16 @@ void TPySelector::SetupPySelf() ...@@ -72,7 +72,16 @@ void TPySelector::SetupPySelf()
if ( fPySelf && fPySelf != Py_None ) if ( fPySelf && fPySelf != Py_None )
return; // already created ... return; // already created ...
TString impst = TString::Format( "import %s", GetOption() ); // split option as needed for the module part and the (optional) user part
std::string opt = GetOption();
std::string::size_type pos = opt.find( '#' );
std::string module = opt.substr( 0, pos );
std::string user = (pos == std::string::npos) ? "" : opt.substr( pos+1, std::string::npos );
TString impst = TString::Format( "import %s", module.c_str() );
// reset user option
SetOption( user.c_str() );
// use TPython to ensure that the interpreter is initialized // use TPython to ensure that the interpreter is initialized
if ( ! TPython::Exec( (const char*)impst ) ) { if ( ! TPython::Exec( (const char*)impst ) ) {
...@@ -86,7 +95,7 @@ void TPySelector::SetupPySelf() ...@@ -86,7 +95,7 @@ void TPySelector::SetupPySelf()
const_cast< char* >( "TPySelector" ) ); const_cast< char* >( "TPySelector" ) );
// get handle to the module // get handle to the module
PyObject* pymod = PyImport_AddModule( const_cast< char* >( GetOption() ) ); PyObject* pymod = PyImport_AddModule( const_cast< char* >( module.c_str() ) );
// get the module dictionary to loop over // get the module dictionary to loop over
PyObject* dict = PyModule_GetDict( pymod ); PyObject* dict = PyModule_GetDict( pymod );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment