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

@@ -38,9 +38,7 @@ std::string DrawViewCollectionPy::representation(void) const
PyObject* DrawViewCollectionPy::addView(PyObject* args)
{
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
PyErr_SetString(PyExc_TypeError, "DrawViewCollectionPy::addView - Bad Arg - not DocumentObject");
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::DrawViewPy::Type), &pcDocObj)) {
return nullptr;
}
@@ -50,15 +48,13 @@ PyObject* DrawViewCollectionPy::addView(PyObject* args)
int i = collect->addView(view);
return PyLong_FromLong((long) i);
return PyLong_FromLong(i);
}
PyObject* DrawViewCollectionPy::removeView(PyObject* args)
{
PyObject *pcDocObj;
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
PyErr_SetString(PyExc_TypeError, "DrawViewCollectionPy::removeView - Bad Arg - not DocumentObject");
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::DrawViewPy::Type), &pcDocObj)) {
return nullptr;
}
@@ -68,7 +64,7 @@ PyObject* DrawViewCollectionPy::removeView(PyObject* args)
int i = collect->removeView(view);
return PyLong_FromLong((long) i);
return PyLong_FromLong(i);
}