Remove unused function RunPythonMethodWithReturnedString

pcbnewRunPythonMethodWithReturnedString already exists
This commit is contained in:
Roberto Fernandez Bautista 2024-03-30 14:49:46 +01:00
parent 79a3dd71e4
commit 9957c58c14
1 changed files with 0 additions and 66 deletions

View File

@ -336,72 +336,6 @@ bool SCRIPTING::scriptingSetup()
}
/**
* Run a python method from the Pcbnew module.
*
* @param aMethodName is the name of the method (like "pcbnew.myfunction" )
* @param aNames will contain the returned string
*/
static void RunPythonMethodWithReturnedString( const char* aMethodName, wxString& aNames )
{
aNames.Clear();
PyLOCK lock;
PyErr_Clear();
PyObject* builtins = PyImport_ImportModule( "pcbnew" );
wxASSERT( builtins );
if( !builtins ) // Something is wrong in pcbnew.py module (incorrect version?)
return;
PyObject* globals = PyDict_New();
PyDict_SetItemString( globals, "pcbnew", builtins );
Py_DECREF( builtins );
// Build the python code
std::string cmd = "result = " + std::string( aMethodName ) + "()";
// Execute the python code and get the returned data
PyObject* localDict = PyDict_New();
PyObject* pobj = PyRun_String( cmd.c_str(), Py_file_input, globals, localDict );
Py_DECREF( globals );
if( pobj )
{
PyObject* str = PyDict_GetItemString(localDict, "result" );
const char* str_res = nullptr;
if(str)
{
PyObject* temp_bytes = PyUnicode_AsEncodedString( str, "UTF-8", "strict" );
if( temp_bytes != nullptr )
{
str_res = PyBytes_AS_STRING( temp_bytes );
aNames = From_UTF8( str_res );
Py_DECREF( temp_bytes );
}
else
{
wxLogMessage( wxS( "cannot encode Unicode python string" ) );
}
}
else
{
aNames = wxString();
}
Py_DECREF( pobj );
}
Py_DECREF( localDict );
if( PyErr_Occurred() )
wxLogMessage( PyErrStringWithTraceback() );
}
wxString PyEscapeString( const wxString& aSource )
{
wxString converted;