diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-09-23 12:28:47 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-09-23 12:28:47 +0300 |
commit | 282efb6d4c23848b2443ffd767fd4bccda209425 (patch) | |
tree | 260228978fa8df28e77c0912e47562b3956002ed /python/rpmds-py.c | |
parent | ac219c129d04952fbd205c536533723d582d1ad2 (diff) | |
download | librpm-tizen-282efb6d4c23848b2443ffd767fd4bccda209425.tar.gz librpm-tizen-282efb6d4c23848b2443ffd767fd4bccda209425.tar.bz2 librpm-tizen-282efb6d4c23848b2443ffd767fd4bccda209425.zip |
Turn tagNumFromPyObject() into an object converter interface
- permits direct validation and conversion from arg parsing
Diffstat (limited to 'python/rpmds-py.c')
-rw-r--r-- | python/rpmds-py.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/python/rpmds-py.c b/python/rpmds-py.c index fe0e164a5..7514bdd24 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -428,20 +428,15 @@ static void rpmds_free(rpmdsObject * s) static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { hdrObject * ho = NULL; - PyObject * to = NULL; rpmTag tagN = RPMTAG_REQUIRENAME; rpmsenseFlags flags = 0; rpmds ds = NULL; char * kwlist[] = {"header", "tag", "flags", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|Oi:rpmds_new", kwlist, - &hdr_Type, &ho, &to, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|O&i:rpmds_new", kwlist, + &hdr_Type, &ho, tagNumFromPyObject, &tagN, &flags)) return NULL; - if (to != NULL) { - tagN = tagNumFromPyObject(to); - if (tagN == RPMTAG_NOT_FOUND) return NULL; - } ds = rpmdsNew(hdrGetHeader(ho), tagN, 0); return rpmds_Wrap(ds); @@ -515,21 +510,16 @@ PyObject * rpmds_Wrap(rpmds ds) PyObject * rpmds_Single(PyObject * s, PyObject * args, PyObject * kwds) { - PyObject * to = NULL; rpmTag tagN = RPMTAG_PROVIDENAME; const char * N; const char * EVR = NULL; rpmsenseFlags Flags = 0; char * kwlist[] = {"to", "name", "evr", "flags", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "Os|si:Single", kwlist, - &to, &N, &EVR, &Flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&s|si:Single", kwlist, + tagNumFromPyObject, &tagN, &N, &EVR, &Flags)) return NULL; - if (to != NULL) { - tagN = tagNumFromPyObject(to); - if (tagN == RPMTAG_NOT_FOUND) return NULL; - } return rpmds_Wrap( rpmdsSingle(tagN, N, EVR, Flags) ); } |