diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-05-05 11:09:26 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-05-05 11:09:26 +0200 |
| commit | 51c60cb3447247188bb8bf5c82b53e5199878b36 (patch) | |
| tree | 5f3d6ff39d06199a0423913284149fb6e59436d5 /apt/cache.py | |
| parent | b08e026fea9ed453d2cbaaa402fe1bd17c6242dd (diff) | |
| parent | 23d29169c30b2f05a0c2943832a7cf7288ff5802 (diff) | |
| download | python-apt-51c60cb3447247188bb8bf5c82b53e5199878b36.tar.gz | |
merge from the debian-unstable tree
Diffstat (limited to 'apt/cache.py')
| -rw-r--r-- | apt/cache.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/apt/cache.py b/apt/cache.py index cd9c5fe9..cc425ccb 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -1,6 +1,6 @@ # cache.py - apt cache abstraction # -# Copyright (c) 2005 Canonical +# Copyright (c) 2005-2009 Canonical # # Author: Michael Vogt <michael.vogt@ubuntu.com> # @@ -20,7 +20,6 @@ # USA import os -import sys import apt_pkg from apt import Package @@ -53,9 +52,11 @@ class Cache(object): apt_pkg.Config.Set("Dir::Cache::pkgcache", "") if rootdir: if os.path.exists(rootdir+"/etc/apt/apt.conf"): - apt_pkg.ReadConfigFile(apt_pkg.Config, rootdir+"/etc/apt/apt.conf") + apt_pkg.ReadConfigFile(apt_pkg.Config, + rootdir + "/etc/apt/apt.conf") if os.path.isdir(rootdir+"/etc/apt/apt.conf.d"): - apt_pkg.ReadConfigDir(apt_pkg.Config, rootdir+"/etc/apt/apt.conf.d") + apt_pkg.ReadConfigDir(apt_pkg.Config, + rootdir + "/etc/apt/apt.conf.d") apt_pkg.Config.Set("Dir", rootdir) apt_pkg.Config.Set("Dir::State::status", rootdir + "/var/lib/dpkg/status") @@ -71,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) @@ -79,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: @@ -93,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): @@ -154,7 +155,7 @@ class Cache(object): """Return the packages not downloadable packages in reqreinst state.""" reqreinst = set() for pkg in self: - if (not pkg.candidateDownloadable and + if (not pkg.candidate.downloadable and (pkg._pkg.InstState == apt_pkg.InstStateReInstReq or pkg._pkg.InstState == apt_pkg.InstStateHoldReInstReq)): reqreinst.add(pkg.name) @@ -448,7 +449,7 @@ if __name__ == "__main__": print len(f) print "Testing filtered cache (no argument)" - f = FilteredCache(progress=OpTextProgress()) + f = FilteredCache(progress=apt.progress.OpTextProgress()) f.cache.connect("cache_pre_change", cache_pre_changed) f.cache.connect("cache_post_change", cache_post_changed) f.cache.upgrade() |
