summaryrefslogtreecommitdiff
path: root/python/rpmfiles-py.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2014-01-31 12:49:54 +0200
committerPanu Matilainen <pmatilai@redhat.com>2014-01-31 12:49:54 +0200
commit2498f1caa0ec7ff58d9fdd6ff3d5cb416ac6786e (patch)
tree74044b34cb470c824f611a8ca9d1290789328b23 /python/rpmfiles-py.c
parentee237ffdd98de8f0202f3db6c3b42bba05836078 (diff)
downloadrpm-2498f1caa0ec7ff58d9fdd6ff3d5cb416ac6786e.tar.gz
Add python bindings + a testcase for the archive API
- Wouldn't be surprised in the slightest if various details here changed before an actual release, but its a start. - Simple testcase showing spec file extraction from an src.rpm. Which also goes to show just how low-level our APIs are...
Diffstat (limited to 'python/rpmfiles-py.c')
-rw-r--r--python/rpmfiles-py.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/python/rpmfiles-py.c b/python/rpmfiles-py.c
index 2584d1acd..b62b9cbad 100644
--- a/python/rpmfiles-py.c
+++ b/python/rpmfiles-py.c
@@ -6,6 +6,8 @@
#include "header-py.h"
#include "rpmfi-py.h"
#include "rpmfiles-py.h"
+#include "rpmfd-py.h"
+#include "rpmarchive-py.h"
#include "rpmstrpool-py.h"
/* A single file from rpmfiles set, can't be independently instanciated */
@@ -399,6 +401,30 @@ static PyObject * rpmfiles_find(rpmfileObject *s,
Py_RETURN_NONE;
}
+static PyObject *rpmfiles_archive(rpmfilesObject *s,
+ PyObject *args, PyObject *kwds)
+{
+ char * kwlist[] = {"fd", "write", NULL};
+ rpmfdObject *fdo = NULL;
+ FD_t fd = NULL;
+ rpmfi archive = NULL;
+ int writer = 0;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|i", kwlist,
+ rpmfdFromPyObject, &fdo, &writer)) {
+ return NULL;
+ }
+
+ fd = rpmfdGetFd(fdo);
+ if (writer) {
+ archive = rpmfiNewArchiveWriter(fd, s->files);
+ } else {
+ archive = rpmfiNewArchiveReader(fd, s->files);
+ }
+
+ return rpmarchive_Wrap(&rpmarchive_Type, s->files, archive);
+}
+
static PyObject *rpmfiles_subscript(rpmfilesObject *s, PyObject *item)
{
PyObject *str = NULL;
@@ -453,6 +479,8 @@ static PyMappingMethods rpmfiles_as_mapping = {
};
static struct PyMethodDef rpmfiles_methods[] = {
+ { "archive", (PyCFunction) rpmfiles_archive, METH_VARARGS|METH_KEYWORDS,
+ NULL },
{ "find", (PyCFunction) rpmfiles_find, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }