summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/depcache.py20
1 files changed, 16 insertions, 4 deletions
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()