MCPcopy Create free account
hub / github.com/MrKepzie/Natron / declareNodeVariableToPython

Method declareNodeVariableToPython

Engine/Node.cpp:10787–10827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10785}
10786
10787void
10788Node::declareNodeVariableToPython(const std::string& nodeName)
10789{
10790#ifdef NATRON_RUN_WITHOUT_PYTHON
10791
10792 return;
10793#endif
10794 if (getScriptName_mt_safe().empty()) {
10795 return;
10796 }
10797
10798
10799 PythonGILLocker pgl;
10800 PyObject* mainModule = appPTR->getMainModule();
10801 assert(mainModule);
10802
10803 std::string appID = getApp()->getAppIDString();
10804 std::string nodeFullName = appID + "." + nodeName;
10805 bool alreadyDefined = false;
10806 PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(nodeFullName, mainModule, &alreadyDefined);
10807 assert(nodeObj);
10808 Q_UNUSED(nodeObj);
10809
10810 if (!alreadyDefined) {
10811 std::stringstream ss;
10812 ss << nodeFullName << " = " << appID << ".getNode(\"" << nodeName << "\")\n";
10813#ifdef DEBUG
10814 ss << "if not " << nodeFullName << ":\n";
10815 ss << " print \"[BUG]: " << nodeFullName << " does not exist!\"";
10816#endif
10817 std::string script = ss.str();
10818 std::string output;
10819 std::string err;
10820 if ( !appPTR->isBackground() ) {
10821 getApp()->printAutoDeclaredVariable(script);
10822 }
10823 if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) {
10824 qDebug() << err.c_str();
10825 }
10826 }
10827}
10828
10829void
10830Node::setNodeVariableToPython(const std::string& oldName,

Callers

nothing calls this directly

Calls 6

getAppFunction · 0.85
emptyMethod · 0.80
getMainModuleMethod · 0.80
getAppIDStringMethod · 0.80
isBackgroundMethod · 0.45

Tested by

no test coverage detected