From 59902bad90ed9192ad9b2def78f588cdefe1080c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2005 16:16:37 +0000 Subject: * Implemented OpProgress support --- doc/examples/depcache.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'doc/examples') diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py index 76487b1d..5e5699e7 100644 --- a/doc/examples/depcache.py +++ b/doc/examples/depcache.py @@ -3,14 +3,26 @@ import apt_pkg import sys +import copy -def progress(percent, data): - print "%s %s" % (data, percent) - +class MyProgress: + def __init__(self): + self.last = 0.0 + + def Update(self, percent): + if (self.last + 1.0) <= percent: + print "lala %s " % (percent) + self.last = percent + + def Done(self): + self.last = 0.0 + print "Done!" # init apt_pkg.init() -cache = apt_pkg.GetCache(progress,None) + +progress = MyProgress() +cache = apt_pkg.GetCache(progress) print "Available packages: %s " % cache.PackageCount sys.exit() -- cgit v1.2.3