From 2002bc4d51f80e630ea1b04964ba1d1210cf3da3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Mar 2011 13:54:50 +0100 Subject: * python/apt_pkgmodule.cc: - strip multiarch by default in RealParseDepends --- python/apt_pkgmodule.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index cacbf77a..91e8d844 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -184,7 +184,8 @@ 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 debStyle=false, + bool StripMultiArch=true) { string Package; string Version; @@ -205,7 +206,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"); -- cgit v1.2.3 From 22ab3421fbb8e936c3e6e32175a04ad801d7f511 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Mar 2011 14:35:41 +0100 Subject: - 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) --- debian/changelog | 4 ++++ doc/source/library/apt_pkg.rst | 5 ++++- python/apt_pkgmodule.cc | 7 ++++--- tests/test_deps.py | 8 ++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'python') 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 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)") -- cgit v1.2.3