From: Michael Tremer Date: Sun, 14 Feb 2021 16:26:34 +0000 (+0000) Subject: python: Export pakfire_make_path() X-Git-Tag: 0.9.28~1285^2~723 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d598dec8449928c2526088fc4fbe530ba13e79fb;p=pakfire.git python: Export pakfire_make_path() Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 5b90967b3..503923564 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -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,