summaryrefslogtreecommitdiff
path: root/python/rpmts-py.c
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2009-12-15 13:15:10 +0100
committerFlorian Festi <ffesti@redhat.com>2010-10-21 10:32:20 +0200
commit5914d0ec2995d4f4d128c3e96b79f22ec8f48d64 (patch)
tree32cf33c6ca6a04f465cf803d714761ea935f50e8 /python/rpmts-py.c
parenta916e399ab0734816f1e4567b34db0b55e9f5c7c (diff)
downloadlibrpm-tizen-5914d0ec2995d4f4d128c3e96b79f22ec8f48d64.tar.gz
librpm-tizen-5914d0ec2995d4f4d128c3e96b79f22ec8f48d64.tar.bz2
librpm-tizen-5914d0ec2995d4f4d128c3e96b79f22ec8f48d64.zip
rpmdbKeyIterator: loop over keys in the database indexes
Diffstat (limited to 'python/rpmts-py.c')
-rw-r--r--python/rpmts-py.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 16a824318..13bb3aa58 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -12,6 +12,7 @@
#include "rpmkeyring-py.h"
#include "rpmfi-py.h" /* XXX for rpmfiNew */
#include "rpmmi-py.h"
+#include "rpmki-py.h"
#include "rpmps-py.h"
#include "rpmte-py.h"
@@ -628,6 +629,31 @@ exit:
Py_XDECREF(str);
return mio;
}
+static PyObject *
+rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds)
+{
+ rpmTag tag;
+ PyObject *mio = NULL;
+ char * kwlist[] = {"tag", "pattern", "type", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:Keys", kwlist,
+ tagNumFromPyObject, &tag))
+ return NULL;
+
+ /* XXX If not already opened, open the database O_RDONLY now. */
+ if (rpmtsGetRdb(s->ts) == NULL) {
+ int rc = rpmtsOpenDB(s->ts, O_RDONLY);
+ if (rc || rpmtsGetRdb(s->ts) == NULL) {
+ PyErr_SetString(pyrpmError, "rpmdb open failed");
+ goto exit;
+ }
+ }
+
+ mio = rpmki_Wrap(&rpmki_Type, rpmdbKeyIteratorInit(rpmtsGetRdb(s->ts), tag), (PyObject*)s);
+
+exit:
+ return mio;
+}
static struct PyMethodDef rpmts_methods[] = {
{"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS,
@@ -681,6 +707,9 @@ static struct PyMethodDef rpmts_methods[] = {
{"dbMatch", (PyCFunction) rpmts_Match, METH_VARARGS|METH_KEYWORDS,
"ts.dbMatch([TagN, [key]]) -> mi\n\
- Create a match iterator for the default transaction rpmdb.\n" },
+ {"dbKeys", (PyCFunction) rpmts_Keys, METH_VARARGS|METH_KEYWORDS,
+"ts.dbKeys(TagN) -> ki\n\
+-Create a key iterator for the default transaction rpmdb.\n" },
{NULL, NULL} /* sentinel */
};