#include <pakfire/pakfire.h>
#include <pakfire/key.h>
#include <pakfire/repo.h>
+#include <pakfire/util.h>
#include "key.h"
#include "pakfire.h"
return PyUnicode_FromString(arch);
}
+static PyObject* Pakfire_get_cache_path(PakfireObject* self) {
+ char* path = pakfire_get_cache_path(self->pakfire, NULL);
+ if (!path)
+ Py_RETURN_NONE;
+
+ PyObject* obj = PyUnicode_FromString(path);
+ pakfire_free(path);
+
+ return obj;
+}
+
+static int Pakfire_set_cache_path(PakfireObject* self, PyObject* value) {
+ const char* path = PyUnicode_AsUTF8(value);
+
+ if (path)
+ pakfire_set_cache_path(self->pakfire, path);
+
+ return 0;
+}
+
static PyObject* Pakfire_get_installed_repo(PakfireObject* self) {
PakfireRepo repo = pakfire_get_installed_repo(self->pakfire);
if (!repo)
NULL,
NULL
},
+ {
+ "cache_path",
+ (getter)Pakfire_get_cache_path,
+ (setter)Pakfire_set_cache_path,
+ NULL,
+ NULL
+ },
{
"installed_repo",
(getter)Pakfire_get_installed_repo,
return 0;
}
-static PyObject* Pool_get_cache_path(PoolObject* self) {
- const char* path = pakfire_pool_get_cache_path(self->pool);
- if (!path)
- Py_RETURN_NONE;
-
- return PyUnicode_FromString(path);
-}
-
-static int Pool_set_cache_path(PoolObject* self, PyObject* value) {
- const char* path = PyUnicode_AsUTF8(value);
- assert(path);
-
- pakfire_pool_set_cache_path(self->pool, path);
- return 0;
-}
-
-static struct PyGetSetDef Pool_getsetters[] = {
- {
- "cache_path",
- (getter)Pool_get_cache_path,
- (setter)Pool_set_cache_path,
- NULL,
- NULL
- },
- { NULL }
-};
-
PyTypeObject PoolType = {
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "_pakfire.Pool",
tp_dealloc: (destructor)Pool_dealloc,
tp_init: (initproc)Pool_init,
tp_doc: "Pool object",
- tp_getset: Pool_getsetters,
};
PakfirePool pakfire_pool_ref(PakfirePool pool);
PakfirePool pakfire_pool_unref(PakfirePool pool);
-const char* pakfire_pool_get_cache_path(PakfirePool pool);
-void pakfire_pool_set_cache_path(PakfirePool pool, const char* path);
PakfireCache pakfire_pool_get_cache(PakfirePool pool);
#ifdef PAKFIRE_PRIVATE
# pool
pakfire_pool_create;
- pakfire_pool_get_cache_path;
pakfire_pool_ref;
- pakfire_pool_set_cache_path;
pakfire_pool_unref;
# problem
return pakfire_get_solv_pool(pool->pakfire);
}
-PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) {
- if (!pool->cache)
- return NULL;
-
- return pakfire_cache_get_path(pool->cache);
-}
-
-PAKFIRE_EXPORT void pakfire_pool_set_cache_path(PakfirePool pool, const char* path) {
- if (pool->cache)
- pakfire_cache_free(pool->cache);
-
- pool->cache = pakfire_cache_create(pool, path);
-}
-
PAKFIRE_EXPORT PakfireCache pakfire_pool_get_cache(PakfirePool pool) {
if (pool->cache)
return pool->cache;
self.config = config or Config("general.conf")
self.pool = _pakfire.Pool(self)
- self.pool.cache_path = cache_path or \
+ self.cache_path = cache_path or \
os.path.join(CACHE_DIR, self.distro.sname, self.distro.release)
self.repos = repository.Repositories(self)