summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-01-30 15:46:34 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2012-01-30 15:46:34 +0100
commit5cc2cc92346239274953f3795f9b3d0ec5534246 (patch)
treed9096b97878b35c3c458fac0f7c88acae3469d65
parent38165cbeb26313bb468dcf527a843ba55571a8f2 (diff)
parent055dc32f4025f081293cee32cde935100532c651 (diff)
downloadpython-apt-5cc2cc92346239274953f3795f9b3d0ec5534246.tar.gz
GREEN: apt.Version has a "policy_priority" property
-rw-r--r--apt/package.py11
-rw-r--r--debian/changelog1
-rw-r--r--po/python-apt.pot8
-rw-r--r--tests/test_policy.py11
4 files changed, 25 insertions, 6 deletions
diff --git a/apt/package.py b/apt/package.py
index 81f33a8b..73f68c87 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -409,6 +409,17 @@ class Version(object):
return self._cand.priority_str
@property
+ def policy_priority(self):
+ """Return the internal policy priority as a number.
+ See apt_preferences(5) for more information about what it means.
+ """
+ priority = 0
+ policy = self.package._pcache._depcache.policy
+ for (packagefile, _) in self._cand.file_list:
+ priority = max(priority, policy.get_priority(packagefile))
+ return priority
+
+ @property
def record(self):
"""Return a Record() object for this version.
diff --git a/debian/changelog b/debian/changelog
index 7f582bff..1e400dfb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ python-apt (0.8.4) UNRELEASED; urgency=low
* doc/examples/build-deps.py:
- update the build-deps.py example to use the apt API more
+ * add support for apt_pkg.Policy.get_priority(PkgFileIterator)
-- Michael Vogt <michael.vogt@ubuntu.com> Wed, 04 Jan 2012 12:07:48 +0100
diff --git a/po/python-apt.pot b/po/python-apt.pot
index b99c36e1..02c65f13 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: 2012-01-30 15:32+0100\n"
+"POT-Creation-Date: 2012-01-30 15:44+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"
@@ -455,11 +455,11 @@ msgstr ""
msgid "Invalid unicode in description for '%s' (%s). Please report."
msgstr ""
-#: ../apt/package.py:1074 ../apt/package.py:1180
+#: ../apt/package.py:1085 ../apt/package.py:1191
msgid "The list of changes is not available"
msgstr ""
-#: ../apt/package.py:1186
+#: ../apt/package.py:1197
#, python-format
msgid ""
"The list of changes is not available yet.\n"
@@ -468,7 +468,7 @@ msgid ""
"until the changes become available or try again later."
msgstr ""
-#: ../apt/package.py:1193
+#: ../apt/package.py:1204
msgid ""
"Failed to download the list of changes. \n"
"Please check your Internet connection."
diff --git a/tests/test_policy.py b/tests/test_policy.py
index 2aab6722..d77fb27e 100644
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -11,7 +11,7 @@ import unittest
class TestAptPolicy(unittest.TestCase):
- def test_apt_policy(self):
+ def test_apt_policy_lowlevel(self):
# get a policy
cache = apt.Cache()
policy = cache._depcache.policy
@@ -23,10 +23,17 @@ class TestAptPolicy(unittest.TestCase):
for ver in pkg.versions:
lowlevel_ver = ver._cand
for pkgfile, i in lowlevel_ver.file_list:
- #print verfile, i, policy.get_priority(pkgfile)
+ #print pkgfile, i, policy.get_priority(pkgfile)
self.assertTrue(policy.get_priority(pkgfile) > 1)
self.assertTrue(policy.get_priority(pkgfile) < 1001)
+ def test_apt_policy_highlevel(self):
+ cache = apt.Cache()
+ pkg = cache["apt"]
+ self.assertTrue(pkg.candidate.policy_priority > 1 and
+ pkg.candidate.policy_priority < 1001)
+
+
if __name__ == "__main__":
unittest.main()