diff options
| -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 |
