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

Method declarePythonFields

Engine/Node.cpp:6617–6680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6615}
6616
6617void
6618Node::declarePythonFields()
6619{
6620#ifdef NATRON_RUN_WITHOUT_PYTHON
6621
6622 return;
6623#endif
6624 if (getScriptName_mt_safe().empty()) {
6625 return;
6626 }
6627 PythonGILLocker pgl;
6628
6629 if ( !getGroup() ) {
6630 return;
6631 }
6632
6633 std::locale locale;
6634 std::string nodeName;
6635 if (getIOContainer()) {
6636 nodeName = getIOContainer()->getFullyQualifiedName();
6637 } else {
6638 nodeName = getFullyQualifiedName();
6639 }
6640 std::string appID = getApp()->getAppIDString();
6641 bool alreadyDefined = false;
6642 std::string nodeFullName = appID + "." + nodeName;
6643 PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(nodeFullName, NATRON_PYTHON_NAMESPACE::getMainModule(), &alreadyDefined);
6644 assert(nodeObj);
6645 Q_UNUSED(nodeObj);
6646 if (!alreadyDefined) {
6647 qDebug() << QString::fromUtf8("declarePythonFields(): attribute ") + QString::fromUtf8( nodeFullName.c_str() ) + QString::fromUtf8(" is not defined");
6648 throw std::logic_error(std::string("declarePythonFields(): attribute ") + nodeFullName + " is not defined");
6649 }
6650
6651
6652 std::stringstream ss;
6653#ifdef DEBUG
6654 ss << "if not " << nodeFullName << ":\n";
6655 ss << " print(\"[BUG]: " << nodeFullName << " is not defined!\")\n";
6656#endif
6657 const KnobsVec& knobs = getKnobs();
6658 for (U32 i = 0; i < knobs.size(); ++i) {
6659 const std::string& knobName = knobs[i]->getName();
6660 if ( !knobName.empty() && (knobName.find(" ") == std::string::npos) && !std::isdigit(knobName[0], locale) ) {
6661 if ( PyObject_HasAttrString( nodeObj, knobName.c_str() ) ) {
6662 continue;
6663 }
6664 ss << nodeFullName << "." << knobName << " = ";
6665 ss << nodeFullName << ".getParam(\"" << knobName << "\")\n";
6666 }
6667 }
6668
6669 std::string script = ss.str();
6670 if ( !script.empty() ) {
6671 if ( !appPTR->isBackground() ) {
6672 getApp()->printAutoDeclaredVariable(script);
6673 }
6674 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