From 157fcc2665301c168dabc02eec9105db3d860b53 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 23 Feb 2005 20:45:52 +0000 Subject: * apt_pkg.GetCache() supports a progress callback now too --- python/cache.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'python/cache.cc') diff --git a/python/cache.cc b/python/cache.cc index 954aed92..ceffba20 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -16,6 +16,8 @@ #include #include +#include "progress.h" + /*}}}*/ struct PkgListStruct @@ -740,14 +742,25 @@ PyTypeObject RDepListType = PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { - if (PyArg_ParseTuple(Args,"") == 0) + pkgCacheFile *Cache = new pkgCacheFile(); + + PyObject *pyCallbackObj = 0; + PyObject *pyCallbackArgs = 0; + if (PyArg_ParseTuple(Args, "|OO", &pyCallbackObj, &pyCallbackArgs) == 0) return 0; - pkgCacheFile *Cache = new pkgCacheFile(); - OpTextProgress Prog; - if (Cache->Open(Prog,false) == false) - return HandleErrors(); - + if(pyCallbackObj != 0) { + PyOpProgressStruct progress; + progress.py_update_callback_func = pyCallbackObj; + progress.py_update_callback_args = pyCallbackArgs; + if (Cache->Open(progress,false) == false) + return HandleErrors(); + } else { + OpTextProgress Prog; + if (Cache->Open(Prog,false) == false) + return HandleErrors(); + } + CppOwnedPyObject *CacheFileObj = CppOwnedPyObject_NEW(0,&PkgCacheFileType, *Cache); -- cgit v1.2.3