summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2011-03-21 14:48:47 +0100
committerMichael Vogt <mvo@debian.org>2011-03-21 14:48:47 +0100
commit5050f5f7c7f4b1fdd8bfec37c8baead2237e4f2d (patch)
tree07a4a5b10e9d9900501d43f76bd86593172efce1
parentbe46a92a5621d2c199792ead5371afb979f32f9c (diff)
parent22ab3421fbb8e936c3e6e32175a04ad801d7f511 (diff)
downloadpython-apt-5050f5f7c7f4b1fdd8bfec37c8baead2237e4f2d.tar.gz
merged from mvo
-rw-r--r--debian/changelog8
-rw-r--r--doc/source/library/apt_pkg.rst5
-rw-r--r--python/apt_pkgmodule.cc6
-rw-r--r--tests/test_deps.py8
4 files changed, 23 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 9559587d..0641983d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,8 +19,14 @@ python-apt (0.7.100.2) UNRELEASED; urgency=low
* py3 compatible exception handline
* debian/control:
- bump minimal python version to >= 2.6
+ * 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> Fri, 18 Feb 2011 22:34:09 +0100
+ -- Michael Vogt <mvo@debian.org> Mon, 21 Mar 2011 14:48:35 +0100
python-apt (0.7.100.1) unstable; urgency=low
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 cacbf77a..d1ac33e0 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -189,12 +189,14 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
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);
@@ -205,7 +207,7 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
break;
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op,
- ParseArchFlags);
+ ParseArchFlags, StripMultiArch);
if (Start == 0)
{
PyErr_SetString(PyExc_ValueError,"Problem Parsing Dependency");
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)")