summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-05-06 21:19:53 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-05-06 21:19:53 +0200
commit2c43ad2f4440571a1fadb6830f14d7a3f1ad2020 (patch)
tree76b78116acb768f6379d3425bace15cc7069bfe9 /apt/cache.py
parentd9096e08b64c0e917bcfcce29f498fa47a6d7db4 (diff)
parentb285f7334fc4aa735993a057c8788876620e55cb (diff)
downloadpython-apt-2c43ad2f4440571a1fadb6830f14d7a3f1ad2020.tar.gz
* merged from debian, remaining changes:
- updated mirrors - build python2.4 - use DH_PYCENTRAL=include-links - use --install-layout=deb - pre-build.sh: update ubuntu mirrors on bzr-buildpackage * apt/package.py: Handle cases where no candidate is available, by returning None in the candidate property. (Closes: #523801) * apt/package.py: Handle cases where no candidate is available and one of the deprecated properties (e.g. candidateVersion) is requested. (Closes: #523801) * setup.py, debian/rules: Support version in setup.py again by getting the value from the variable DEBVER (defined in debian/rules), falling back to None. * Build-Depend on python-debian, use it to get version number from changelog * Depend on libjs-jquery, and remove internal copy (Closes: #521532) * apt/package.py: - Introduce Version.{uri,uris,fetch_binary()} * debian/control: - Remove mdz from Uploaders (Closes: #521477), add myself. - Update Standards-Version to 3.8.1 - Use ${binary:Version} instead of ${Source-Version} - Fix spelling error: python -> Python * debian/copyright: Switch to machine-interpretable copyright * Fix documentation building - doc/source/conf.py: Only include directories for current python version. - debian/control: Build-Depend on python-gtk2, python-vte. - setup.py: If pygtk can not be imported, do not build the documentation. * Breaks: debdelta (<< 0.28~) to avoid more problems due to the internal API changes from 0.7.9. * apt/gtk/widgets.py: - Handle older versions of python-gobject which do not ship glib * apt/package.py: Introduce the Version class - Deprecate Package.candidate*() and Package.installed*(), except for installedFiles. - Provide Version.get_source() (LP: #118788) - Provide Package.versions (Closes: #513236) * apt/progress/: New package, replaces apt.progress and apt.gtk - apt/progress/gtk2.py: Moved here from apt/gtk/widgets.py - apt/progress/__init__.py: Move here from apt/progress.py * doc/source/*: Improve the documentation - Document more attributes and functions of apt_pkg (they are all listed) * aptsources/distro.py: - use iso_3166.xml instead of iso_3166.tab - fix incorrect indent * debian/control: - add Recommends to iso-codes (for iso_3166.xml) * apt/package.py: - make sure to set the defaulttimeout back to the original value (in getChangelog(), LP: #314212) Closes: #513315 * apt/cache.py: - when setting a alternative rootdir, read the config from it as well * python/configuration.cc, python/apt_pkgmodule.cc: - add apt_pkg.ReadConfigDir() * python/cache.cc, tests/getcache_mem_corruption.py: - test if progress objects have the right methods and raise error if not (thanks to Emanuele Rocca) closes: #497049 * apt/package.py: - avoid uneeded interal references in the Package objects * aptsources/sourceslist.py: - fix bug in invalid lines detection (LP: #324614)
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 01c12c94..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:
@@ -90,13 +91,11 @@ class Cache(object):
last=i
# drop stuff with no versions (cruft)
if len(pkg.VersionList) > 0:
- self._dict[pkg.Name] = Package(self._cache, self._depcache,
- self._records, self._list,
- self, pkg)
+ 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):
@@ -156,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)
@@ -450,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()