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

Method declarePythonFields

Engine/Node.cpp:10888–10951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10886}
10887
10888void
10889Node::declarePythonFields()
10890{
10891#ifdef NATRON_RUN_WITHOUT_PYTHON
10892
10893 return;
10894#endif
10895 if (getScriptName_mt_safe().empty()) {
10896 return;
10897 }
10898 PythonGILLocker pgl;
10899
10900 if ( !getGroup() ) {
10901 return;
10902 }
10903
10904 std::locale locale;
10905 std::string nodeName;
10906 if (getIOContainer()) {
10907 nodeName = getIOContainer()->getFullyQualifiedName();
10908 } else {
10909 nodeName = getFullyQualifiedName();
10910 }
10911 std::string appID = getApp()->getAppIDString();
10912 bool alreadyDefined = false;
10913 std::string nodeFullName = appID + "." + nodeName;
10914 PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(nodeFullName, NATRON_PYTHON_NAMESPACE::getMainModule(), &alreadyDefined);
10915 assert(nodeObj);
10916 Q_UNUSED(nodeObj);
10917 if (!alreadyDefined) {
10918 qDebug() << QString::fromUtf8("declarePythonFields(): attribute ") + QString::fromUtf8( nodeFullName.c_str() ) + QString::fromUtf8(" is not defined");
10919 throw std::logic_error(std::string("declarePythonFields(): attribute ") + nodeFullName + " is not defined");
10920 }
10921
10922
10923 std::stringstream ss;
10924#ifdef DEBUG
10925 ss << "if not " << nodeFullName << ":\n";
10926 ss << " print \"[BUG]: " << nodeFullName << " is not defined!\"\n";
10927#endif
10928 const KnobsVec& knobs = getKnobs();
10929 for (U32 i = 0; i < knobs.size(); ++i) {
10930 const std::string& knobName = knobs[i]->getName();
10931 if ( !knobName.empty() && (knobName.find(" ") == std::string::npos) && !std::isdigit(knobName[0], locale) ) {
10932 if ( PyObject_HasAttrString( nodeObj, knobName.c_str() ) ) {
10933 continue;
10934 }
10935 ss << nodeFullName << "." << knobName << " = ";
10936 ss << nodeFullName << ".getParam(\"" << knobName << "\")\n";
10937 }
10938 }
10939
10940 std::string script = ss.str();
10941 if ( !script.empty() ) {
10942 if ( !appPTR->isBackground() ) {
10943 getApp()->printAutoDeclaredVariable(script);
10944 }
10945 std::string err;

Callers 15

createDefaultReadNodeMethod · 0.45
createReadNodeMethod · 0.45
createWriteNodeMethod · 0.45
recreateUserKnobsMethod · 0.45
recreateKnobsMethod · 0.45
createIntKnobMethod · 0.45
createDoubleKnobMethod · 0.45

Calls 9

getAppFunction · 0.85
emptyMethod · 0.80
getAppIDStringMethod · 0.80
getNameMethod · 0.80
getFullyQualifiedNameMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
isBackgroundMethod · 0.45

Tested by

no test coverage detected