diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-09-20 11:36:25 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-09-20 11:36:25 +0000 |
| commit | aff4a3d2c1280da136198463a51fff5026194048 (patch) | |
| tree | fa07d8045fea9d5485bca754b31bb25fa9a1d5e8 /apt | |
| parent | 86af28f7da01d549fc1cd6f0ebff17a7fe764eb8 (diff) | |
| download | python-apt-aff4a3d2c1280da136198463a51fff5026194048.tar.gz | |
* added __iter__ support to apt/cache.py
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/cache.py | 8 |
1 files changed, 7 insertions, 1 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] |
