| 73 | } |
| 74 | |
| 75 | static PyObject* PythonSave( PyObject* self, PyObject* args, bool async ) |
| 76 | { |
| 77 | TriTextureRes* pThis = BluePythonCast<TriTextureRes*>( self ); |
| 78 | |
| 79 | PyObject* file = nullptr; |
| 80 | |
| 81 | if( !PyArg_ParseTuple( args, "O", &file ) ) |
| 82 | { |
| 83 | PyErr_SetString( PyExc_TypeError, "Expected a filepath string" ); |
| 84 | return nullptr; |
| 85 | } |
| 86 | |
| 87 | std::wstring wcstr; |
| 88 | std::string cstr; |
| 89 | bool OK = false; |
| 90 | if( PyUnicode_Check( file ) && BlueExtractArgument( file, wcstr, 1 ) ) |
| 91 | { |
| 92 | if( async ) |
| 93 | { |
| 94 | OK = pThis->SaveAsync( wcstr.c_str() ); |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | OK = pThis->Save( wcstr.c_str() ); |
| 99 | } |
| 100 | } |
| 101 | #if PY_MAJOR_VERSION == 2 |
| 102 | else if( PyString_Check( file ) && BlueExtractArgument( file, cstr, 1 ) ) |
| 103 | { |
| 104 | if( async ) |
| 105 | { |
| 106 | OK = pThis->SaveAsync( CA2W( cstr.c_str() ) ); |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | OK = pThis->Save( CA2W( cstr.c_str() ) ); |
| 111 | } |
| 112 | } |
| 113 | #endif |
| 114 | else |
| 115 | { |
| 116 | PyErr_SetString( PyExc_TypeError, "Expected a filepath string" ); |
| 117 | return nullptr; |
| 118 | } |
| 119 | |
| 120 | return PyBool_FromLong( OK ); |
| 121 | } |
no test coverage detected