summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/cache.py8
-rw-r--r--debian/changelog4
-rw-r--r--tests/apt-test.py3
3 files changed, 11 insertions, 4 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 83f0bd3d..973291c0 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -50,7 +50,6 @@ class Cache(object):
self._records = apt_pkg.GetPkgRecords(self._cache)
self._dict = {}
-
# build the packages dict
if progress != None:
progress.Op = "Building data structures"
@@ -64,14 +63,21 @@ class Cache(object):
if len(pkg.VersionList) > 0:
self._dict[pkg.Name] = Package(self._cache, self._depcache,
self._records, self, pkg)
+
i += 1
if progress != None:
progress.done()
self._runCallbacks("cache_post_open")
def __getitem__(self, key):
+ """ look like a dictionary (get key) """
return self._dict[key]
+ def __iter__(self):
+ for pkgname in self._dict.keys():
+ yield self._dict[pkgname]
+ raise StopIteration
+
def has_key(self, key):
try:
self._dict[key]
diff --git a/debian/changelog b/debian/changelog
index df7bd0a0..a31244bb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,8 +8,10 @@ python-apt (0.6.14) unstable; urgency=low
- support for "srcrecords.Files" added
- always run "Restart" before performing a Lookup
* export locking via: GetLock(),PkgSystem{Lock,UnLock}
+ * apt/cache.py:
+ - add __iter__
- --
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 20 Sep 2005 13:24:31 +0200
python-apt (0.6.13) unstable; urgency=low
diff --git a/tests/apt-test.py b/tests/apt-test.py
index f1bc5593..6205cf60 100644
--- a/tests/apt-test.py
+++ b/tests/apt-test.py
@@ -7,8 +7,7 @@ if __name__ == "__main__":
progress = apt.progress.OpTextProgress()
cache = apt.Cache(progress)
print cache
- for name in cache.keys():
- pkg = cache[name]
+ for pkg in cache:
if pkg.isUpgradable:
pkg.markInstall()
for pkg in cache.getChanges():