diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-08-31 15:34:04 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-08-31 15:34:04 +0200 |
| commit | 3ec4a3676de540d05286f3bdc41f00a799244f3b (patch) | |
| tree | 460e9e05ba521082d5f901fdd1452cbc9bf9c329 | |
| parent | 8cd715add7f85fb67cc30e42449d83a2ef7cf0bd (diff) | |
| parent | 96476d01e881f52d53a70f1ae700594a0f321056 (diff) | |
| download | python-apt-3ec4a3676de540d05286f3bdc41f00a799244f3b.tar.gz | |
* add "provides" property to the apt.Version objects
* apt/debfile.py:
- fix error when reading binary content and add regresion test
| -rw-r--r-- | apt/debfile.py | 4 | ||||
| -rw-r--r-- | apt/package.py | 5 | ||||
| -rw-r--r-- | debian/changelog | 3 | ||||
| -rw-r--r-- | python/acquire.cc | 6 | ||||
| -rw-r--r-- | python/cache.cc | 10 | ||||
| -rw-r--r-- | tests/data/test_debs/gdebi-test11.deb | bin | 0 -> 634 bytes | |||
| -rw-r--r-- | tests/data/test_debs/gdebi-test12.deb | bin | 0 -> 966 bytes | |||
| -rw-r--r-- | tests/test_apt_cache.py | 3 | ||||
| -rw-r--r-- | tests/test_debfile.py | 13 |
9 files changed, 34 insertions, 10 deletions
diff --git a/apt/debfile.py b/apt/debfile.py index 9bf27da3..f4a31379 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -512,7 +512,7 @@ class DebPackage(object): return sorted(content) @staticmethod - def to_hex(self, in_data): + def to_hex(in_data): hex = "" for (i, c) in enumerate(in_data): if i%80 == 0: @@ -521,7 +521,7 @@ class DebPackage(object): return hex @staticmethod - def to_strish(self, in_data): + def to_strish(in_data): s = "" for c in in_data: if ord(c) < 10 or ord(c) > 127: diff --git a/apt/package.py b/apt/package.py index 228a3385..871c1e16 100644 --- a/apt/package.py +++ b/apt/package.py @@ -415,6 +415,11 @@ class Version(object): return depends_list @property + def provides(self): + """ Return a list of names that this version provides.""" + return [p[0] for p in self._cand.provides_list] + + @property def enhances(self): """Return the list of enhances for the package version.""" return self.get_dependencies("Enhances") diff --git a/debian/changelog b/debian/changelog index 6f3ea91e..5e16f349 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ python-apt (0.7.97.2) UNRELEASED; urgency=low [ Michael Vogt ] * apt/debfile.py: - add missing init for _installed_conflicts (LP: #618597) + * add "provides" property to the apt.Version objects + * apt/debfile.py: + - fix error when reading binary content and add regresion test -- Michael Vogt <mvo@debian.org> Fri, 27 Aug 2010 11:22:23 +0200 diff --git a/python/acquire.cc b/python/acquire.cc index 6f9a1412..ab90bbdd 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -259,15 +259,15 @@ static PyMethodDef PkgAcquireMethods[] = { #define fetcher (GetCpp<pkgAcquire*>(Self)) static PyObject *PkgAcquireGetTotalNeeded(PyObject *Self,void*) { - return Py_BuildValue("d", fetcher->TotalNeeded()); + return Py_BuildValue("L", fetcher->TotalNeeded()); } static PyObject *PkgAcquireGetFetchNeeded(PyObject *Self,void*) { - return Py_BuildValue("d", fetcher->FetchNeeded()); + return Py_BuildValue("L", fetcher->FetchNeeded()); } static PyObject *PkgAcquireGetPartialPresent(PyObject *Self,void*) { - return Py_BuildValue("d", fetcher->PartialPresent()); + return Py_BuildValue("L", fetcher->PartialPresent()); } #undef fetcher diff --git a/python/cache.cc b/python/cache.cc index e31f6a65..e87d73d4 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -573,9 +573,8 @@ static PyGetSetDef PackageGetSet[] = { {"rev_depends_list",PackageGetRevDependsList,0, "An apt_pkg.DependencyList object of all reverse dependencies."}, {"provides_list",PackageGetProvidesList,0, - "A list of all packages providing this package. The list contains\n" - "tuples in the format (providesname, providesver, version)\n" - "where 'version' is an apt_pkg.Version object."}, + "Ignore it, it does nothing. You want to use\n" + "apt_pkg.Version.provides_list instead."}, {"selected_state",PackageGetSelectedState,0, "The state of the selection, which can be compared against the constants\n" "SELSTATE_DEINSTALL, SELSTATE_HOLD, SELSTATE_INSTALL, SELSTATE_PURGE,\n" @@ -979,8 +978,9 @@ static PyGetSetDef VersionGetSet[] = { {"priority_str",VersionGetPriorityStr,0, "The priority of the package, as a string."}, {"provides_list",VersionGetProvidesList,0, - "A list of all packages provided by this version. See\n" - "Package.provides_list for a description of the format."}, + "A list of all packages provided by this version. The list contains\n" + "tuples in the format (providesname, providesver, version)\n" + "where 'version' is an apt_pkg.Version object."}, {"section",VersionGetSection,0, "The section of this package version."}, {"size",VersionGetSize,0, diff --git a/tests/data/test_debs/gdebi-test11.deb b/tests/data/test_debs/gdebi-test11.deb Binary files differnew file mode 100644 index 00000000..af9b441f --- /dev/null +++ b/tests/data/test_debs/gdebi-test11.deb diff --git a/tests/data/test_debs/gdebi-test12.deb b/tests/data/test_debs/gdebi-test12.deb Binary files differnew file mode 100644 index 00000000..36544cc7 --- /dev/null +++ b/tests/data/test_debs/gdebi-test12.deb diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 81d64bc6..44b95cab 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -1,6 +1,7 @@ #!/usr/bin/python # # Copyright (C) 2010 Julian Andres Klode <jak@debian.org> +# 2010 Michael Vogt <mvo@ubuntu.com> # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -51,6 +52,7 @@ class TestAptCache(unittest.TestCase): # a true virtual pkg l = cache.get_providing_packages("mail-transport-agent") self.assertTrue(len(l) > 0) + self.assertTrue("postfix" in [p.name for p in l]) # this is a not virtual (transitional) package provided by another l = cache.get_providing_packages("scrollkeeper") self.assertEqual(l, []) @@ -59,6 +61,7 @@ class TestAptCache(unittest.TestCase): l = cache.get_providing_packages("scrollkeeper", include_nonvirtual=True) self.assertTrue(len(l), 1) + self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides) def test_dpkg_journal_dirty(self): diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 5874dfc4..42cda6f6 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -77,6 +77,19 @@ class TestDebfilee(unittest.TestCase): "Unexpected result for package '%s' (got %s wanted %s)\n%s" % ( filename, res, expected_res, deb._failure_string)) + def testContent(self): + # normal + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) + self.assertEqual('#!/bin/sh\necho "test"\n', + deb.data_content("usr/bin/test")) + # binary + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb")) + content = deb.data_content("usr/bin/binary") + self.assertTrue(content.startswith("Automatically converted to printable ascii:\n\x7fELF ")) + + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() |
