Flow123d
JB_transport-9331eee
|
#include <python_loader.hh>
Public Member Functions | |
TYPEDEF_ERR_INFO (EI_PythonMessage, std::string) | |
DECLARE_EXCEPTION (ExcPythonError,<< "Python Error: "<< EI_PythonMessage::val<< "\n") | |
Static Public Member Functions | |
static void | initialize () |
static pybind11::module_ | load_module_from_file (const std::string &fname) |
static pybind11::module_ | load_module_from_string (const std::string &module_name, const std::string &func_name, const std::string &source_string) |
static pybind11::module_ | load_module_by_name (const std::string &module_name) |
static void | throw_error (const pybind11::error_already_set &ex) |
static void | add_sys_path (const std::string &path) |
static std::vector< std::string > | get_python_path () |
Class with static only members, should be used to load and compile Python sources either from file or from string. Implement correct initialization and finalization. TODO:
Definition at line 75 of file python_loader.hh.
|
static |
Add path to python sys_path.
Definition at line 148 of file python_loader.cc.
PythonLoader::DECLARE_EXCEPTION | ( | ExcPythonError | , |
<< "Python Error: "<< EI_PythonMessage::val<< "\n" | |||
) |
|
static |
Returns vector of Python paths.
Definition at line 165 of file python_loader.cc.
|
static |
Calls python initialization and guarantee that appropriate finalization will be called. Do nothing if initialization was done.
The method with no parameters is called at the beginning of every function of this class, so an explicit call to it has only sense if one would like to provide alternative python home directories. The string has form <prefix>[:<exec_prefix>] where <prefix> is prefix for platform independent libraries (namely sources of python standard libraries) and <exec_prefix> is prefix for platform dependent libraries namely for the python executable.
Definition at line 35 of file python_loader.cc.
|
static |
Method which loads module by given module_name module_name can (and probably will) contain packages path (will contain dots '.' which detonates package)
Example: PyObject * python_module = PythonLoader::load_module_by_name ("profiler.profiler_formatter_module")
will import module 'profiler_formatter_module' from package 'profiler'
Definition at line 78 of file python_loader.cc.
|
static |
This function loads a module from the given file. Resulting module has to be deallocated by Py_DECREF() macro.
Definition at line 41 of file python_loader.cc.
|
static |
This function compile code in the given string and creates a module with name module_name
. Module contains one function with name func_name
. Function must be defined in source_strimg
. Resulting module has to be deallocated by Py_DECREF() macro.
Definition at line 62 of file python_loader.cc.
|
static |
Formats and throws ExcPythonError exception.
Definition at line 93 of file python_loader.cc.
PythonLoader::TYPEDEF_ERR_INFO | ( | EI_PythonMessage | , |
std::string | |||
) |
Definition of exception thrown by python compiler or interpreter.