|
Packit Service |
7203c3 |
#include "rpmsystem-py.h"
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
#include "rpmps-py.h"
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
struct rpmProblemObject_s {
|
|
Packit Service |
7203c3 |
PyObject_HEAD
|
|
Packit Service |
7203c3 |
PyObject *md_dict;
|
|
Packit Service |
7203c3 |
rpmProblem prob;
|
|
Packit Service |
7203c3 |
};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static char rpmprob_doc[] =
|
|
Packit Service |
7203c3 |
"";
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_type(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
return Py_BuildValue("i", rpmProblemGetType(s->prob));
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_pkgnevr(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
d188d8 |
return utf8FromString(rpmProblemGetPkgNEVR(s->prob));
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_altnevr(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
d188d8 |
return utf8FromString(rpmProblemGetAltNEVR(s->prob));
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_key(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
fnpyKey key = rpmProblemGetKey(s->prob);
|
|
Packit Service |
7203c3 |
if (key) {
|
|
Packit Service |
7203c3 |
return Py_BuildValue("O", rpmProblemGetKey(s->prob));
|
|
Packit Service |
7203c3 |
} else {
|
|
Packit Service |
7203c3 |
Py_RETURN_NONE;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_str(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
d188d8 |
return utf8FromString(rpmProblemGetStr(s->prob));
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_get_num(rpmProblemObject *s, void *closure)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
return Py_BuildValue("L", rpmProblemGetDiskNeed(s->prob));
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyGetSetDef rpmprob_getseters[] = {
|
|
Packit Service |
7203c3 |
{ "type", (getter)rpmprob_get_type, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ "pkgNEVR", (getter)rpmprob_get_pkgnevr, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ "altNEVR", (getter)rpmprob_get_altnevr, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ "key", (getter)rpmprob_get_key, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ "_str", (getter)rpmprob_get_str, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ "_num", (getter)rpmprob_get_num, NULL, NULL },
|
|
Packit Service |
7203c3 |
{ NULL }
|
|
Packit Service |
7203c3 |
};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static PyObject *rpmprob_str(rpmProblemObject *s)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
char *str = rpmProblemString(s->prob);
|
|
Packit Service |
d188d8 |
PyObject *res = utf8FromString(str);
|
|
Packit Service |
7203c3 |
free(str);
|
|
Packit Service |
7203c3 |
return res;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
static void rpmprob_dealloc(rpmProblemObject *s)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
s->prob = rpmProblemFree(s->prob);
|
|
Packit Service |
7203c3 |
Py_TYPE(s)->tp_free((PyObject *)s);
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyTypeObject rpmProblem_Type = {
|
|
Packit Service |
7203c3 |
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
Packit Service |
7203c3 |
"rpm.prob", /* tp_name */
|
|
Packit Service |
7203c3 |
sizeof(rpmProblemObject), /* tp_basicsize */
|
|
Packit Service |
7203c3 |
0, /* tp_itemsize */
|
|
Packit Service |
7203c3 |
/* methods */
|
|
Packit Service |
7203c3 |
(destructor)rpmprob_dealloc, /* tp_dealloc */
|
|
Packit Service |
7203c3 |
0, /* tp_print */
|
|
Packit Service |
7203c3 |
(getattrfunc)0, /* tp_getattr */
|
|
Packit Service |
7203c3 |
(setattrfunc)0, /* tp_setattr */
|
|
Packit Service |
7203c3 |
0, /* tp_compare */
|
|
Packit Service |
7203c3 |
(reprfunc)0, /* tp_repr */
|
|
Packit Service |
7203c3 |
0, /* tp_as_number */
|
|
Packit Service |
7203c3 |
0, /* tp_as_sequence */
|
|
Packit Service |
7203c3 |
0, /* tp_as_mapping */
|
|
Packit Service |
7203c3 |
(hashfunc)0, /* tp_hash */
|
|
Packit Service |
7203c3 |
(ternaryfunc)0, /* tp_call */
|
|
Packit Service |
7203c3 |
(reprfunc)rpmprob_str, /* tp_str */
|
|
Packit Service |
7203c3 |
PyObject_GenericGetAttr, /* tp_getattro */
|
|
Packit Service |
7203c3 |
PyObject_GenericSetAttr, /* tp_setattro */
|
|
Packit Service |
7203c3 |
0, /* tp_as_buffer */
|
|
Packit Service |
7203c3 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
|
Packit Service |
7203c3 |
rpmprob_doc, /* tp_doc */
|
|
Packit Service |
7203c3 |
0, /* tp_traverse */
|
|
Packit Service |
7203c3 |
0, /* tp_clear */
|
|
Packit Service |
7203c3 |
(richcmpfunc)0, /* tp_richcompare */
|
|
Packit Service |
7203c3 |
0, /* tp_weaklistoffset */
|
|
Packit Service |
7203c3 |
0, /* tp_iter */
|
|
Packit Service |
7203c3 |
0, /* tp_iternext */
|
|
Packit Service |
7203c3 |
0, /* tp_methods */
|
|
Packit Service |
7203c3 |
0, /* tp_members */
|
|
Packit Service |
7203c3 |
rpmprob_getseters, /* tp_getset */
|
|
Packit Service |
7203c3 |
0, /* tp_base */
|
|
Packit Service |
7203c3 |
0, /* tp_dict */
|
|
Packit Service |
7203c3 |
0, /* tp_descr_get */
|
|
Packit Service |
7203c3 |
0, /* tp_descr_set */
|
|
Packit Service |
7203c3 |
0, /* tp_dictoffset */
|
|
Packit Service |
7203c3 |
0, /* tp_init */
|
|
Packit Service |
7203c3 |
0, /* tp_alloc */
|
|
Packit Service |
7203c3 |
(newfunc)0, /* tp_new */
|
|
Packit Service |
7203c3 |
0, /* tp_free */
|
|
Packit Service |
7203c3 |
0, /* tp_is_gc */
|
|
Packit Service |
7203c3 |
};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyObject *rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
rpmProblemObject * s = (rpmProblemObject *)subtype->tp_alloc(subtype, 0);
|
|
Packit Service |
7203c3 |
if (s == NULL) return NULL;
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
s->prob = rpmProblemLink(prob);
|
|
Packit Service |
7203c3 |
return (PyObject *) s;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyObject *rpmps_AsList(rpmps ps)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
PyObject *problems;
|
|
Packit Service |
7203c3 |
rpmpsi psi;
|
|
Packit Service |
7203c3 |
rpmProblem prob;
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
problems = PyList_New(0);
|
|
Packit Service |
7203c3 |
if (!problems) {
|
|
Packit Service |
7203c3 |
return NULL;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
psi = rpmpsInitIterator(ps);
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
while ((prob = rpmpsiNext(psi))) {
|
|
Packit Service |
7203c3 |
PyObject *pyprob = rpmprob_Wrap(&rpmProblem_Type, prob);
|
|
Packit Service |
7203c3 |
if (!pyprob) {
|
|
Packit Service |
7203c3 |
Py_DECREF(problems);
|
|
Packit Service |
7203c3 |
rpmpsFreeIterator(psi);
|
|
Packit Service |
7203c3 |
return NULL;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
PyList_Append(problems, pyprob);
|
|
Packit Service |
7203c3 |
Py_DECREF(pyprob);
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
rpmpsFreeIterator(psi);
|
|
Packit Service |
7203c3 |
return problems;
|
|
Packit Service |
7203c3 |
}
|