]> git.ipfire.org Git - pakfire.git/commitdiff
Implement searching the pool.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2011 10:08:02 +0000 (12:08 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2011 10:08:02 +0000 (12:08 +0200)
pakfire/base.py
po/pakfire.pot
src/_pakfiremodule.c
src/pool.c

index 2d2562131d8eaec8c998bea2169d96def69853d7..c1673365c2a3c22b947f543655cfc1b22a1874f5 100644 (file)
@@ -207,7 +207,9 @@ class Pakfire(object):
 
        def search(self, pattern):
                # Do the search.
-               pkgs = self.repos.search(pattern)
+               pkgs = []
+               for solv in self.pool.search(pattern):
+                       pkgs.append(packages.SolvPackage(self, solv))
 
                # Return the output as a package listing.
                return packages.PackageListing(pkgs)
index 8837d1fa042ebbdc630314cb9e815b95c66235c5..f1d2d7bb39d6c3bf63afa18b29f5cae9271e21dc 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-16 22:20+0200\n"
+"POT-Creation-Date: 2011-07-17 12:07+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
index 7f4255ecc92d6047431e8b543889e5701296c245..54a671f3bd91fa2d49fbdf527d2fc5c2431efe22 100644 (file)
@@ -20,6 +20,7 @@ static PyMethodDef Pool_methods[] = {
        {"size", (PyCFunction)Pool_size, METH_NOARGS, NULL},
        {"set_installed", (PyCFunction)Pool_set_installed, METH_VARARGS, NULL},
        {"providers", (PyCFunction)Pool_providers, METH_VARARGS, NULL},
+       {"search", (PyCFunction)Pool_search, METH_VARARGS, NULL},
        { NULL, NULL, 0, NULL }
 };
 
index d8032343988b0177521a42e1fb78a7dcce751edc..c70e4093aaa8e7a70506db2a5194e0f1b2d4c53e 100644 (file)
@@ -88,8 +88,39 @@ PyObject *Pool_size(PoolObject *self) {
        return Py_BuildValue("i", pool->nsolvables);
 }
 
+PyObject *_Pool_search(Pool *pool, Repo *repo, const char *match, int option) {
+       // Prepare the pool, so we can search in it.
+       _Pool_prepare(pool);
+
+       Dataiterator d;
+       dataiterator_init(&d, pool, repo, 0, 0, match, option);
+
+       PyObject *list = PyList_New(0);
+
+       SolvableObject *solvable;
+       while (dataiterator_step(&d)) {
+               solvable = PyObject_New(SolvableObject, &SolvableType);
+               solvable->_pool = pool;
+               solvable->_id = d.solvid;
+
+               PyList_Append(list, (PyObject *)solvable);
+       }
+
+       dataiterator_free(&d);
+
+       Py_INCREF(list);
+       return list;
+}
+
 PyObject *Pool_search(PoolObject *self, PyObject *args) {
-       Py_RETURN_NONE; /* XXX to be done */
+       const char *match = NULL;
+       int option = SEARCH_SUBSTRING;
+
+       if (!PyArg_ParseTuple(args, "s|i", &match, &option)) {
+               /* XXX raise exception */
+       }
+
+       return _Pool_search(self->_pool, NULL, match, option);
 }
 
 PyObject *Pool_set_installed(PoolObject *self, PyObject *args) {