#include "errors.h"
#include "package.h"
+PyObject* new_archive(PyTypeObject* type, PakfireArchive archive) {
+ ArchiveObject* self = (ArchiveObject *)type->tp_alloc(type, 0);
+ if (self) {
+ self->archive = pakfire_archive_ref(archive);
+ }
+
+ return (PyObject*)self;
+}
+
static PyObject* Archive_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
ArchiveObject* self = (ArchiveObject *)type->tp_alloc(type, 0);
if (self) {
#include <Python.h>
#include <errno.h>
+#include <pakfire/archive.h>
#include <pakfire/build.h>
#include <pakfire/constants.h>
#include <pakfire/dist.h>
#include <pakfire/request.h>
#include <pakfire/util.h>
+#include "archive.h"
#include "errors.h"
#include "key.h"
#include "pakfire.h"
Py_RETURN_NONE;
}
+static PyObject* Pakfire_open(PakfireObject* self, PyObject* args) {
+ PakfireArchive archive = NULL;
+ const char* path = NULL;
+
+ if (!PyArg_ParseTuple(args, "s", &path))
+ return NULL;
+
+ int r = pakfire_archive_open(&archive, self->pakfire, path);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ // Create Python object
+ PyObject* object = new_archive(&ArchiveType, archive);
+ pakfire_archive_unref(archive);
+
+ return object;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"bind",
METH_VARARGS|METH_KEYWORDS,
NULL,
},
+ {
+ "open",
+ (PyCFunction)Pakfire_open,
+ METH_VARARGS,
+ NULL
+ },
{
"refresh",
(PyCFunction)Pakfire_refresh,