summaryrefslogtreecommitdiff
path: root/doc/examples/depcache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-03-09 16:16:37 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-03-09 16:16:37 +0000
commit59902bad90ed9192ad9b2def78f588cdefe1080c (patch)
tree859896b89dc8a332c8c39d0960eb3f59128e465e /doc/examples/depcache.py
parent6d42024c88d207c35718f4f8458e58fc44951830 (diff)
downloadpython-apt-59902bad90ed9192ad9b2def78f588cdefe1080c.tar.gz
* Implemented OpProgress support
Diffstat (limited to 'doc/examples/depcache.py')
-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()