diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-03-13 12:28:26 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-03-13 12:28:26 +0200 |
commit | c4b4944e8f4633d564613d46c9b8b6f143b4b8f5 (patch) | |
tree | b813f46f16a3bc7a75a220ce0252e2df2678cda4 /python | |
parent | d91060373663d703457c6e1abf40b495ea372bf2 (diff) | |
download | librpm-tizen-c4b4944e8f4633d564613d46c9b8b6f143b4b8f5.tar.gz librpm-tizen-c4b4944e8f4633d564613d46c9b8b6f143b4b8f5.tar.bz2 librpm-tizen-c4b4944e8f4633d564613d46c9b8b6f143b4b8f5.zip |
Add a helper function for turning rpm problem set into python list
Diffstat (limited to 'python')
-rw-r--r-- | python/rpmps-py.c | 12 | ||||
-rw-r--r-- | python/rpmps-py.h | 2 | ||||
-rw-r--r-- | python/rpmts-py.c | 9 |
3 files changed, 15 insertions, 8 deletions
diff --git a/python/rpmps-py.c b/python/rpmps-py.c index 083e513fa..c003dd8fc 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -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; +} diff --git a/python/rpmps-py.h b/python/rpmps-py.h index 8cebb77e1..4d7efc892 100644 --- a/python/rpmps-py.h +++ b/python/rpmps-py.h @@ -11,4 +11,6 @@ extern PyTypeObject rpmProblem_Type; PyObject * rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob); +PyObject *rpmps_AsList(rpmps ps); + #endif diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 72c039b6c..bc010ec3f 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -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; } |