[TD] remove Py2 code from TD

This commit is contained in:
luz paz
2021-04-21 22:06:59 -04:00
committed by wwmayer
parent 819e15a0a4
commit 1d60dbdc85
11 changed files with 0 additions and 91 deletions

View File

@@ -781,17 +781,10 @@ private:
try {
Py::Sequence list(pEdgeList);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check((*it).ptr())) {
std::string temp = PyUnicode_AsUTF8((*it).ptr());
edgeList.push_back(temp);
}
#else
if (PyString_Check((*it).ptr())) {
std::string temp = PyString_AsString((*it).ptr()); //py2 only!!!
edgeList.push_back(temp);
}
#endif
}
}
catch (Standard_Failure& e) {
@@ -829,15 +822,9 @@ private:
else {
throw Py::TypeError("expected (DrawViewPart, dimType, from, to");
}
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(pDimType) ) {
dimType = PyUnicode_AsUTF8(pDimType);
}
#else
if (PyString_Check(pDimType) ) {
dimType = PyString_AsString(pDimType);
}
#endif
if (PyObject_TypeCheck(pFrom, &(Base::VectorPy::Type))) {
from = static_cast<Base::VectorPy*>(pFrom)->value();
@@ -877,15 +864,9 @@ private:
else {
throw Py::TypeError("expected (DrawViewPart, dimType, from, to");
}
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(pDimType)) {
dimType = PyUnicode_AsUTF8(pDimType);
}
#else
if (PyString_Check(pDimType)) {
dimType = PyString_AsString(pDimType);
}
#endif
if (PyObject_TypeCheck(pFrom, &(Base::VectorPy::Type))) {
from = static_cast<Base::VectorPy*>(pFrom)->value();
}

View File

@@ -321,17 +321,10 @@ void CenterLinePy::setEdges(Py::Object arg)
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_edges = temp;
} else {
@@ -367,17 +360,10 @@ void CenterLinePy::setFaces(Py::Object arg)
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_faces = temp;
} else {
@@ -414,17 +400,10 @@ void CenterLinePy::setPoints(Py::Object arg)
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_verts = temp;
} else {

View File

@@ -44,11 +44,7 @@ PyObject* DrawPagePy::addView(PyObject* args)
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
int rc = page->addView(view);
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) rc);
#else
return PyLong_FromLong((long) rc);
#endif
}
PyObject* DrawPagePy::removeView(PyObject* args)
@@ -69,11 +65,7 @@ PyObject* DrawPagePy::removeView(PyObject* args)
int rc = page->removeView(view);
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) rc);
#else
return PyLong_FromLong((long) rc);
#endif
}
PyObject* DrawPagePy::getAllViews(PyObject* args)

View File

@@ -72,11 +72,7 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
int i = projGroup->removeProjection(projType);
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) i);
#else
return PyLong_FromLong((long) i);
#endif
}
PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/)
@@ -84,11 +80,7 @@ PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
int i = projGroup->purgeProjections();
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) i);
#else
return PyLong_FromLong((long) i);
#endif
}
PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)

View File

@@ -71,11 +71,7 @@ PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args)
}
std::string content = getDrawSVGTemplatePtr()->EditableTexts[fieldName];
if (!content.empty()) {
#if PY_MAJOR_VERSION < 3
result = PyString_FromString(content.c_str());
#else
result = PyUnicode_FromString(content.c_str());
#endif
}
return result;
}

View File

@@ -50,11 +50,7 @@ PyObject* DrawViewCollectionPy::addView(PyObject* args)
int i = collect->addView(view);
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) i);
#else
return PyLong_FromLong((long) i);
#endif
}
PyObject* DrawViewCollectionPy::removeView(PyObject* args)
@@ -72,11 +68,7 @@ PyObject* DrawViewCollectionPy::removeView(PyObject* args)
int i = collect->removeView(view);
#if PY_MAJOR_VERSION < 3
return PyInt_FromLong((long) i);
#else
return PyLong_FromLong((long) i);
#endif
}

View File

@@ -553,17 +553,10 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
int i = 0;
for ( ; i < size; i++) {
PyObject* po = PyList_GetItem(pSubs, i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(po)) {
std::string s = PyUnicode_AsUTF8(po); //py3 only!!!
subs.push_back(s);
}
#else
if (PyString_Check(po)) {
std::string s = PyString_AsString(po); //py2 only!!!
subs.push_back(s);
}
#endif
}
}
CenterLine* cl = nullptr;