diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-09-28 17:23:28 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-09-28 17:23:28 +0300 |
commit | ac3f9f729b9a3b938d3344278c7e0564934f3871 (patch) | |
tree | 5caffa8e5f80e97c88856e4b4e03dbd56a7d6834 | |
parent | f74def684253964fa03edb55f155dfbb5122b1bf (diff) | |
download | librpm-tizen-ac3f9f729b9a3b938d3344278c7e0564934f3871.tar.gz librpm-tizen-ac3f9f729b9a3b938d3344278c7e0564934f3871.tar.bz2 librpm-tizen-ac3f9f729b9a3b938d3344278c7e0564934f3871.zip |
Support numeric expansion in rpm.expandMacro()
-rw-r--r-- | python/rpmmacro-py.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/python/rpmmacro-py.c b/python/rpmmacro-py.c index ec99e189e..660bd00e4 100644 --- a/python/rpmmacro-py.c +++ b/python/rpmmacro-py.c @@ -40,15 +40,21 @@ rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds) PyObject * rpmmacro_ExpandMacro(PyObject * self, PyObject * args, PyObject * kwds) { - char *macro, *str; + char *macro; PyObject *res; + int num = 0; + char * kwlist[] = {"macro", "numeric", NULL}; - if (!PyArg_ParseTuple(args, "s", ¯o)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, ¯o, &num)) return NULL; - str = rpmExpand(macro, NULL); - res = Py_BuildValue("s", str); - free(str); + if (num) { + res = Py_BuildValue("i", rpmExpandNumeric(macro)); + } else { + char *str = rpmExpand(macro, NULL); + res = Py_BuildValue("s", str); + free(str); + } return res; } |