Commit 47e3d345 authored by Julian Andres Klode's avatar Julian Andres Klode

Add optional 'architecture' argument to parse_depends()

This follows the change after apt 1.4~beta2, hence the bump
in build-dependency.
parent 6ce94b3a
......@@ -11,7 +11,7 @@ Build-Depends: apt (>= 1.0.9.4),
debhelper (>= 9),
dh-python,
fakeroot,
libapt-pkg-dev (>= 1.1~exp9),
libapt-pkg-dev (>= 1.4~beta3),
python-all-dev (>= 2.7),
python-all-dbg,
python3-all-dev (>= 3.3),
......
......@@ -2110,7 +2110,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, strip_multiarch=True)
.. function:: parse_depends(depends, strip_multiarch=True, arch)
Parse the string *depends* which contains dependency information as
specified in Debian Policy, Section 7.1.
......@@ -2126,6 +2126,10 @@ use the same format as :attr:`Version.depends_list_str`.
You can force the full dependency info (including the multiarch info)
by passing "False" as a additional parameter to this function.
You can specify an optional argument *arch* that treats the given
architecture as the native architecture for purposes of parsing the
dependency.
.. note::
The behavior of this function is different than the behavior of the
......@@ -2134,7 +2138,7 @@ use the same format as :attr:`Version.depends_list_str`.
is specified in control files.
.. function:: parse_src_depends(depends)
.. function:: parse_src_depends(depends, strip_multiarch=True, arch)
Parse the string *depends* which contains dependency information as
specified in Debian Policy, Section 7.1.
......@@ -2153,6 +2157,14 @@ use the same format as :attr:`Version.depends_list_str`.
>>> apt_pkg.parse_src_depends("a (>= 01) [i386 amd64]")
[[('a', '01', '>=')]]
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.
You can specify an optional argument *arch* that treats the given
architecture as the native architecture for purposes of parsing the
dependency.
.. note::
The behavior of this function is different than the behavior of the
......
......@@ -140,7 +140,7 @@ static PyObject *UpstreamVersion(PyObject *Self,PyObject *Args)
}
static const char *doc_ParseDepends =
"parse_depends(s: str[, strip_multi_arch : bool = True]) -> list\n"
"parse_depends(s: str[, strip_multi_arch : bool = True[, arch : string]]) -> list\n"
"\n"
"Parse the dependencies given by 's' and return a list of lists. Each of\n"
"these lists represents one or more options for an 'or' dependency in\n"
......@@ -149,10 +149,12 @@ static const char *doc_ParseDepends =
"if no version was requested. The element 'ver' is a comparison\n"
"operator ('<', '<=', '=', '>=', or '>').\n\n"
"If 'strip_multi_arch' is True, :any (and potentially other special values)\n"
"will be stripped from the full package name";
"will be stripped from the full package name"
"The 'arch' parameter may be used to specify a non-native architecture for\n"
"the dependency parsing.";
static const char *parse_src_depends_doc =
"parse_src_depends(s: str[, strip_multi_arch : bool = True]) -> list\n"
"parse_src_depends(s: str[, strip_multi_arch : bool = True[, arch : string]]) -> list\n"
"\n"
"Parse the dependencies given by 's' and return a list of lists. Each of\n"
"these lists represents one or more options for an 'or' dependency in\n"
......@@ -165,7 +167,9 @@ static const char *parse_src_depends_doc =
"only contains those dependencies for the architecture set in the\n"
"configuration variable APT::Architecture\n\n"
"If 'strip_multi_arch' is True, :any (and potentially other special values)\n"
"will be stripped from the full package name";
"will be stripped from the full package name"
"The 'arch' parameter may be used to specify a non-native architecture for\n"
"the dependency parsing.";
static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
bool ParseArchFlags, bool ParseRestrictionsList,
std::string name, bool debStyle=false)
......@@ -178,9 +182,10 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
const char *Start;
const char *Stop;
int Len;
const char *Arch = NULL;
if (PyArg_ParseTuple(Args,(char *)("s#|b:" + name).c_str(),
&Start, &Len, &StripMultiArch) == 0)
if (PyArg_ParseTuple(Args,(char *)("s#|bs:" + name).c_str(),
&Start, &Len, &StripMultiArch, &Arch) == 0)
return 0;
Stop = Start + Len;
PyObject *List = PyList_New(0);
......@@ -189,10 +194,15 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
{
if (Start == Stop)
break;
if (Arch == NULL)
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op,
ParseArchFlags, StripMultiArch,
ParseRestrictionsList);
else
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op,
ParseArchFlags, StripMultiArch,
ParseRestrictionsList, Arch);
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op,
ParseArchFlags, StripMultiArch,
ParseRestrictionsList);
if (Start == 0)
{
PyErr_SetString(PyExc_ValueError,"Problem Parsing Dependency");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment