| 1008 | } |
| 1009 | |
| 1010 | PyObject* ApplicationPy::sListDocuments(PyObject* /*self*/, PyObject* args) |
| 1011 | { |
| 1012 | PyObject* sort = Py_False; |
| 1013 | if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &sort)) { |
| 1014 | return nullptr; |
| 1015 | } |
| 1016 | PY_TRY |
| 1017 | { |
| 1018 | PyObject* pDict = PyDict_New(); |
| 1019 | PyObject* pKey {}; |
| 1020 | Base::PyObjectBase* pValue {}; |
| 1021 | |
| 1022 | std::vector<Document*> docs = GetApplication().getDocuments(); |
| 1023 | ; |
| 1024 | if (Base::asBoolean(sort)) { |
| 1025 | docs = Document::getDependentDocuments(docs, true); |
| 1026 | } |
| 1027 | |
| 1028 | for (auto doc : docs) { |
| 1029 | pKey = PyUnicode_FromString(doc->getName()); |
| 1030 | // GetPyObject() increments |
| 1031 | pValue = static_cast<Base::PyObjectBase*>(doc->getPyObject()); |
| 1032 | PyDict_SetItem(pDict, pKey, pValue); |
| 1033 | // now we can decrement again as PyDict_SetItem also has incremented |
| 1034 | pValue->DecRef(); |
| 1035 | } |
| 1036 | |
| 1037 | return pDict; |
| 1038 | } |
| 1039 | PY_CATCH; |
| 1040 | } |
| 1041 |
nothing calls this directly
no test coverage detected