return 0;
}
+static Py_ssize_t Pakfire_len(PakfireObject* self) {
+ return pakfire_count_packages(self->pakfire);
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"generate_key",
{ NULL },
};
+static PySequenceMethods Pakfire_sequence = {
+ sq_length: (lenfunc)Pakfire_len,
+};
+
PyTypeObject PakfireType = {
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "_pakfire.Pakfire",
tp_methods: Pakfire_methods,
tp_getset: Pakfire_getsetters,
tp_repr: (reprfunc)Pakfire_repr,
+ tp_as_sequence: &Pakfire_sequence,
};
return 0;
}
-static Py_ssize_t Pool_len(PoolObject* self) {
- return pakfire_pool_count(self->pool);
-}
-
-
-
static PyObject* Pool_get_cache_path(PoolObject* self) {
const char* path = pakfire_pool_get_cache_path(self->pool);
if (!path)
{ NULL }
};
-static PySequenceMethods Pool_sequence = {
- sq_length: (lenfunc)Pool_len,
-};
-
PyTypeObject PoolType = {
PyVarObject_HEAD_INIT(NULL, 0)
tp_name: "_pakfire.Pool",
tp_init: (initproc)Pool_init,
tp_doc: "Pool object",
tp_getset: Pool_getsetters,
- tp_as_sequence: &Pool_sequence,
};
#ifndef PAKFIRE_PAKFIRE_H
#define PAKFIRE_PAKFIRE_H
+#include <stddef.h>
+
#include <pakfire/types.h>
int pakfire_init();
int pakfire_version_compare(Pakfire pakfire, const char* evr1, const char* evr2);
+size_t pakfire_count_packages(Pakfire pakfire);
+
PakfireRepo pakfire_get_installed_repo(Pakfire pakfire);
void pakfire_set_installed_repo(Pakfire pakfire, PakfireRepo repo);
PakfirePool pakfire_pool_ref(PakfirePool pool);
PakfirePool pakfire_pool_unref(PakfirePool pool);
-int pakfire_pool_count(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);
global:
# pakfire
pakfire_init;
+ pakfire_count_packages;
pakfire_create;
pakfire_get_arch;
pakfire_get_installed_repo;
pakfire_packagelist_unref;
# pool
- pakfire_pool_count;
pakfire_pool_create;
pakfire_pool_get_cache_path;
pakfire_pool_ref;
# #
#############################################################################*/
+#include <stddef.h>
+
#include <solv/evr.h>
#include <solv/pool.h>
#include <solv/poolarch.h>
pakfire->pool_ready = 0;
}
+PAKFIRE_EXPORT size_t pakfire_count_packages(Pakfire pakfire) {
+ size_t cnt = 0;
+
+ for (int i = 2; i < pakfire->pool->nsolvables; i++) {
+ Solvable* s = pakfire->pool->solvables + i;
+ if (s->repo)
+ cnt++;
+ }
+
+ return cnt;
+}
+
void pakfire_pool_apply_changes(Pakfire pakfire) {
if (!pakfire->pool_ready) {
pool_addfileprovides(pakfire->pool);
return pakfire_get_solv_pool(pool->pakfire);
}
-PAKFIRE_EXPORT int pakfire_pool_count(PakfirePool pool) {
- Pool* p = pakfire_get_solv_pool(pool->pakfire);
- int cnt = 0;
-
- for (int i = 2; i < p->nsolvables; i++) {
- Solvable* s = p->solvables + i;
- if (s->repo)
- cnt++;
- }
-
- return cnt;
-}
-
PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) {
if (!pool->cache)
return NULL;