diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-03-22 14:56:29 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-03-22 14:56:29 +0100 |
| commit | e02913b6f336d4bf5bc2c17032c91ade974de04f (patch) | |
| tree | 3c3689a9f8d69eb45140d10d60b9e1d2d6b025bf /python | |
| parent | 4e7cf23803ea29eb90b9c663cb6ded845067a6c7 (diff) | |
| download | python-apt-e02913b6f336d4bf5bc2c17032c91ade974de04f.tar.gz | |
* fixes for the pkgSrcRecords code
Diffstat (limited to 'python')
| -rw-r--r-- | python/pkgrecords.cc | 2 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 27 |
2 files changed, 25 insertions, 4 deletions
diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index c6f5aeb9..ec78f554 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -46,7 +46,7 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) // always return true (to make it consistent with the pkgsrcrecords object return Py_BuildValue("i", 1); } - + static PyMethodDef PkgRecordsMethods[] = { {"Lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 252810c7..abb29c74 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -43,7 +43,6 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"s",&Name) == 0) return 0; - Struct.Records->Restart(); Struct.Last = Struct.Records->Find(Name, false); if (Struct.Last == 0) { Struct.Records->Restart(); @@ -54,9 +53,25 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) return Py_BuildValue("i", 1); } +static char *doc_PkgSrcRecordsRestart = "Start Lookup from the begining"; +static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) +{ + PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self); + + char *Name = 0; + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + + Struct.Records->Restart(); + + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} + static PyMethodDef PkgSrcRecordsMethods[] = { {"Lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, + {"Restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, {} }; @@ -126,10 +141,10 @@ PyTypeObject PkgSrcRecordsType = PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size "pkgSrcRecords", // tp_name - sizeof(CppOwnedPyObject<PkgSrcRecordsStruct>), // tp_basicsize + sizeof(CppPyObject<PkgSrcRecordsStruct>), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc<PkgSrcRecordsStruct>, // tp_dealloc + CppDealloc<PkgSrcRecordsStruct>, // tp_dealloc 0, // tp_print PkgSrcRecordsAttr, // tp_getattr 0, // tp_setattr @@ -145,11 +160,17 @@ PyTypeObject PkgSrcRecordsType = PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) { +#if 0 PyObject *Owner; if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) return 0; return HandleErrors(CppOwnedPyObject_NEW<PkgSrcRecordsStruct>(Owner, &PkgSrcRecordsType)); +#endif + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + + return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(&PkgSrcRecordsType)); } |
