| 1025 | } |
| 1026 | |
| 1027 | PyObject* DocumentPy::getTempFileName(PyObject* args) |
| 1028 | { |
| 1029 | PyObject* value; |
| 1030 | if (!PyArg_ParseTuple(args, "O", &value)) { |
| 1031 | return nullptr; |
| 1032 | } |
| 1033 | |
| 1034 | std::string string; |
| 1035 | if (PyUnicode_Check(value)) { |
| 1036 | string = PyUnicode_AsUTF8(value); |
| 1037 | } |
| 1038 | else { |
| 1039 | std::string error = std::string("type must be a string!"); |
| 1040 | error += value->ob_type->tp_name; |
| 1041 | throw Py::TypeError(error); |
| 1042 | } |
| 1043 | |
| 1044 | // search for a temp file name in the document transient directory |
| 1045 | Base::FileInfo fileName( |
| 1046 | Base::FileInfo::getTempFileName(string.c_str(), getDocumentPtr()->TransientDir.getValue())); |
| 1047 | // delete the created file, we need only the name... |
| 1048 | fileName.deleteFile(); |
| 1049 | |
| 1050 | PyObject* p = |
| 1051 | PyUnicode_DecodeUTF8(fileName.filePath().c_str(), fileName.filePath().size(), nullptr); |
| 1052 | if (!p) { |
| 1053 | throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()"); |
| 1054 | } |
| 1055 | return p; |
| 1056 | } |
| 1057 | |
| 1058 | PyObject* DocumentPy::getCustomAttributes(const char* attr) const |
| 1059 | { |
nothing calls this directly
no test coverage detected