diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2013-12-19 15:44:47 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2014-01-17 13:19:57 +0200 |
commit | b52a3c44669f8a3d62c0b8a55c0536d46f89e88d (patch) | |
tree | 7da63fca1707afda492f4940361802d079670f50 | |
parent | 059b01f5a28b4cf8bbf7ad75e449b466d4a53bf2 (diff) | |
download | rpm-b52a3c44669f8a3d62c0b8a55c0536d46f89e88d.tar.gz |
Add .open() class method to rpm.fd
- This is simply equivalent of calling rpm.fd constructor, but
might be somewhat more natural way of opening files
(cherry picked from commit 6bd4a7475fe1c959db895d14386de95846fa0b71)
-rw-r--r-- | python/rpmfd-py.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index 0a87c824b..663743d59 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -117,6 +117,11 @@ static int rpmfd_init(rpmfdObject *s, PyObject *args, PyObject *kwds) return (fd == NULL) ? -1 : 0; } +static PyObject *rpmfd_open(PyObject *cls, PyObject *args, PyObject *kwds) +{ + return PyObject_Call(cls, args, kwds); +} + static PyObject *do_close(rpmfdObject *s) { /* mimic python fileobject: close on closed file is not an error */ @@ -293,6 +298,8 @@ static PyObject *rpmfd_write(rpmfdObject *s, PyObject *args, PyObject *kwds) static char rpmfd_doc[] = ""; static struct PyMethodDef rpmfd_methods[] = { + { "open", (PyCFunction) rpmfd_open, METH_VARARGS|METH_KEYWORDS|METH_CLASS, + NULL }, { "close", (PyCFunction) rpmfd_close, METH_NOARGS, NULL }, { "fileno", (PyCFunction) rpmfd_fileno, METH_NOARGS, |