summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-28 17:23:28 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-28 17:23:28 +0300
commitac3f9f729b9a3b938d3344278c7e0564934f3871 (patch)
tree5caffa8e5f80e97c88856e4b4e03dbd56a7d6834 /python
parentf74def684253964fa03edb55f155dfbb5122b1bf (diff)
downloadrpm-ac3f9f729b9a3b938d3344278c7e0564934f3871.tar.gz
rpm-ac3f9f729b9a3b938d3344278c7e0564934f3871.tar.bz2
rpm-ac3f9f729b9a3b938d3344278c7e0564934f3871.zip
Support numeric expansion in rpm.expandMacro()
Diffstat (limited to 'python')
-rw-r--r--python/rpmmacro-py.c16
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", &macro))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, &macro, &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;
}