]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
Implement dumping solver problems.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jul 2011 13:08:00 +0000 (15:08 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jul 2011 13:08:00 +0000 (15:08 +0200)
13 files changed:
Makefile
pakfire/satsolver.py
po/POTFILES.in
po/pakfire.pot
src/_pakfiremodule.c
src/config.h
src/problem.c
src/problem.h
src/relation.c
src/relation.h
src/solvable.c
src/solvable.h
src/solver.c

index 85581ed92689993af7fbd41dbbd686516e91155e..c32cea939768aa92850160349edf29433e27ce63 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,4 +30,4 @@ check:
 
 .PHONY: po
 po:
-       find pakfire -name "*.py" | grep -v "__version__.py" | sort > po/POTFILES.in
+       find pakfire src -name "*.py" -or -name "*.c" | grep -v "__version__.py" | sort > po/POTFILES.in
index e626827a9471049f7f34f8f8f7a0055973540fc8..d4a80a808d7cca29be1bd3279c4df1f900c8ea16 100644 (file)
@@ -7,6 +7,8 @@ from _pakfire import *
 
 import transaction
 
+from i18n import _
+
 class Request(_pakfire.Request):
        def install(self, what):
                if isinstance(what, Solvable):
@@ -96,4 +98,20 @@ class Solver(object):
 
                        return transaction.Transaction.from_solver(self.pakfire, self, t)
 
+               # Do the problem handling...
+               problems = self._solver.get_problems(request)
+
+               logging.info("")
+               logging.info(_("The solver returned %s problems:") % len(problems))
+               logging.info("")
+
+               i = 0
+               for p in self._solver.get_problems(request):
+                       i += 1
+
+                       # Print information about the problem to the user.
+                       logging.info(_("  Problem #%d:") % i)
+                       logging.info("    %s" % p)
+                       logging.info("")
+
                return res
index 828fd69641781f2458535557af00768cd9631366..d99bf2768da9500af2e9cf9236cf225f2be8b196 100644 (file)
@@ -38,3 +38,14 @@ pakfire/satsolver.py
 pakfire/server.py
 pakfire/transaction.py
 pakfire/util.py
+src/_pakfiremodule.c
+src/pool.c
+src/problem.c
+src/relation.c
+src/repo.c
+src/request.c
+src/solvable.c
+src/solver.c
+src/step.c
+src/test.py
+src/transaction.c
index 62532a9173c93b0206d2c0640e6a6c3059246c1c..be74ce9a800b21e00fec0c3582febdf4287095f7 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-24 18:12+0200\n"
+"POT-Creation-Date: 2011-07-29 15:04+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"
@@ -187,11 +187,11 @@ msgstr ""
 msgid "Build the package for the given architecture."
 msgstr ""
 
-#: ../pakfire/cli.py:318 ../pakfire/cli.py:342
+#: ../pakfire/cli.py:318 ../pakfire/cli.py:344
 msgid "Path were the output files should be copied to."
 msgstr ""
 
-#: ../pakfire/cli.py:320
+#: ../pakfire/cli.py:320 ../pakfire/cli.py:333
 msgid "Mode to run in. Is either 'release' or 'development' (default)."
 msgstr ""
 
@@ -207,55 +207,55 @@ msgstr ""
 msgid "Emulated architecture in the shell."
 msgstr ""
 
-#: ../pakfire/cli.py:336
+#: ../pakfire/cli.py:338
 msgid "Generate a source package."
 msgstr ""
 
-#: ../pakfire/cli.py:338
+#: ../pakfire/cli.py:340
 msgid "Give name(s) of a package(s)."
 msgstr ""
 
-#: ../pakfire/cli.py:413
+#: ../pakfire/cli.py:416
 msgid "Pakfire repo command line interface."
 msgstr ""
 
-#: ../pakfire/cli.py:438
+#: ../pakfire/cli.py:441
 msgid "Repository management commands."
 msgstr ""
 
-#: ../pakfire/cli.py:446
+#: ../pakfire/cli.py:449
 msgid "Create a new repository index."
 msgstr ""
 
-#: ../pakfire/cli.py:447
+#: ../pakfire/cli.py:450
 msgid "Path to the packages."
 msgstr ""
 
-#: ../pakfire/cli.py:448
+#: ../pakfire/cli.py:451
 msgid "Path to input packages."
 msgstr ""
 
-#: ../pakfire/cli.py:460
+#: ../pakfire/cli.py:463
 msgid "Pakfire master command line interface."
 msgstr ""
 
-#: ../pakfire/cli.py:488
+#: ../pakfire/cli.py:491
 msgid "Update the sources."
 msgstr ""
 
-#: ../pakfire/cli.py:498
+#: ../pakfire/cli.py:501
 msgid "Pakfire server command line interface."
 msgstr ""
 
-#: ../pakfire/cli.py:530
+#: ../pakfire/cli.py:533
 msgid "Request a build job from the server."
 msgstr ""
 
-#: ../pakfire/cli.py:536
+#: ../pakfire/cli.py:539
 msgid "Send a keepalive to the server."
 msgstr ""
 
-#: ../pakfire/cli.py:543
+#: ../pakfire/cli.py:546
 msgid "Update all repositories."
 msgstr ""
 
@@ -343,6 +343,17 @@ msgstr ""
 msgid "Loading installed packages"
 msgstr ""
 
+#: ../pakfire/satsolver.py:105
+#, python-format
+msgid "The solver returned %s problems:"
+msgstr ""
+
+#. Print information about the problem to the user.
+#: ../pakfire/satsolver.py:113
+#, python-format
+msgid "  Problem #%d:"
+msgstr ""
+
 #: ../pakfire/transaction.py:89
 msgid "Downloading packages:"
 msgstr ""
@@ -397,3 +408,83 @@ msgstr ""
 #, python-format
 msgid "%s [y/N]"
 msgstr ""
+
+#: ../src/problem.c:126
+#, c-format
+msgid "%s does not belong to a distupgrade repository"
+msgstr ""
+
+#: ../src/problem.c:133
+#, c-format
+msgid "%s has inferior architecture"
+msgstr ""
+
+#: ../src/problem.c:140
+#, c-format
+msgid "problem with installed package %s"
+msgstr ""
+
+#: ../src/problem.c:146
+#, c-format
+msgid "conflicting requests"
+msgstr ""
+
+#: ../src/problem.c:151
+#, c-format
+msgid "nothing provides requested %s"
+msgstr ""
+
+#: ../src/problem.c:157
+#, c-format
+msgid "some dependency problem"
+msgstr ""
+
+#: ../src/problem.c:162
+#, c-format
+msgid "package %s is not installable"
+msgstr ""
+
+#: ../src/problem.c:169
+#, c-format
+msgid "nothing provides %s needed by %s"
+msgstr ""
+
+#: ../src/problem.c:176
+#, c-format
+msgid "cannot install both %s and %s"
+msgstr ""
+
+#: ../src/problem.c:183
+#, c-format
+msgid "package %s conflicts with %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:191
+#, c-format
+msgid "package %s obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:199
+#, c-format
+msgid "installed package %s obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:207
+#, c-format
+msgid "package %s implicitely obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:215
+#, c-format
+msgid "package %s requires %s, but none of the providers can be installed"
+msgstr ""
+
+#: ../src/problem.c:222
+#, c-format
+msgid "package %s conflicts with %s provided by itself"
+msgstr ""
+
+#: ../src/problem.c:231
+#, c-format
+msgid "bad rule type"
+msgstr ""
index 959ccd04257937ca8ae3fe1f3c8e5db511e0259d..0aaa2c8111f7c2314020347255b27764925dd17d 100644 (file)
@@ -1,6 +1,7 @@
 
 #include <Python.h>
 
+#include "config.h"
 #include "pool.h"
 #include "problem.h"
 #include "relation.h"
@@ -25,6 +26,10 @@ static PyMethodDef Pool_methods[] = {
 };
 
 static PyMethodDef Problem_methods[] = {
+       {"get_rule", (PyCFunction)Problem_get_rule, METH_NOARGS, NULL},
+       {"get_source", (PyCFunction)Problem_get_source, METH_NOARGS, NULL},
+       {"get_target", (PyCFunction)Problem_get_target, METH_NOARGS, NULL},
+       {"get_dep", (PyCFunction)Problem_get_dep, METH_NOARGS, NULL},
        { NULL, NULL, 0, NULL }
 };
 
@@ -136,6 +141,12 @@ static PyMethodDef Transaction_methods[] = {
 };
 
 void init_pakfire(void) {
+       /* Initialize locale */
+       setlocale(LC_ALL, "");
+       bindtextdomain(TEXTDOMAIN, "/usr/share/locale");
+       textdomain(TEXTDOMAIN);
+
+       /* Load the python module */
        PyObject *m, *d;
 
        m = Py_InitModule("_pakfire", pakfireModuleMethods);
@@ -214,12 +225,33 @@ void init_pakfire(void) {
        PyDict_SetItemString(d, "REL_GE", Py_BuildValue("i", REL_GT|REL_EQ));
 
        // Add constants for search
-       PyDict_SetItemString(d, "SEARCH_STRING",                Py_BuildValue("i", SEARCH_STRING));
+       PyDict_SetItemString(d, "SEARCH_STRING",        Py_BuildValue("i", SEARCH_STRING));
        PyDict_SetItemString(d, "SEARCH_STRINGSTART",   Py_BuildValue("i", SEARCH_STRINGSTART));
-       PyDict_SetItemString(d, "SEARCH_STRINGEND",             Py_BuildValue("i", SEARCH_STRINGEND));
-       PyDict_SetItemString(d, "SEARCH_SUBSTRING",             Py_BuildValue("i", SEARCH_SUBSTRING));
-       PyDict_SetItemString(d, "SEARCH_GLOB",                  Py_BuildValue("i", SEARCH_GLOB));
-       PyDict_SetItemString(d, "SEARCH_REGEX",                 Py_BuildValue("i", SEARCH_REGEX));
-       PyDict_SetItemString(d, "SEARCH_FILES",                 Py_BuildValue("i", SEARCH_FILES));
-       PyDict_SetItemString(d, "SEARCH_CHECKSUMS",             Py_BuildValue("i", SEARCH_CHECKSUMS));
+       PyDict_SetItemString(d, "SEARCH_STRINGEND",     Py_BuildValue("i", SEARCH_STRINGEND));
+       PyDict_SetItemString(d, "SEARCH_SUBSTRING",     Py_BuildValue("i", SEARCH_SUBSTRING));
+       PyDict_SetItemString(d, "SEARCH_GLOB",          Py_BuildValue("i", SEARCH_GLOB));
+       PyDict_SetItemString(d, "SEARCH_REGEX",         Py_BuildValue("i", SEARCH_REGEX));
+       PyDict_SetItemString(d, "SEARCH_FILES",         Py_BuildValue("i", SEARCH_FILES));
+       PyDict_SetItemString(d, "SEARCH_CHECKSUMS",     Py_BuildValue("i", SEARCH_CHECKSUMS));
+
+       // Add constants for rules
+       PyDict_SetItemString(d, "SOLVER_RULE_DISTUPGRADE",                      Py_BuildValue("i", SOLVER_RULE_DISTUPGRADE));
+       PyDict_SetItemString(d, "SOLVER_RULE_INFARCH",                          Py_BuildValue("i", SOLVER_RULE_INFARCH));
+       PyDict_SetItemString(d, "SOLVER_RULE_UPDATE",                           Py_BuildValue("i", SOLVER_RULE_UPDATE));
+       PyDict_SetItemString(d, "SOLVER_RULE_JOB",                              Py_BuildValue("i", SOLVER_RULE_JOB));
+       PyDict_SetItemString(d, "SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP",         Py_BuildValue("i", SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM",                              Py_BuildValue("i", SOLVER_RULE_RPM));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_NOT_INSTALLABLE",              Py_BuildValue("i", SOLVER_RULE_RPM_NOT_INSTALLABLE));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP",         Py_BuildValue("i", SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_SAME_NAME",                    Py_BuildValue("i", SOLVER_RULE_RPM_SAME_NAME));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_CONFLICT",             Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_CONFLICT));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_OBSOLETES",            Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_OBSOLETES));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES",       Py_BuildValue("i", SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_IMPLICIT_OBSOLETES",           Py_BuildValue("i", SOLVER_RULE_RPM_IMPLICIT_OBSOLETES));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_REQUIRES",             Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_REQUIRES));
+       PyDict_SetItemString(d, "SOLVER_RULE_RPM_SELF_CONFLICT",                Py_BuildValue("i", SOLVER_RULE_RPM_SELF_CONFLICT));
+       PyDict_SetItemString(d, "SOLVER_RULE_UNKNOWN",                          Py_BuildValue("i", SOLVER_RULE_UNKNOWN));
+       PyDict_SetItemString(d, "SOLVER_RULE_FEATURE",                          Py_BuildValue("i", SOLVER_RULE_FEATURE));
+       PyDict_SetItemString(d, "SOLVER_RULE_LEARNT",                           Py_BuildValue("i", SOLVER_RULE_LEARNT));
+       PyDict_SetItemString(d, "SOLVER_RULE_CHOICE",                           Py_BuildValue("i", SOLVER_RULE_CHOICE));
 }
index d367e8c91d2484bddcbc626e14baa7537322da47..da1981e4f0c35d0cdc7183f87185150b4f931efd 100644 (file)
@@ -4,4 +4,16 @@
        of the satsolver module.
 */
 
-#define DEBUG
+//#define DEBUG
+
+
+#define STRING_SIZE    2048
+
+/*
+       Load all required modules for the translation.
+*/
+
+#include <libintl.h>
+
+#define TEXTDOMAIN     "pakfire"
+#define _(x) gettext(x)
index 266eb2be3b4bce1305108996e7572c2ceb6446c3..d44ab234960b3ee5b7b9ef214e57489d554a7b98 100644 (file)
@@ -1,6 +1,11 @@
 
+#include <Python.h>
+
+#include "config.h"
 #include "problem.h"
+#include "relation.h"
 #include "request.h"
+#include "solvable.h"
 #include "solver.h"
 
 PyTypeObject ProblemType = {
@@ -11,31 +16,222 @@ PyTypeObject ProblemType = {
        tp_new : Problem_new,
        tp_dealloc: (destructor) Problem_dealloc,
        tp_doc: "Sat Problem objects",
+       tp_str: (reprfunc)Problem_string,
 };
 
 PyObject* Problem_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
        ProblemObject *self;
-
        SolverObject *solver;
        RequestObject *request;
        Id problem_id;
 
        if (!PyArg_ParseTuple(args, "OOi", &solver, &request, &problem_id)) {
                /* XXX raise exception */
+               return NULL;
        }
 
        self = (ProblemObject *)type->tp_alloc(type, 0);
        if (self != NULL) {
+               self->_pool = request->_pool;
                self->_solver = solver->_solver;
-//             self->_request = request->_request;
                self->_id = problem_id;
+
+               // Initialize problem information.
+               Problem_init(self);
        }
 
        return (PyObject *)self;
 }
 
 PyObject *Problem_dealloc(ProblemObject *self) {
-       //self->ob_type->tp_free((PyObject *)self);
+       self->ob_type->tp_free((PyObject *)self);
 
        Py_RETURN_NONE;
 }
+
+PyObject *Problem_init(ProblemObject *self) {
+       Id id = solver_findproblemrule(self->_solver, self->_id);
+
+       self->rule = solver_ruleinfo(self->_solver, id, &self->source,
+               &self->target, &self->dep);
+
+       Py_RETURN_NONE;
+}
+
+PyObject *Problem_get_rule(ProblemObject *self) {
+       return Py_BuildValue("i", self->rule);
+}
+
+PyObject *Problem_get_source(ProblemObject *self) {
+       SolvableObject *solvable;
+
+       if (self->source == ID_NULL)
+               Py_RETURN_NONE;
+
+       solvable = PyObject_New(SolvableObject, &SolvableType);
+       if (solvable == NULL)
+               return NULL;
+
+       solvable->_pool = self->_pool;
+       solvable->_id = self->source;
+
+       return (PyObject *)solvable;
+}
+
+PyObject *Problem_get_target(ProblemObject *self) {
+       SolvableObject *solvable;
+
+       if (self->target == ID_NULL)
+               Py_RETURN_NONE;
+
+       solvable = PyObject_New(SolvableObject, &SolvableType);
+       if (solvable == NULL)
+               return NULL;
+
+       solvable->_pool = self->_pool;
+       solvable->_id = self->target;
+
+       return (PyObject *)solvable;
+}
+
+PyObject *Problem_get_dep(ProblemObject *self) {
+       RelationObject *relation;
+
+       if (self->dep == ID_NULL)
+               Py_RETURN_NONE;
+
+       relation = PyObject_New(RelationObject, &RelationType);
+       if (relation == NULL)
+               return NULL;
+
+       relation->_pool = self->_pool;
+       relation->_id = self->dep;
+
+       return (PyObject *)relation;
+}
+
+PyObject *Problem_get_solutions(ProblemObject *self) {
+       PyObject *list = PyList_New(0);
+
+       return list;
+}
+
+PyObject *Problem_string(ProblemObject *self) {
+       Pool *pool = self->_pool;
+       char s[STRING_SIZE];
+
+       switch (self->rule) {
+               case SOLVER_RULE_DISTUPGRADE:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("%s does not belong to a distupgrade repository"),
+                               pool_solvid2str(pool, self->source)
+                       );
+                       break;
+
+               case SOLVER_RULE_INFARCH:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("%s has inferior architecture"),
+                               pool_solvid2str(pool, self->source)
+                       );
+                       break;
+
+               case SOLVER_RULE_UPDATE:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("problem with installed package %s"),
+                               pool_solvid2str(pool, self->source)
+                       );
+                       break;
+
+               case SOLVER_RULE_JOB:
+                       snprintf(s, STRING_SIZE - 1, _("conflicting requests"));
+                       break;
+
+               case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("nothing provides requested %s"),
+                               pool_dep2str(pool, self->dep)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM:
+                       snprintf(s, STRING_SIZE - 1, _("some dependency problem"));
+                       break;
+
+               case SOLVER_RULE_RPM_NOT_INSTALLABLE:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s is not installable"),
+                               pool_solvid2str(pool, self->source)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("nothing provides %s needed by %s"),
+                               pool_dep2str(pool, self->dep),  pool_solvid2str(pool, self->source)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_SAME_NAME:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("cannot install both %s and %s"),
+                               pool_dep2str(pool, self->source),  pool_solvid2str(pool, self->target)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s conflicts with %s provided by %s"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+                               pool_solvid2str(pool, self->target)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s obsoletes %s provided by %s"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+                               pool_solvid2str(pool, self->target)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("installed package %s obsoletes %s provided by %s"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+                               pool_solvid2str(pool, self->target)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s implicitely obsoletes %s provided by %s"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+                               pool_solvid2str(pool, self->target)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s requires %s, but none of the providers can be installed"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep)
+                       );
+                       break;
+
+               case SOLVER_RULE_RPM_SELF_CONFLICT:
+                       snprintf(s, STRING_SIZE - 1,
+                               _("package %s conflicts with %s provided by itself"),
+                               pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep)
+                       );
+                       break;
+
+               case SOLVER_RULE_UNKNOWN:
+               case SOLVER_RULE_FEATURE:
+               case SOLVER_RULE_LEARNT:
+               case SOLVER_RULE_CHOICE:
+                       snprintf(s, STRING_SIZE - 1, _("bad rule type"));
+                       break;
+
+       }
+
+       return Py_BuildValue("s", &s);
+}
index 28d495efde609ec9715065acbb9455b6d3c7f33f..73074fddf61a7cfdbacb027d17131cea09c81dd7 100644 (file)
@@ -7,17 +7,31 @@
 #include <satsolver/pool.h>
 #include <satsolver/solver.h>
 
-// Sat Step object
+// Sat Problem object
 typedef struct {
     PyObject_HEAD
+    Pool *_pool;
     Solver *_solver;
-//    Request *_request;
     Id _id;
+
+    // problem information
+    Id rule;
+    Id source;
+    Id target;
+    Id dep;
 } ProblemObject;
 
-extern PyObjectProblem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+extern PyObject *Problem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 extern PyObject *Problem_dealloc(ProblemObject *self);
 
+extern PyObject *Problem_init(ProblemObject *self);
+extern PyObject *Problem_string(ProblemObject *self);
+
+extern PyObject *Problem_get_rule(ProblemObject *self);
+extern PyObject *Problem_get_source(ProblemObject *self);
+extern PyObject *Problem_get_target(ProblemObject *self);
+extern PyObject *Problem_get_dep(ProblemObject *self);
+
 extern PyTypeObject ProblemType;
 
 #endif
index 10020e6b32d3e316280ca2b8fd16a3bd121d72c7..30a9cc5524fd076e36d1b4bfffdc6440bbd7dbb6 100644 (file)
@@ -12,6 +12,7 @@ PyTypeObject RelationType = {
        tp_new : Relation_new,
        tp_dealloc: (destructor) Relation_dealloc,
        tp_doc: "Sat Relation objects",
+       tp_str: (reprfunc)Relation_string,
 };
 
 PyObject* Relation_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
@@ -48,3 +49,7 @@ PyObject *Relation_dealloc(RelationObject *self) {
 
        Py_RETURN_NONE;
 }
+
+PyObject *Relation_string(RelationObject *self) {
+       return Py_BuildValue("s", pool_dep2str(self->_pool, self->_id));
+}
index 9ae4e3bf290af36fedb87f06cddaaf76e4f9c9be..0ba8a4fa15baeb23c6ac0cbbe732b4d4cfe8a57b 100644 (file)
@@ -13,9 +13,11 @@ typedef struct {
     Id _id;
 } RelationObject;
 
-extern PyObjectRelation_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+extern PyObject *Relation_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 extern PyObject *Relation_dealloc(RelationObject *self);
 
+extern PyObject *Relation_string(RelationObject *self);
+
 extern PyTypeObject RelationType;
 
 #endif
index 493148a3586a12faec350dd47b214eca4a641648..602db60125ad00c740c83db32f178f8cd5aff7b0 100644 (file)
@@ -1,4 +1,7 @@
 
+#include <Python.h>
+
+#include "config.h"
 #include "relation.h"
 #include "repo.h"
 #include "solvable.h"
@@ -11,6 +14,7 @@ PyTypeObject SolvableType = {
        tp_new : Solvable_new,
        tp_dealloc: (destructor) Solvable_dealloc,
        tp_doc: "Sat Solvable objects",
+       tp_str: (reprfunc)Solvable_string,
 };
 
 // Solvable
@@ -53,6 +57,14 @@ PyObject *Solvable_dealloc(SolvableObject *self) {
        Py_RETURN_NONE;
 }
 
+PyObject *Solvable_string(SolvableObject *self) {
+       Solvable *solvable = pool_id2solvable(self->_pool, self->_id);
+
+       const char *str = pool_solvable2str(self->_pool, solvable);
+
+       return Py_BuildValue("s", str);
+}
+
 PyObject *Solvable_get_name(SolvableObject *self) {
        Solvable *solvable = pool_id2solvable(self->_pool, self->_id);
 
index ac233152885ae72ffbe3974775825dda37cf873f..5ff6daa97a4ebb66752fd59d3d8710ddff5dec46 100644 (file)
@@ -15,6 +15,8 @@ typedef struct {
 
 extern PyObject* Solvable_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 extern PyObject *Solvable_dealloc(SolvableObject *self);
+extern PyObject *Solvable_string(SolvableObject *self);
+
 extern PyObject *Solvable_get_name(SolvableObject *self);
 extern PyObject *Solvable_get_evr(SolvableObject *self);
 extern PyObject *Solvable_get_arch(SolvableObject *self);
index 16801876375723e4794183e4e67168febcb2bd2e..625b57cd445b643aa982e046d30fd2cc8230473b 100644 (file)
@@ -152,7 +152,9 @@ PyObject *Solver_solve(SolverObject *self, PyObject *args) {
 
        solver_solve(self->_solver, &request->_queue);
 
+#ifdef DEBUG
        solver_printallsolutions(self->_solver);
+#endif
 
        if (self->_solver->problems.count == 0) {
                Py_RETURN_TRUE;
@@ -166,21 +168,23 @@ PyObject *Solver_get_problems(SolverObject *self, PyObject *args) {
 
        if (!PyArg_ParseTuple(args, "O", &request)) {
                /* XXX raise exception */
+               return NULL;
        }
 
        PyObject *list = PyList_New(0);
 
        ProblemObject *problem;
-       int i = 0;
-       for(; i < self->_solver->problems.count; i++) {
+       Id p = 0;
+       while ((p = solver_next_problem(self->_solver, p)) != 0) {
                problem = PyObject_New(ProblemObject, &ProblemType);
+
+               problem->_pool = self->_solver->pool;
                problem->_solver = self->_solver;
-               //problem->_request = request->_request;
-               problem->_id = self->_solver->problems.elements[i];
+               problem->_id = p;
+               Problem_init(problem);
 
                PyList_Append(list, (PyObject *)problem);
        }
 
-       Py_INCREF(list); // XXX do we need this here?
-       return (PyObject *)list;
+       return list;
 }