poldek: poldek/python/poldek.py, poldek/python/poldekmod.i, poldek...
mis
mis at pld-linux.org
Sat Feb 2 16:28:13 CET 2008
Author: mis Date: Sat Feb 2 15:28:13 2008 GMT
Module: poldek Tag: HEAD
---- Log message:
- choose_suggests support; updated choose_equiv
---- Files affected:
poldek/poldek/python:
poldek.py (1.14 -> 1.15) , poldekmod.i (1.17 -> 1.18) , pyldek.py (1.6 -> 1.7)
---- Diffs:
================================================================
Index: poldek/poldek/python/poldek.py
diff -u poldek/poldek/python/poldek.py:1.14 poldek/poldek/python/poldek.py:1.15
--- poldek/poldek/python/poldek.py:1.14 Mon Jan 28 15:08:48 2008
+++ poldek/poldek/python/poldek.py Sat Feb 2 16:28:08 2008
@@ -237,13 +237,28 @@
return False
# n_array_proxy() applied to tn_array*
- def raw__choose_equiv(self, ts, capability_name, raw_packages, hint):
+ def raw__choose_equiv(self, ts, pkg, capability_name, raw_packages, hint):
packages = n_array_proxy(raw_packages, pkg)
- return self.choose_equiv(ts, capability_name, packages, hint)
+ return self.choose_equiv(ts, package, capability_name, packages, hint)
- def choose_equiv(self, ts, capability_name, packages, hint):
- print "## confirm_transaction: Implement me"
+ def choose_equiv(self, ts, package, capability_name, packages, hint):
+ print "## choose_equiv: Implement me"
return hint
+
+ # n_array_proxy() applied to tn_array*
+ def raw__choose_suggests(self, ts, package, raw_caps, raw_choices, hint):
+ caps = n_array_proxy(raw_caps, capreq)
+
+ choices = []
+ rv = self.choose_suggests(ts, package, caps, choices, hint)
+ for c in choices:
+ raw_choices.push(c)
+ return rv
+
+ def choose_suggests(self, ts, package, caps, choices, hint):
+ print "## choose_suggests: Implement me"
+ return hint
+
class vfile_progress(py_poldek_util):
def initialize(self, label):
================================================================
Index: poldek/poldek/python/poldekmod.i
diff -u poldek/poldek/python/poldekmod.i:1.17 poldek/poldek/python/poldekmod.i:1.18
--- poldek/poldek/python/poldekmod.i:1.17 Fri Feb 1 17:09:17 2008
+++ poldek/poldek/python/poldekmod.i Sat Feb 2 16:28:08 2008
@@ -16,12 +16,18 @@
#include "log.h"
#include "vfile/vfile.h" /* for vf_progress */
-static void PythonDoLog(void *data, int pri, const char *fmt, va_list vargs);
+static void PythonDoLog(void *data, int pri, const char *message);
static int PythonConfirm(void *data, const struct poldek_ts *ts,
int hint, const char *message);
static int PythonTsConfirm(void *data, const struct poldek_ts *ts);
-static int PythonChooseEquiv(void *data, const struct poldek_ts *ts,
- const char *cap, tn_array *pkgs, int hint);
+
+static int PythonChooseEquiv(void *data, const struct poldek_ts *ts,
+ const struct pkg *pkg, const char *cap,
+ tn_array *pkgs, int hint);
+
+static int PythonChooseSuggests(void *data, const struct poldek_ts *ts,
+ const struct pkg *pkg, tn_array *caps,
+ tn_array *choices, int hint);
static struct vf_progress vfPyProgress;
%}
@@ -183,9 +189,10 @@
}
static int PythonChooseEquiv(void *data, const struct poldek_ts *ts,
- const char *cap, tn_array *pkgs, int hint)
+ const struct pkg *pkg, const char *cap,
+ tn_array *pkgs, int hint)
{
- PyObject *obj, *method, *pyts, *pycap, *pypkgs, *pyhint, *r;
+ PyObject *obj, *method, *pyts, *pypkg, *pycap, *pypkgs, *pyhint, *r;
tn_array *packages = n_ref(pkgs); // XXX
int answer;
@@ -195,16 +202,20 @@
pyts = SWIG_NewPointerObj(SWIG_as_voidptr(ts), SWIGTYPE_p_poldek_ts, 0 | 0);
Py_INCREF(pyts); // XXX - SWIG_NewPointerObj do incref?
+ pypkg = SWIG_NewPointerObj(SWIG_as_voidptr(pkg), SWIGTYPE_p_pkg, 0 | 0);
+ Py_INCREF(pypkg); // XXX - SWIG_NewPointerObj do incref?
+
pycap = Py_BuildValue("s", cap);
pypkgs = SWIG_NewPointerObj(SWIG_as_voidptr(pkgs), SWIGTYPE_p_trurl_array_private, 0 | 0);
Py_INCREF(pypkgs);
pyhint = Py_BuildValue("i", hint);
- r = PyObject_CallMethodObjArgs(obj, method, pyts, pycap, pypkgs, pyhint, NULL);
+ r = PyObject_CallMethodObjArgs(obj, method, pyts, pypkg, pycap, pypkgs, pyhint, NULL);
Py_DECREF(method);
Py_DECREF(pyts);
+ Py_DECREF(pypkg);
Py_DECREF(pycap);
Py_DECREF(pypkgs);
Py_DECREF(pyhint);
@@ -217,6 +228,48 @@
return answer;
}
+static int PythonChooseSuggests(void *data, const struct poldek_ts *ts,
+ const struct pkg *pkg, tn_array *caps,
+ tn_array *choices, int hint)
+{
+ PyObject *obj, *method, *pyts, *pypkg, *pycaps, *pychoices, *pyhint, *r;
+ int answer;
+
+ obj = (PyObject *) data;
+ method = Py_BuildValue("s", "raw__choose_suggests"); // XXX - see poldek.py
+
+ pyts = SWIG_NewPointerObj(SWIG_as_voidptr(ts), SWIGTYPE_p_poldek_ts, 0 | 0);
+ Py_INCREF(pyts); // XXX - SWIG_NewPointerObj do incref?
+
+ pypkg = SWIG_NewPointerObj(SWIG_as_voidptr(pkg), SWIGTYPE_p_pkg, 0 | 0);
+ Py_INCREF(pypkg); // XXX - SWIG_NewPointerObj do incref?
+
+ pycaps = SWIG_NewPointerObj(SWIG_as_voidptr(caps), SWIGTYPE_p_trurl_array_private, 0 | 0);
+ Py_INCREF(pycaps);
+
+ pychoices = SWIG_NewPointerObj(SWIG_as_voidptr(choices), SWIGTYPE_p_trurl_array_private, 0 | 0);
+ Py_INCREF(pychoices);
+
+
+ pyhint = Py_BuildValue("i", hint);
+
+ r = PyObject_CallMethodObjArgs(obj, method, pyts, pypkg, pycaps, pychoices, pyhint, NULL);
+
+ Py_DECREF(method);
+ Py_DECREF(pyts);
+ Py_DECREF(pypkg);
+ Py_DECREF(pycaps);
+ Py_DECREF(pychoices);
+ Py_DECREF(pyhint);
+
+ if (r == NULL)
+ return hint;
+
+ answer = (int)PyLong_AsLong(r);
+ Py_DECREF(r);
+ return answer;
+}
+
%}
%extend capreq {
@@ -479,6 +532,7 @@
poldek_configure(self, POLDEK_CONF_CONFIRM_CB, (void*)PythonConfirm, v);
poldek_configure(self, POLDEK_CONF_TSCONFIRM_CB, (void*)PythonTsConfirm, v);
poldek_configure(self, POLDEK_CONF_CHOOSEEQUIV_CB, (void*)PythonChooseEquiv, v);
+ poldek_configure(self, POLDEK_CONF_CHOOSESUGGESTS_CB, (void*)PythonChooseSuggests, v);
Py_INCREF(obj);
}
================================================================
Index: poldek/poldek/python/pyldek.py
diff -u poldek/poldek/python/pyldek.py:1.6 poldek/poldek/python/pyldek.py:1.7
--- poldek/poldek/python/pyldek.py:1.6 Mon Jan 28 15:08:48 2008
+++ poldek/poldek/python/pyldek.py Sat Feb 2 16:28:08 2008
@@ -98,9 +98,19 @@
print "*****************************************************\n"
return hint
+ def choose_suggests(self, ts, package, caps, choices, hint):
+ print "\n************** choose suggests *********************"
+ print "* Package <%s> suggests:" % package
+ for cap in caps:
+ print "* - %s" % cap
+ print "* Choosing the first one: %s" % caps[0]
+ print "*****************************************************\n"
+
+ choices.append(caps[0])
+ return 1
class Pyldek:
- def __init__(self, source_name = None, verbose = 1, config = None):
+ def __init__(self, source_name = None, source_path = None, verbose = 1, config = None):
ctx = poldek.poldek_ctx()
self._cb = PyldekCallbacks()
self._progress = vfileProgress()
@@ -115,6 +125,12 @@
src = poldek.source(source_name)
ctx.configure(ctx.CONF_SOURCE, src)
+ if source_path: # -s source_name ?
+ print "## Configured %s" % source_path
+ src = poldek.source(None, None, source_path, None)
+ ctx.configure(ctx.CONF_SOURCE, src)
+
+
ctx.load_config()
if not ctx.setup():
@@ -266,10 +282,11 @@
parser.add_option("-l", action='count', help="List sources")
parser.add_option("-v", action='count', help="Be verbose")
parser.add_option("-n", metavar="source", help="Select repository")
+ parser.add_option("-s", metavar="sourcepath", help="Select repository")
parser.add_option("--up", action="count", help="Update repository/ies")
parser.add_option("--upa", action="count", help="Update repository/ies")
(options, args) = parser.parse_args()
- if not options.l and not options.n and len(args) < 1:
+ if not options.l and not options.n and not options.s and len(args) < 1:
parser.print_help()
sys.exit(0)
return (options, args)
@@ -280,7 +297,7 @@
if not options.v :
options.v = 0
-pyl = Pyldek(options.n, verbose = options.v)
+pyl = Pyldek(options.n, options.s, verbose = options.v)
if options.l:
pyl.list_sources()
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/python/poldek.py?r1=1.14&r2=1.15&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/python/poldekmod.i?r1=1.17&r2=1.18&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/python/pyldek.py?r1=1.6&r2=1.7&f=u
More information about the pld-cvs-commit
mailing list