PyObject *rpmtd_AsPyobj(rpmtd td) { PyObject *res = NULL; int array = (rpmTagGetReturnType(td->tag) == RPM_ARRAY_RETURN_TYPE); rpmTagClass tclass = rpmtdClass(td); if (!array && rpmtdCount(td) < 1) { Py_RETURN_NONE; } if (array) { int ix; res = PyList_New(rpmtdCount(td)); if (!res) { return NULL; } while ((ix = rpmtdNext(td)) >= 0) { PyObject *item = rpmtd_ItemAsPyobj(td, tclass); if (!item) { Py_DECREF(res); return NULL; } PyList_SET_ITEM(res, ix, item); } } else { res = rpmtd_ItemAsPyobj(td, tclass); } return res; }
PyObject *rpmtd_AsPyobj(rpmtd td) { PyObject *res = NULL; rpmTagType type = rpmTagGetType(rpmtdTag(td)); int array = ((type & RPM_MASK_RETURN_TYPE) == RPM_ARRAY_RETURN_TYPE); if (!array && rpmtdCount(td) < 1) { Py_RETURN_NONE; } if (array) { res = PyList_New(0); if (!res) { return NULL; } while (rpmtdNext(td) >= 0) { PyList_Append(res, rpmtd_ItemAsPyobj(td)); } } else { res = rpmtd_ItemAsPyobj(td); } return res; }