summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-03-21 14:35:41 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-03-21 14:35:41 +0100
commit22ab3421fbb8e936c3e6e32175a04ad801d7f511 (patch)
tree9da265554ccf418c62f4e05023e3273577bd718e
parent2002bc4d51f80e630ea1b04964ba1d1210cf3da3 (diff)
downloadpython-apt-22ab3421fbb8e936c3e6e32175a04ad801d7f511.tar.gz
- add optional parameter to allow parse_depends() to keep the
multiarch parameter * tests/test_deps.py: - add test forapt_pkg.parse_depends(strip_multiarch=True)
-rw-r--r--debian/changelog4
-rw-r--r--doc/source/library/apt_pkg.rst5
-rw-r--r--python/apt_pkgmodule.cc7
-rw-r--r--tests/test_deps.py8
4 files changed, 20 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 0d890f44..97bdd506 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,10 @@ python-apt (0.7.100.2) UNRELEASED; urgency=low
- require new libapt-pkg-dev SetCandidateRelease()
* python/apt_pkgmodule.cc:
- strip multiarch by default in RealParseDepends
+ - add optional parameter to allow parse_depends() to keep the
+ multiarch parameter
+ * tests/test_deps.py:
+ - add test forapt_pkg.parse_depends(strip_multiarch=True)
-- Michael Vogt <mvo@debian.org> Tue, 07 Dec 2010 13:41:07 +0100
diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst
index f1bc4845..81358bac 100644
--- a/doc/source/library/apt_pkg.rst
+++ b/doc/source/library/apt_pkg.rst
@@ -1731,7 +1731,7 @@ Dependencies
The following two functions provide the ability to parse dependencies. They
use the same format as :attr:`Version.depends_list_str`.
-.. function:: parse_depends(depends)
+.. function:: parse_depends(depends, strip_multiarch=True)
Parse the string *depends* which contains dependency information as
specified in Debian Policy, Section 7.1.
@@ -1743,6 +1743,9 @@ use the same format as :attr:`Version.depends_list_str`.
>>> apt_pkg.parse_depends("PkgA (>= VerA) | PkgB (>= VerB)")
[[('PkgA', 'VerA', '>='), ('PkgB', 'VerB', '>=')]]
+ Note that multiarch dependency information is stripped off by default.
+ You can force the full dependency info (including the multiarch info)
+ by passing "False" as a additional parameter to this function.
.. note::
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 91e8d844..d1ac33e0 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -184,18 +184,19 @@ static const char *parse_src_depends_doc =
"configuration variable APT::Architecture";
static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
bool ParseArchFlags, string name,
- bool debStyle=false,
- bool StripMultiArch=true)
+ bool debStyle=false)
{
string Package;
string Version;
unsigned int Op;
+ bool StripMultiArch=true;
const char *Start;
const char *Stop;
int Len;
- if (PyArg_ParseTuple(Args,(char *)("s#:" + name).c_str(),&Start,&Len) == 0)
+ if (PyArg_ParseTuple(Args,(char *)("s#|b:" + name).c_str(),
+ &Start, &Len, &StripMultiArch) == 0)
return 0;
Stop = Start + Len;
PyObject *List = PyList_New(0);
diff --git a/tests/test_deps.py b/tests/test_deps.py
index 674c9485..e9a75ee2 100644
--- a/tests/test_deps.py
+++ b/tests/test_deps.py
@@ -61,6 +61,14 @@ class TestDependencies(unittest.TestCase):
self.assertFalse(apt_pkg.check_dep("1", ">>", "1"))
self.assertTrue(apt_pkg.check_dep("2", ">>", "1"))
+ def test_parse_depends_multiarch(self):
+ # strip multiarch
+ deps = apt_pkg.parse_depends("po4a:native", True)
+ self.assertEqual(deps[0][0][0], "po4a")
+ # do not strip multiarch
+ deps = apt_pkg.parse_depends("po4a:native", False)
+ self.assertEqual(deps[0][0][0], "po4a:native")
+
def test_parse_depends(self):
"""dependencies: Test apt_pkg.parse_depends()"""
deps = apt_pkg.parse_depends("p1a (<< 1a) | p1b (>> 1b)")