MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / getGroupInfosInternal

Function getGroupInfosInternal

Engine/AppManager.cpp:4015–4169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4013}
4014
4015static bool
4016getGroupInfosInternal(const std::string& modulePath,
4017 const std::string& pythonModule,
4018 std::string* pluginID,
4019 std::string* pluginLabel,
4020 std::string* iconFilePath,
4021 std::string* grouping,
4022 std::string* description,
4023 bool* isToolset,
4024 unsigned int* version)
4025{
4026#ifdef NATRON_RUN_WITHOUT_PYTHON
4027
4028 return false;
4029#endif
4030 PythonGILLocker pgl;
4031 static const QString script = QString::fromUtf8("import sys\n"
4032 "import %1\n"
4033 "ret = True\n"
4034 "if not hasattr(%1,\"createInstance\") or not hasattr(%1.createInstance,\"__call__\"):\n"
4035 " ret = False\n"
4036 "if not hasattr(%1,\"getLabel\") or not hasattr(%1.getLabel,\"__call__\"):\n"
4037 " ret = False\n"
4038 "templateLabel=\"\"\n"
4039 "if ret == True:\n"
4040 " templateLabel = %1.getLabel()\n"
4041 "pluginID = templateLabel\n"
4042 "version = 1\n"
4043 "isToolset = False\n"
4044 "if hasattr(%1,\"getVersion\") and hasattr(%1.getVersion,\"__call__\"):\n"
4045 " version = %1.getVersion()\n"
4046 "if hasattr(%1,\"getIsToolset\") and hasattr(%1.getIsToolset,\"__call__\"):\n"
4047 " isToolset = %1.getIsToolset()\n"
4048 "description=\"\"\n"
4049 "if hasattr(%1,\"getPluginDescription\") and hasattr(%1.getPluginDescription,\"__call__\"):\n"
4050 " description = %1.getPluginDescription()\n"
4051 "elif hasattr(%1,\"getDescription\") and hasattr(%1.getDescription,\"__call__\"):\n" // Check old function name for compat
4052 " description = %1.getDescription()\n"
4053 "if hasattr(%1,\"getPluginID\") and hasattr(%1.getPluginID,\"__call__\"):\n"
4054 " pluginID = %1.getPluginID()\n"
4055 "if ret == True and hasattr(%1,\"getIconPath\") and hasattr(%1.getIconPath,\"__call__\"):\n"
4056 " global templateIcon\n"
4057 " templateIcon = %1.getIconPath()\n"
4058 "if ret == True and hasattr(%1,\"getGrouping\") and hasattr(%1.getGrouping,\"__call__\"):\n"
4059 " global templateGrouping\n"
4060 " templateGrouping = %1.getGrouping()\n");
4061 std::string toRun = script.arg( QString::fromUtf8( pythonModule.c_str() ) ).toStdString();
4062 std::string err;
4063 if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(toRun, &err, 0) ) {
4064 QString logStr = QCoreApplication::translate("AppManager", "Was not recognized as a PyPlug: %1").arg( QString::fromUtf8( err.c_str() ) );
4065 appPTR->writeToErrorLog_mt_safe(QString::fromUtf8(pythonModule.c_str()), QDateTime::currentDateTime(), logStr);
4066
4067 return false;
4068 }
4069
4070 PyObject* mainModule = NATRON_PYTHON_NAMESPACE::getMainModule();
4071 PyObject* retObj = PyObject_GetAttrString(mainModule, "ret"); //new ref
4072 assert(retObj);

Callers 2

getGroupInfosMethod · 0.85

Calls 6

PyStringToStdStringFunction · 0.85
toStdStringMethod · 0.80
appendMethod · 0.80
emptyMethod · 0.80
translateFunction · 0.50

Tested by

no test coverage detected