diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-11-22 18:01:26 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-11-22 18:01:26 +0100 |
| commit | b7b608bf2c66e7466313ea02568348aea9cc29ba (patch) | |
| tree | 2cfcdd1eed42ac86182e8e009b2c7f52c43d8bf3 /apt | |
| parent | 92cc00805d175dc013d544bcee603e8a0c031c2b (diff) | |
| download | python-apt-b7b608bf2c66e7466313ea02568348aea9cc29ba.tar.gz | |
cleanup based on feedback from juliank
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/cache.py | 10 | ||||
| -rw-r--r-- | apt/debfile.py | 19 |
2 files changed, 21 insertions, 8 deletions
diff --git a/apt/cache.py b/apt/cache.py index 8a456715..b4d67fa5 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 104b0814..5b9274b2 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 ValueError("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 ValueError("property only available after check() was run") for pkg in self._cache: if pkg.marked_install or pkg.marked_upgrade: install.append(pkg.name) @@ -641,7 +645,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(): @@ -649,6 +654,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) |
