From 644401875d02f4fad5e8e5a004aa9bd08153ba84 Mon Sep 17 00:00:00 2001 From: jbj Date: Fri, 9 Aug 2002 23:14:10 +0000 Subject: - python: include instance in IDTXload, filename in IDTXglob, return - python: argument to ts.addErase (if integer) deletes that instance. - python: rpmmi methods to return this instance, and number of members. CVS patchset: 5620 CVS date: 2002/08/09 23:14:10 --- python/rpmmi-py.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'python/rpmmi-py.c') diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 17ee71a09..24f5d0d2a 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -119,6 +119,42 @@ rpmmi_Next(rpmmiObject * s, PyObject *args) return result; } +/** + */ +static PyObject * +rpmmi_Instance(rpmmiObject * s, PyObject * args) + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ +{ + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Instance")) + return NULL; + + if (s->mi) + rc = rpmdbGetIteratorOffset(s->mi); + + return Py_BuildValue("i", rc); +} + +/** + */ +static PyObject * +rpmmi_Count(rpmmiObject * s, PyObject * args) + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ +{ + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Instance")) + return NULL; + + if (s->mi) + rc = rpmdbGetIteratorCount(s->mi); + + return Py_BuildValue("i", rc); +} + /** */ static PyObject * @@ -154,6 +190,10 @@ static struct PyMethodDef rpmmi_methods[] = { {"next", (PyCFunction) rpmmi_Next, METH_VARARGS, "mi.next() -> hdr\n\ - Retrieve next header that matches. Iterate directly in python if possible.\n" }, + {"instance", (PyCFunction) rpmmi_Instance, METH_VARARGS, + NULL }, + {"count", (PyCFunction) rpmmi_Count, METH_VARARGS, + NULL }, {"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS, "mi.pattern(TagN, mire_type, pattern)\n\ - Set a secondary match pattern on tags from retrieved header.\n" }, -- cgit v1.2.3