From: Panu Matilainen Date: Wed, 23 Sep 2009 06:03:25 +0000 (+0300) Subject: Add has_key() method to header object X-Git-Tag: rpm-4.8.0-beta1~214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42810ceae18d920f40f5193cf900f1c96bca7186;p=platform%2Fupstream%2Frpm.git Add has_key() method to header object --- diff --git a/python/header-py.c b/python/header-py.c index 98d76d3..739f858 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -265,6 +265,15 @@ static PyObject *hdrIsSource(hdrObject *s) return PyBool_FromLong(headerIsSource(s->h)); } +static PyObject *hdrHasKey(hdrObject *s, PyObject *pytag) +{ + rpmTag tag = tagNumFromPyObject(pytag); + if (tag == RPMTAG_NOT_FOUND) { + return NULL; + } + return PyBool_FromLong(headerIsEntry(s->h, tag)); +} + static int hdr_compare(hdrObject * a, hdrObject * b) { return rpmVersionCompare(a->h, b->h); @@ -286,6 +295,8 @@ static struct PyMethodDef hdr_methods[] = { NULL }, {"fullFilelist", (PyCFunction) hdrFullFilelist, METH_NOARGS, NULL }, + {"has_key", (PyCFunction) hdrHasKey, METH_O, + NULL }, {"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS|METH_KEYWORDS, NULL }, {"isSource", (PyCFunction)hdrIsSource, METH_NOARGS,