diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-30 15:25:37 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-30 15:25:37 +0100 |
| commit | 2021c1b4973c3201b1e4580d00b7351c23a831c4 (patch) | |
| tree | ad93be852c4b8eec0b5d4e8fafda5a0bde3f9352 | |
| parent | 6c8269fc130c66d4a450a004af4e120e074808ce (diff) | |
| download | python-apt-2021c1b4973c3201b1e4580d00b7351c23a831c4.tar.gz | |
RED: policy should support verfile
| -rw-r--r-- | po/python-apt.pot | 50 | ||||
| -rw-r--r-- | python/cache.cc | 7 | ||||
| -rw-r--r-- | tests/test_policy.py | 31 |
3 files changed, 63 insertions, 25 deletions
diff --git a/po/python-apt.pot b/po/python-apt.pot index f1aecc59..a7cf0a8d 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-12-08 20:01+0100\n" +"POT-Creation-Date: 2012-01-30 15:16+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" @@ -410,7 +410,7 @@ msgid "Non-DFSG-compatible Software" msgstr "" #. TRANSLATORS: %s is a country -#: ../aptsources/distro.py:210 ../aptsources/distro.py:438 +#: ../aptsources/distro.py:206 ../aptsources/distro.py:434 #, python-format msgid "Server for %s" msgstr "" @@ -418,35 +418,35 @@ msgstr "" #. More than one server is used. Since we don't handle this case #. in the user interface we set "custom servers" to true and #. append a list of all used servers -#: ../aptsources/distro.py:228 ../aptsources/distro.py:234 -#: ../aptsources/distro.py:250 +#: ../aptsources/distro.py:224 ../aptsources/distro.py:230 +#: ../aptsources/distro.py:246 msgid "Main server" msgstr "" -#: ../aptsources/distro.py:254 +#: ../aptsources/distro.py:250 msgid "Custom servers" msgstr "" -#: ../apt/progress/gtk2.py:261 ../apt/progress/gtk2.py:317 +#: ../apt/progress/gtk2.py:258 ../apt/progress/gtk2.py:314 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "" -#: ../apt/progress/gtk2.py:267 ../apt/progress/gtk2.py:323 +#: ../apt/progress/gtk2.py:264 ../apt/progress/gtk2.py:320 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "" #. Setup some child widgets -#: ../apt/progress/gtk2.py:343 +#: ../apt/progress/gtk2.py:340 msgid "Details" msgstr "" -#: ../apt/progress/gtk2.py:431 +#: ../apt/progress/gtk2.py:428 msgid "Starting..." msgstr "" -#: ../apt/progress/gtk2.py:437 +#: ../apt/progress/gtk2.py:434 msgid "Complete" msgstr "" @@ -479,18 +479,18 @@ msgstr "" msgid "List of files for '%s' could not be read" msgstr "" -#: ../apt/debfile.py:205 +#: ../apt/debfile.py:202 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "" -#: ../apt/debfile.py:226 +#: ../apt/debfile.py:223 #, 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:371 +#: ../apt/debfile.py:364 #, 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:387 +#: ../apt/debfile.py:380 #, python-format msgid "" "Breaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s " "%(targetver)s)" msgstr "" -#: ../apt/debfile.py:397 +#: ../apt/debfile.py:390 #, 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:445 +#: ../apt/debfile.py:438 msgid "No Architecture field in the package" msgstr "" -#: ../apt/debfile.py:455 +#: ../apt/debfile.py:448 #, python-format msgid "Wrong architecture '%s'" msgstr "" #. the deb is older than the installed -#: ../apt/debfile.py:462 +#: ../apt/debfile.py:455 msgid "A later version is already installed" msgstr "" -#: ../apt/debfile.py:487 +#: ../apt/debfile.py:480 msgid "Failed to satisfy all dependencies (broken cache)" msgstr "" -#: ../apt/debfile.py:517 +#: ../apt/debfile.py:510 #, python-format msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:561 +#: ../apt/debfile.py:554 msgid "Python-debian module not available" msgstr "" -#: ../apt/debfile.py:604 +#: ../apt/debfile.py:597 msgid "" "Automatically decompressed:\n" "\n" msgstr "" -#: ../apt/debfile.py:610 +#: ../apt/debfile.py:603 msgid "Automatically converted to printable ascii:\n" msgstr "" -#: ../apt/debfile.py:700 +#: ../apt/debfile.py:693 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:711 +#: ../apt/debfile.py:704 msgid "An essential package would be removed" msgstr "" diff --git a/python/cache.cc b/python/cache.cc index b263d320..191e2204 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -229,6 +229,12 @@ static PyObject *PkgCacheGetGroups(PyObject *Self, void*) { return CppPyObject_NEW<GrpListStruct>(Self,&PyGroupList_Type,Cache->GrpBegin()); } +static PyObject *PkgCacheGetPolicy(PyObject *Self, void*) { + pkgCacheFile *CacheFile = GetCpp<pkgCacheFile *>(Self); + std::cerr << "policy: " << CacheFile->Policy << std::endl; + return CppPyObject_NEW<pkgPolicy*>(Self,&PyPolicy_Type,CacheFile->Policy); +} + static PyObject *PkgCacheGetPackages(PyObject *Self, void*) { pkgCache *Cache = GetCpp<pkgCache *>(Self); return CppPyObject_NEW<PkgListStruct>(Self,&PyPackageList_Type,Cache->PkgBegin()); @@ -289,6 +295,7 @@ static PyGetSetDef PkgCacheGetSet[] = { {"group_count",PkgCacheGetGroupCount,0, "The number of apt_pkg.Group objects stored in the cache."}, {"groups", PkgCacheGetGroups, 0, "A list of Group objects in the cache"}, + {"policy", PkgCacheGetPolicy, 0, "The PkgPolicy for the cache"}, {"is_multi_arch", PkgCacheGetIsMultiArch, 0, "Whether the cache supports multi-arch."}, {"package_count",PkgCacheGetPackageCount,0, diff --git a/tests/test_policy.py b/tests/test_policy.py new file mode 100644 index 00000000..2d261f5f --- /dev/null +++ b/tests/test_policy.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# +# Copyright (C) 2012 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 +# notice and this notice are preserved. + +import apt +import unittest + +class TestAptPolicy(unittest.TestCase): + + def test_apt_policy(self): + # get a policy + cache = apt.Cache() + policy = cache._depcache.policy + self.assertNotEqual(policy, None) + # basic tests + pkg = cache["apt"] + self.assertEqual(policy.get_priority(pkg._pkg), 0) + # get verfile + ver = pkg.candidate._cand + verfile_list = ver.file_list + for verfile in verfile_list: + print verfile + self.assertEqual(policy.get_priority(verfile), 500) + + +if __name__ == "__main__": + unittest.main() |
