diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-02-23 20:45:52 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-02-23 20:45:52 +0000 |
| commit | 157fcc2665301c168dabc02eec9105db3d860b53 (patch) | |
| tree | 633b56e9ec59b4ff273d8148e7fad1210a64ad03 /python/cache.cc | |
| parent | 8bd15f69297702d22bd4dc958f2a0eb221b8e6f9 (diff) | |
| download | python-apt-157fcc2665301c168dabc02eec9105db3d860b53.tar.gz | |
* apt_pkg.GetCache() supports a progress callback now too
Diffstat (limited to 'python/cache.cc')
| -rw-r--r-- | python/cache.cc | 25 |
1 files changed, 19 insertions, 6 deletions
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 <apt-pkg/sptr.h> #include <Python.h> +#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<pkgCacheFile> *CacheFileObj = CppOwnedPyObject_NEW<pkgCacheFile>(0,&PkgCacheFileType, *Cache); |
