TechDraw: Improve and clean up code in some Python classes

This commit is contained in:
marioalexis
2022-11-10 13:07:13 -03:00
committed by WandererFan
parent 1349a7120a
commit 232b27517c
7 changed files with 54 additions and 74 deletions

View File

@@ -45,14 +45,10 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
{
const char* fileSpec;
if (!PyArg_ParseTuple(args, "s", &fileSpec)) {
throw Py::TypeError("** dumpSymbol bad args.");
}
auto dvs = getDrawViewSymbolPtr();
std::string symbolRepr;
if (dvs) {
symbolRepr = dvs->Symbol.getValue();
return nullptr;
}
std::string symbolRepr = getDrawViewSymbolPtr()->Symbol.getValue();
Base::FileInfo fi(fileSpec);
Base::ofstream outfile;
outfile.open(fi);
@@ -63,8 +59,10 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
} else {
std::string error = std::string("Can't write ");
error += fileSpec;
throw Py::RuntimeError(error);
PyErr_SetString(PyExc_RuntimeError, error.c_str());
return nullptr;
}
Py_Return;
}