diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-06-10 18:47:25 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-06-10 18:50:40 +0200 |
commit | e575cea699b7ebbf4d3045f4131075f7d0e415e6 (patch) | |
tree | e7fcb7068f7c5abe7e1c3b04b2f76e09ef65779a | |
parent | 133453cd78109e10f9f23168ba3e5923e9afffae (diff) | |
download | python-apt-e575cea699b7ebbf4d3045f4131075f7d0e415e6.tar.gz |
add apt_pkg.SourceRecords.step() to all steping through all SrcRecords
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | python/pkgsrcrecords.cc | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/debian/control b/debian/control index ce5eecb3..9d112644 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Build-Depends: apt (>= 0.9.6), apt-utils, debhelper (>= 9), fakeroot, - libapt-pkg-dev (>= 0.9.16.1), + libapt-pkg-dev (>= 1.0.4~), python-all-dev (>= 2.7), python-all-dbg, python3-all-dev (>= 3.3), diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 6a60a9af..6f80731d 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->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",PkgSrcRecordsNext,METH_VARARGS,doc_PkgSrcRecordsNext}, {} }; |