diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-08 17:26:10 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-08 17:26:10 +0100 |
| commit | 5fef756d94f52495fa1703d2d27ba73e708c4442 (patch) | |
| tree | df7d6a7fa189c480f108655204cb88b514418f1e | |
| parent | d236f527f85b185144875e0e7ad9102c4c2dabd0 (diff) | |
| parent | d686a36d94e909eefc13403391ee60938f54df5c (diff) | |
| download | python-apt-5fef756d94f52495fa1703d2d27ba73e708c4442.tar.gz | |
merged from debian
| -rw-r--r-- | apt/cache.py | 10 | ||||
| -rw-r--r-- | apt/debfile.py | 19 | ||||
| -rw-r--r-- | apt/package.py | 4 | ||||
| -rw-r--r-- | debian/changelog | 25 | ||||
| -rw-r--r-- | po/python-apt.pot | 48 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 2 | ||||
| -rw-r--r-- | tests/test_debfile.py | 7 |
7 files changed, 65 insertions, 50 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. diff --git a/debian/changelog b/debian/changelog index 569c335d..4a90e907 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.8.2) UNRELEASED; urgency=low +python-apt (0.8.2) unstable; urgency=low [ Michael Vogt ] * merged from ubuntu: @@ -18,10 +18,18 @@ python-apt (0.8.2) UNRELEASED; urgency=low * apt/cache.py: - remove "print" when creating dirs in apt.Cache(rootdir=dir), thanks to Martin Pitt - * fix build against apt in experimental + - add __lt__ to apt.Package so that sort() sorts by name + on list of package objects + * debian/control: + - add recommends to xz-lzma to ensure we have the unlzma command * apt/cache.py: - set Dir::bin::dpkg if a alternate rootdir is given (LP: #885895) + * build fixes for the apt in experimental + * apt/debfile.py: + - raise error when accessing require_changes and + missing_deps without calling check() before, thanks to + Tshepang Lekhonkhobe (closes: #624379) * apt/package.py: - add new "suggests" property, thanks to Christop Groth - allow Dependency object to be iteratable, this allows to write @@ -38,15 +46,12 @@ python-apt (0.8.2) UNRELEASED; urgency=low [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) * grammar fix in the cache.py doc (closes: #626610) - * apt/debfile.py: Remove the need to explcitly call check() in order - to get output from require_changes and missing_deps - (closes: #624379) [ Nikola Pavlović ] * fixed a typo, changed "Open Source software" to "free and open-source software" (LP: #500940) - -- Michael Vogt <mvo@debian.org> Wed, 19 Oct 2011 18:03:42 +0200 + -- Michael Vogt <mvo@debian.org> Thu, 01 Dec 2011 14:14:42 +0100 python-apt (0.8.1) unstable; urgency=low @@ -76,14 +81,6 @@ python-apt (0.8.1) unstable; urgency=low that needs universe enabled as well (plus add test) * apt/progress/gtk2.py: - update to the latest vte API for child-exited (LP: #865388) - * tests/test_apt_cache.py: - - add __cmp__ to apt.Package so that sort() sorts by name - on list of package objects - * tests/test_aptsources.py: - - use unlzma from xz-utils instead of lzma to follow what dpkg - is using (LP: #868188) - * debian/control: - - add recommends to xz-lzma to ensure we have the unlzma command -- Michael Vogt <mvo@debian.org> Wed, 19 Oct 2011 16:39:13 +0200 diff --git a/po/python-apt.pot b/po/python-apt.pot index 046f5779..8772e88b 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-10 17:20+0100\n" +"POT-Creation-Date: 2011-12-01 13:58+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -190,7 +190,7 @@ msgstr "" #. CompDescriptionLong #: ../data/templates/Ubuntu.info.in:957 -msgid "Canonical-supported Open Source software" +msgid "Canonical-supported free and open-source software" msgstr "" #. CompDescription @@ -200,7 +200,7 @@ msgstr "" #. CompDescriptionLong #: ../data/templates/Ubuntu.info.in:960 -msgid "Community-maintained Open Source software" +msgid "Community-maintained free and open-source software" msgstr "" #. CompDescription @@ -450,16 +450,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:358 +#: ../apt/package.py:359 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:1068 ../apt/package.py:1174 +#: ../apt/package.py:1074 ../apt/package.py:1180 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:1180 +#: ../apt/package.py:1186 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -468,29 +468,29 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:1187 +#: ../apt/package.py:1193 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." msgstr "" -#: ../apt/debfile.py:82 +#: ../apt/debfile.py:84 #, python-format msgid "List of files for '%s' could not be read" msgstr "" -#: ../apt/debfile.py:167 +#: ../apt/debfile.py:169 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "" -#: ../apt/debfile.py:188 +#: ../apt/debfile.py:190 #, python-format msgid "Conflicts with the installed package '%s'" msgstr "" #. TRANSLATORS: the first '%s' is the package that breaks, the second the dependency that makes it break, the third the relation (e.g. >=) and the latest the version for the releation -#: ../apt/debfile.py:327 +#: ../apt/debfile.py:329 #, python-format msgid "" "Breaks existing package '%(pkgname)s' dependency %(depname)s " @@ -498,63 +498,63 @@ msgid "" msgstr "" #. TRANSLATORS: the first '%s' is the package that conflicts, the second the packagename that it conflicts with (so the name of the deb the user tries to install), the third is the relation (e.g. >=) and the last is the version for the relation -#: ../apt/debfile.py:343 +#: ../apt/debfile.py:345 #, python-format msgid "" "Breaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s " "%(targetver)s)" msgstr "" -#: ../apt/debfile.py:353 +#: ../apt/debfile.py:355 #, python-format msgid "" "Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But " "the '%(debfile)s' provides it via: '%(provides)s'" msgstr "" -#: ../apt/debfile.py:399 +#: ../apt/debfile.py:403 msgid "No Architecture field in the package" msgstr "" -#: ../apt/debfile.py:404 +#: ../apt/debfile.py:408 #, python-format msgid "Wrong architecture '%s'" msgstr "" #. the deb is older than the installed -#: ../apt/debfile.py:411 +#: ../apt/debfile.py:415 msgid "A later version is already installed" msgstr "" -#: ../apt/debfile.py:436 +#: ../apt/debfile.py:440 msgid "Failed to satisfy all dependencies (broken cache)" msgstr "" -#: ../apt/debfile.py:466 +#: ../apt/debfile.py:470 #, python-format msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:510 +#: ../apt/debfile.py:514 msgid "Python-debian module not available" msgstr "" -#: ../apt/debfile.py:544 +#: ../apt/debfile.py:557 msgid "" "Automatically decompressed:\n" "\n" msgstr "" -#: ../apt/debfile.py:550 +#: ../apt/debfile.py:563 msgid "Automatically converted to printable ascii:\n" msgstr "" -#: ../apt/debfile.py:640 +#: ../apt/debfile.py:653 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:650 +#: ../apt/debfile.py:664 msgid "An essential package would be removed" msgstr "" @@ -605,6 +605,6 @@ msgstr "" msgid "Please insert a Disc in the drive and press enter" msgstr "" -#: ../apt/cache.py:148 +#: ../apt/cache.py:158 msgid "Building data structures" msgstr "" diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 7784a25f..6ec04ed5 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -182,7 +182,7 @@ class TestAptCache(unittest.TestCase): apt_pkg.config.set("dir::etc::sourceparts", old_source_parts) def test_package_cmp(self): - cache = apt.Cache() + cache = apt.Cache(rootdir="/") l = [] l.append(cache["libc6"]) l.append(cache["xterm"]) diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 70979689..af04af26 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -114,6 +114,12 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") self.assertEqual(deb.filelist, ["./", "usr/", "usr/bin/"]) + def test_check_exception(self): + deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") + self.assertRaises(AttributeError, lambda: deb.missing_deps) + deb.check() + deb.missing_deps + def test_no_supported_data_tar(self): # ensure that a unknown data.tar.xxx raises a exception raised = False @@ -132,7 +138,6 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading deb = apt.debfile.DebPackage("./data/test_debs/multiarch-test1_i386.deb") res = deb.check() # FIXME: do something sensible with the multiarch test - |
