summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-07 16:27:03 +0300
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-07 16:31:46 +0300
commiteb94de639491d33aea0ad50bf8f58d99f220c544 (patch)
treee9bfc2aee36e858b379ce48b5ed5bb7705176db6 /python
parent63d4926bf601797cbcdf4d5d99e8db4d2530d5ef (diff)
downloadlibrpm-tizen-eb94de639491d33aea0ad50bf8f58d99f220c544.tar.gz
librpm-tizen-eb94de639491d33aea0ad50bf8f58d99f220c544.tar.bz2
librpm-tizen-eb94de639491d33aea0ad50bf8f58d99f220c544.zip
Teach python rpmio bindings about Fdescr()
- Similarly to python file object having o.name, export Fdescr() as fd.name. Python uses <foo> for non-paths but [foo] seems like a safer choice wrt accidental redirections. - Also add a basic testcase for fd.name
Diffstat (limited to 'python')
-rw-r--r--python/rpmfd-py.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c
index df9b6411e..89a70cd0e 100644
--- a/python/rpmfd-py.c
+++ b/python/rpmfd-py.c
@@ -296,8 +296,15 @@ static PyObject *rpmfd_get_closed(rpmfdObject *s)
return PyBool_FromLong((s->fd == NULL));
}
+static PyObject *rpmfd_get_name(rpmfdObject *s)
+{
+ /* XXX: rpm returns non-paths with [mumble], python files use <mumble> */
+ return Py_BuildValue("s", Fdescr(s->fd));
+}
+
static PyGetSetDef rpmfd_getseters[] = {
{ "closed", (getter)rpmfd_get_closed, NULL, NULL },
+ { "name", (getter)rpmfd_get_name, NULL, NULL },
{ NULL },
};