Add a helper function for turning rpm problem set into python list
This commit is contained in:
parent
d910603736
commit
c4b4944e8f
|
@ -125,3 +125,15 @@ PyObject *rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob)
|
|||
return (PyObject *) s;
|
||||
}
|
||||
|
||||
PyObject *rpmps_AsList(rpmps ps)
|
||||
{
|
||||
PyObject *problems = PyList_New(0);
|
||||
rpmpsi psi = rpmpsInitIterator(ps);
|
||||
while (rpmpsNextIterator(psi) >= 0) {
|
||||
PyObject *prob = rpmprob_Wrap(&rpmProblem_Type, rpmpsGetProblem(psi));
|
||||
PyList_Append(problems, prob);
|
||||
Py_DECREF(prob);
|
||||
}
|
||||
rpmpsFreeIterator(psi);
|
||||
return problems;
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@ extern PyTypeObject rpmProblem_Type;
|
|||
|
||||
PyObject * rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob);
|
||||
|
||||
PyObject *rpmps_AsList(rpmps ps);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -517,15 +517,8 @@ rpmtsCallback(const void * hd, const rpmCallbackType what,
|
|||
static PyObject *
|
||||
rpmts_Problems(rpmtsObject * s)
|
||||
{
|
||||
PyObject *problems = PyList_New(0);
|
||||
rpmps ps = rpmtsProblems(s->ts);
|
||||
rpmpsi psi = rpmpsInitIterator(ps);
|
||||
while (rpmpsNextIterator(psi) >= 0) {
|
||||
PyObject *prob = rpmprob_Wrap(&rpmProblem_Type, rpmpsGetProblem(psi));
|
||||
PyList_Append(problems, prob);
|
||||
Py_DECREF(prob);
|
||||
}
|
||||
rpmpsFreeIterator(psi);
|
||||
PyObject *problems = rpmps_AsList(ps);
|
||||
rpmpsFree(ps);
|
||||
return problems;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue