summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-03-08 20:15:52 +0100
committerJulian Andres Klode <jak@debian.org>2009-03-08 20:15:52 +0100
commitd012f1c89a5f773d9b9ae7128e24d708bb4117cb (patch)
tree52ef917250249fb057a3fb00f2e7e8c7e0360973
parent231983e447d19630372a51412859c0942b2d3ac5 (diff)
downloadpython-apt-d012f1c89a5f773d9b9ae7128e24d708bb4117cb.tar.gz
apt/cache.py: If no progress is given for cache open, use OpProgress.
Also fix doc/examples/records.py to use Package.candidate.*
-rw-r--r--apt/cache.py10
-rwxr-xr-xdoc/examples/records.py6
2 files changed, 8 insertions, 8 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 11e44c9e..a9430d6b 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -72,6 +72,8 @@ class Cache(object):
""" Open the package cache, after that it can be used like
a dictionary
"""
+ if progress is None:
+ progress = apt.progress.OpProgress()
self._runCallbacks("cache_pre_open")
self._cache = apt_pkg.GetCache(progress)
self._depcache = apt_pkg.GetDepCache(self._cache)
@@ -80,9 +82,7 @@ class Cache(object):
self._list.ReadMainList()
self._dict = {}
- # build the packages dict
- if progress is not None:
- progress.Op = "Building data structures"
+ progress.Op = "Building data structures"
i=last=0
size=len(self._cache.Packages)
for pkg in self._cache.Packages:
@@ -94,8 +94,8 @@ class Cache(object):
self._dict[pkg.Name] = Package(self, pkg)
i += 1
- if progress is not None:
- progress.done()
+
+ progress.done()
self._runCallbacks("cache_post_open")
def __getitem__(self, key):
diff --git a/doc/examples/records.py b/doc/examples/records.py
index a0fc8dc4..681eac0c 100755
--- a/doc/examples/records.py
+++ b/doc/examples/records.py
@@ -5,9 +5,9 @@ import apt
cache = apt.Cache()
for pkg in cache:
- if not pkg.candidateRecord:
+ if not pkg.candidate.record:
continue
- if "Task" in pkg.candidateRecord:
+ if "Task" in pkg.candidate.record:
print "Pkg %s is part of '%s'" % (
- pkg.name, pkg.candidateRecord["Task"].split())
+ pkg.name, pkg.candidate.record["Task"].split())
#print pkg.candidateRecord