Py_RETURN_NONE;
}
-static PyObject* Ctx_set_cache_path(CtxObject* self, PyObject* value) {
+static PyObject* Ctx_get_cache_path(CtxObject* self) {
+ const char* path = NULL;
+
+ // Fetch the path
+ path = pakfire_ctx_get_cache_path(self->ctx);
+ if (!path) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ return PyUnicode_FromString(path);
+}
+
+static int Ctx_set_cache_path(CtxObject* self, PyObject* value) {
const char* path = NULL;
int r;
// Fetch the path
path = PyUnicode_AsUTF8(value);
if (!path)
- return NULL;
+ return -1;
// Set the cache path
r = pakfire_ctx_set_cache_path(self->ctx, path);
- if (r) {
+ if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
+ return r;
}
- Py_RETURN_NONE;
+ return 0;
}
static struct PyMethodDef Ctx_methods[] = {
static struct PyGetSetDef Ctx_getsetters[] = {
{
"cache_path",
- NULL,
+ (getter)Ctx_get_cache_path,
(setter)Ctx_set_cache_path,
NULL,
NULL,
self.assertIsInstance(ctx, pakfire.Ctx)
+ # Cache Path
+
+ def test_cache_path(self):
+ ctx = self.setup_ctx()
+
+ # Set the cache path
+ ctx.cache_path = "/tmp"
+
+ # Read the cache path
+ self.assertEqual(ctx.cache_path, "/tmp")
+
# Logging
def test_log_default(self):