diff options
Diffstat (limited to 'python/pkgsrcrecords.cc')
| -rw-r--r-- | python/pkgsrcrecords.cc | 62 |
1 files changed, 24 insertions, 38 deletions
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 4c889129..6ec4e63c 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -75,10 +75,34 @@ static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static char *doc_PkgSrcRecordsStep = + "step() -> bool\n\n" + "Go to the source package. Each call moves\n" + "the position of the records parser forward. If there are no\n" + "more records, return None. If the lookup failed this way,\n" + "access to any of the attributes will result in an AttributeError."; +static PyObject *PkgSrcRecordsStep(PyObject *Self,PyObject *Args) +{ + PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self); + + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + + Struct.Last = (pkgSrcRecords::Parser*)Struct.Records->Step(); + if (Struct.Last == 0) { + Struct.Records->Restart(); + Py_INCREF(Py_None); + return HandleErrors(Py_None); + } + + return PyBool_FromLong(1); +} + static PyMethodDef PkgSrcRecordsMethods[] = { {"lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, {"restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, + {"step",PkgSrcRecordsStep,METH_VARARGS,doc_PkgSrcRecordsStep}, {} }; @@ -205,29 +229,6 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { return Dict; } -#ifdef COMPAT_0_7 -static PyObject *PkgSrcRecordsGetBuildDepends_old(PyObject *Self,void*) { - PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends"); - if (Struct.Last == 0) - return 0; - PyObject *List = PyList_New(0); - - vector<pkgSrcRecords::Parser::BuildDepRec> bd; - if(!Struct.Last->BuildDepends(bd, false /* arch-only*/)) - return NULL; // error - - PyObject *v; - for(unsigned int i=0;i<bd.size();i++) { - v = Py_BuildValue("(ssNN)", bd[i].Package.c_str(), - bd[i].Version.c_str(), - MkPyNumber(bd[i].Op), - MkPyNumber(bd[i].Type)); - PyList_Append(List, v); - Py_DECREF(v); - } - return List; -} -#endif static PyGetSetDef PkgSrcRecordsGetSet[] = { {"binaries",PkgSrcRecordsGetBinaries,0, @@ -251,9 +252,6 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { "The section of the source package."}, {"version",PkgSrcRecordsGetVersion,0, "The version of the source package."}, -#ifdef COMPAT_0_7 - {"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."}, -#endif {} }; @@ -316,15 +314,3 @@ PyTypeObject PySourceRecords_Type = /*}}}*/ -#ifdef COMPAT_0_7 -PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is " - "deprecated. Please see apt_pkg.SourceRecords() for the " - "replacement.", 1); - if (PyArg_ParseTuple(Args,"") == 0) - return 0; - - return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(NULL, &PySourceRecords_Type)); -} -#endif |
