summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-08-27 15:06:54 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-08-27 15:06:54 +0200
commit980c1cbd0d883c9e429aaa64633680456a0a776d (patch)
treee2c23a0808bc816dd3e1cda9cf2fe8189420ce72
parent6d564eafe80ebe60c91587dd1bb70a666b70485d (diff)
downloadpython-apt-980c1cbd0d883c9e429aaa64633680456a0a776d.tar.gz
add "provides" property to the apt.Version objects
-rw-r--r--apt/package.py5
-rw-r--r--debian/changelog1
-rw-r--r--tests/test_apt_cache.py3
3 files changed, 9 insertions, 0 deletions
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 761742ca..9478bf89 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,6 +21,7 @@ python-apt (0.7.97) UNRELEASED; urgency=low
- return long long when calling TotalNeeded(), FetchNeeded() and
PartialPresent() from pkgAcquire(). This follows the change
in libapt.
+ * add "provides" property to the apt.Version objects
-- Julian Andres Klode <jak@debian.org> Fri, 23 Jul 2010 16:14:39 +0200
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index a43e92d2..2ace0201 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
@@ -50,6 +51,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, [])
@@ -58,6 +60,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):