From d724db2ef374c97e05f19d6e0bedb6a933426147 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 27 Jul 2009 11:17:52 +0200 Subject: * python/tag.cc: - merge patch from John Wright that adds FindRaw method (closes: #538723) --- debian/changelog | 8 +++++++- python/tag.cc | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5a5b7529..e0bc5a6f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,15 @@ python-apt (0.7.11.1) UNRELEASED; urgency=low + [ Stephan Peijnik ] * apt/progress/__init__.py: - Exception handling fixes in InstallProgress class. + + [ Michael Vogt ] + * python/tag.cc: + - merge patch from John Wright that adds FindRaw method + (closes: #538723) - -- Stephan Peijnik Sat, 25 Jul 2009 10:37:11 +0200 + -- Michael Vogt Mon, 27 Jul 2009 11:17:27 +0200 python-apt (0.7.11.0) unstable; urgency=low diff --git a/python/tag.cc b/python/tag.cc index 217be290..6fe97ed5 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -92,6 +92,29 @@ static PyObject *TagSecFind(PyObject *Self,PyObject *Args) return PyString_FromStringAndSize(Start,Stop-Start); } +static char *doc_FindRaw = "FindRaw(Name) -> String/None"; +static PyObject *TagSecFindRaw(PyObject *Self,PyObject *Args) +{ + char *Name = 0; + char *Default = 0; + if (PyArg_ParseTuple(Args,"s|z",&Name,&Default) == 0) + return 0; + + unsigned Pos; + if (GetCpp(Self).Find(Name,Pos) == false) + { + if (Default == 0) + Py_RETURN_NONE; + return PyString_FromString(Default); + } + + const char *Start; + const char *Stop; + GetCpp(Self).Get(Start,Stop,Pos); + + return PyString_FromStringAndSize(Start,Stop-Start); +} + static char *doc_FindFlag = "FindFlag(Name) -> integer/none"; static PyObject *TagSecFindFlag(PyObject *Self,PyObject *Args) { @@ -355,6 +378,7 @@ static PyMethodDef TagSecMethods[] = { // Query {"Find",TagSecFind,METH_VARARGS,doc_Find}, + {"FindRaw",TagSecFindRaw,METH_VARARGS,doc_FindRaw}, {"FindFlag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, {"Bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, -- cgit v1.2.3