diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-02-23 21:03:13 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-02-23 21:03:13 +0000 |
| commit | 5a4c9edb5772d54a68ca043f4b4ebd85a871bd5d (patch) | |
| tree | a023cc4082ac5aade2ac31f994c77a2093c06cef | |
| parent | 157fcc2665301c168dabc02eec9105db3d860b53 (diff) | |
| download | python-apt-5a4c9edb5772d54a68ca043f4b4ebd85a871bd5d.tar.gz | |
* example for depcache and progress callback commited
| -rw-r--r-- | doc/examples/depcache.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py index b3d720a5..7c8a33ea 100644 --- a/doc/examples/depcache.py +++ b/doc/examples/depcache.py @@ -3,19 +3,33 @@ import apt_pkg +class TextProgress: + def __init__(self): + self.last = 1 + def show(self,Percent): + if self.last < Percent: + print "\r%.2f " % Percent, + self.last = Percent+0.1 + if Percent >= 100: + print "\r100.0 " + self.last = 0 + def Update(Percent, data): - pass + # data is a TextProgress class + progress = data + progress.show(Percent) + apt_pkg.init() -cache = apt_pkg.GetCache() + +progress = TextProgress() +cache = apt_pkg.GetCache(Update, progress) print cache.PackageCount iter = cache["base-config"] print iter -depcache = apt_pkg.GetDepCache(cache) -depcache.SetProgressCallback(Update, None) -depcache.Init() +depcache = apt_pkg.GetDepCache(cache, Update, progress) print depcache print depcache.InstCount |
