| 4169 | } // getGroupInfosInternal |
| 4170 | |
| 4171 | static |
| 4172 | bool |
| 4173 | getGroupInfosFromQtResourceFile(const std::string& resourceFileName, |
| 4174 | const std::string& modulePath, |
| 4175 | const std::string& pythonModule, |
| 4176 | std::string* pluginID, |
| 4177 | std::string* pluginLabel, |
| 4178 | std::string* iconFilePath, |
| 4179 | std::string* grouping, |
| 4180 | std::string* description, |
| 4181 | bool* isToolset, |
| 4182 | unsigned int* version) |
| 4183 | { |
| 4184 | ///Must be locked |
| 4185 | assert( PyThreadState_Get() ); |
| 4186 | |
| 4187 | QString qModulePath = QString::fromUtf8( resourceFileName.c_str() ); |
| 4188 | |
| 4189 | assert( qModulePath.startsWith( QString::fromUtf8(":/Resources") ) ); |
| 4190 | |
| 4191 | QFile moduleContent(qModulePath); |
| 4192 | if ( !moduleContent.open(QIODevice::ReadOnly | QIODevice::Text) ) { |
| 4193 | return false; |
| 4194 | } |
| 4195 | |
| 4196 | QByteArray utf8bytes = QString::fromUtf8( pythonModule.c_str() ).toUtf8(); |
| 4197 | char *moduleName = utf8bytes.data(); |
| 4198 | PyObject* moduleCode = Py_CompileString(moduleContent.readAll().constData(), moduleName, Py_file_input); |
| 4199 | if (!moduleCode) { |
| 4200 | return false; |
| 4201 | } |
| 4202 | PyObject* module = PyImport_ExecCodeModule(moduleName, moduleCode); |
| 4203 | if (!module) { |
| 4204 | return false; |
| 4205 | } |
| 4206 | |
| 4207 | //Now that the module is loaded, use the regular version |
| 4208 | return getGroupInfosInternal(modulePath, pythonModule, pluginID, pluginLabel, iconFilePath, grouping, description, isToolset, version); |
| 4209 | //PyDict_SetItemString(priv->globals, moduleName, module); |
| 4210 | } |
| 4211 | |
| 4212 | bool |
| 4213 | NATRON_PYTHON_NAMESPACE::getGroupInfos(const std::string& modulePath, |
no test coverage detected