summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-12-08 17:26:10 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-12-08 17:26:10 +0100
commit5fef756d94f52495fa1703d2d27ba73e708c4442 (patch)
treedf7d6a7fa189c480f108655204cb88b514418f1e /apt
parentd236f527f85b185144875e0e7ad9102c4c2dabd0 (diff)
parentd686a36d94e909eefc13403391ee60938f54df5c (diff)
downloadpython-apt-5fef756d94f52495fa1703d2d27ba73e708c4442.tar.gz
merged from debian
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py10
-rw-r--r--apt/debfile.py19
-rw-r--r--apt/package.py4
3 files changed, 23 insertions, 10 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 8a456715..96b38a57 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -46,7 +46,13 @@ class LockFailedException(IOError):
class Cache(object):
"""Dictionary-like package cache.
- The dictionary of this class contains all available packages.
+ The APT cache file contains a hash table mapping names of binary
+ packages to their metadata. A Cache object is the in-core
+ representation of the same. It provides access to APTs idea of the
+ list of available packages.
+
+ The cache can be used like a mapping from package names to Package
+ objects (although only getting items is supported).
Keyword arguments:
progress -- a OpProgress object
@@ -510,7 +516,7 @@ class Cache(object):
self._callbacks[name].append(callback)
def actiongroup(self):
- """Return an action group object for the current cache.
+ """Return an `ActionGroup` object for the current cache.
Action groups can be used to speedup actions. The action group is
active as soon as it is created, and disabled when the object is
diff --git a/apt/debfile.py b/apt/debfile.py
index a7202eba..c91ce349 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -53,6 +53,7 @@ class DebPackage(object):
self.pkgname = ""
self._sections = {}
self._need_pkgs = []
+ self._check_was_run = False
self._failure_string = ""
if filename:
self.open(filename)
@@ -68,7 +69,8 @@ class DebPackage(object):
control = self._debfile.control.extractdata("control")
self._sections = apt_pkg.TagSection(control)
self.pkgname = self._sections["Package"]
-
+ self._check_was_run = False
+
def __getitem__(self, key):
return self._sections[key]
@@ -393,6 +395,8 @@ class DebPackage(object):
"""Check if the package is installable."""
self._dbg(3, "check")
+ self._check_was_run = True
+
# check arch
if not "Architecture" in self._sections:
self._dbg(1, "ERROR: no architecture field")
@@ -472,8 +476,8 @@ class DebPackage(object):
def missing_deps(self):
"""Return missing dependencies."""
self._dbg(1, "Installing: %s" % self._need_pkgs)
- if not self._need_pkgs:
- self.check()
+ if not self._check_was_run:
+ raise AttributeError("property only available after check() was run")
return self._need_pkgs
@property
@@ -485,8 +489,8 @@ class DebPackage(object):
install = []
remove = []
unauthenticated = []
- if not self._cache:
- self.check()
+ if not self._check_was_run:
+ raise AttributeError("property only available after check() was run")
for pkg in self._cache:
if pkg.marked_install or pkg.marked_upgrade:
install.append(pkg.name)
@@ -650,7 +654,8 @@ class DscSrcPackage(DebPackage):
"source package '%s' that builds %s\n") % (self.pkgname,
" ".join(self.binaries))
self._sections["Description"] = s
-
+ self._check_was_run = False
+
def check(self):
"""Check if the package is installable.."""
if not self.check_conflicts():
@@ -658,6 +663,8 @@ class DscSrcPackage(DebPackage):
if self._cache[pkgname]._pkg.essential:
raise Exception(_("An essential package would be removed"))
self._cache[pkgname].mark_delete()
+ # properties are ok now
+ self._check_was_run = True
# FIXME: a additional run of the check_conflicts()
# after _satisfy_depends() should probably be done
return self._satisfy_depends(self.depends)
diff --git a/apt/package.py b/apt/package.py
index 8b79c420..81f33a8b 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -713,8 +713,8 @@ class Package(object):
return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name,
self._pkg.architecture, self._pkg.id)
- def __cmp__(self, other):
- return cmp(self.name, other.name)
+ def __lt__(self, other):
+ return self.name < other.name
def candidate(self):
"""Return the candidate version of the package.