diff options
| author | Michael Vogt <mvo@debian.org> | 2014-06-10 16:44:03 +0200 |
|---|---|---|
| committer | Michael Vogt <mvo@debian.org> | 2014-06-10 16:44:03 +0200 |
| commit | 1b6b123a052ca2d53e90b62da09ce300d701265a (patch) | |
| tree | 2279c1f66853c40413a1bfb1c758368037d8b7c1 /python/pkgsrcrecords.cc | |
| parent | 9de6a183f09f0d0adbcc5817872c5a0024f5ef47 (diff) | |
| parent | 887406dbb341ed684cd898f15b133baac252bc25 (diff) | |
| download | python-apt-1b6b123a052ca2d53e90b62da09ce300d701265a.tar.gz | |
Merge remote-tracking branch 'mvo/feature/srcrec-enum' into debian/sid
Conflicts:
debian/control
Diffstat (limited to 'python/pkgsrcrecords.cc')
| -rw-r--r-- | python/pkgsrcrecords.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 6a60a9af..308299e2 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" + "Step to the next 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->Next(); + 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}, {} }; |
