]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
python: Export pakfire_make_path()
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 14 Feb 2021 16:26:34 +0000 (16:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 14 Feb 2021 16:26:34 +0000 (16:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c

index 5b90967b39bd669e77bc19175d032d71ddd8c9d2..5039235642279ec5f03d53442a6838de0d28e5b9 100644 (file)
@@ -350,6 +350,24 @@ static Py_ssize_t Pakfire_len(PakfireObject* self) {
        return pakfire_count_packages(self->pakfire);
 }
 
+static PyObject* Pakfire_make_path(PakfireObject* self, PyObject* args) {
+       const char* path = NULL;
+
+       if (!PyArg_ParseTuple(args, "s", &path))
+               return NULL;
+
+       char* abspath = pakfire_make_path(self->pakfire, path);
+       if (!abspath) {
+               PyErr_SetFromErrno(PyExc_OSError);
+               return NULL;
+       }
+
+       PyObject* ret = PyUnicode_FromString(abspath);
+       free(abspath);
+
+       return ret;
+}
+
 static PyObject* Pakfire_execute_logging_callback = NULL;
 
 static int __Pakfire_execute_logging_callback(Pakfire pakfire, int priority, const char* data) {
@@ -549,6 +567,12 @@ static struct PyMethodDef Pakfire_methods[] = {
                METH_VARARGS,
                NULL
        },
+       {
+               "make_path",
+               (PyCFunction)Pakfire_make_path,
+               METH_VARARGS,
+               NULL
+       },
        {
                "search",
                (PyCFunction)Pakfire_search,