+ Make Python API more pythonic

This commit is contained in:
wmayer
2013-10-11 13:57:05 +02:00
parent 890d454eca
commit 4686118f2a
20 changed files with 255 additions and 256 deletions

View File

@@ -99,10 +99,10 @@ int TopoShapeWirePy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(PyList_Type), &pcObj)) {
if (PyArg_ParseTuple(args, "O", &pcObj)) {
BRepBuilderAPI_MakeWire mkWire;
Py::List list(pcObj);
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
Py::Sequence list(pcObj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& sh = static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->_Shape;
@@ -246,11 +246,11 @@ PyObject* TopoShapeWirePy::makePipeShell(PyObject *args)
int is_Frenet = 0;
int transition = 0;
if (PyArg_ParseTuple(args, "O!|iii", &(PyList_Type), &obj, &make_solid, &is_Frenet, &transition)) {
if (PyArg_ParseTuple(args, "O|iii", &obj, &make_solid, &is_Frenet, &transition)) {
try {
TopTools_ListOfShape sections;
Py::List list(obj);
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
Py::Sequence list(obj);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
const TopoDS_Shape& shape = static_cast<TopoShapePy*>((*it).ptr())->getTopoShapePtr()->_Shape;
sections.Append(shape);