diff options
Diffstat (limited to 'python/sourcelist.cc')
| -rw-r--r-- | python/sourcelist.cc | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/python/sourcelist.cc b/python/sourcelist.cc index e2343e1c..16e51368 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -3,7 +3,7 @@ // $Id: sourcelist.cc,v 1.2 2003/12/26 17:04:22 mdz Exp $ /* ###################################################################### - Package Records - Wrapper for the package records functions + SourcesList - Wrapper for the SourcesList functions ##################################################################### */ /*}}}*/ @@ -16,10 +16,7 @@ #include <Python.h> /*}}}*/ -struct PkgSourceListStruct -{ - pkgSourceList List; -}; + // PkgsourceList Class /*{{{*/ // --------------------------------------------------------------------- @@ -27,23 +24,57 @@ struct PkgSourceListStruct static char *doc_PkgSourceListFindIndex = "xxx"; static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) { - PkgSourceListStruct &Struct = GetCpp<PkgSourceListStruct>(Self); - return Py_BuildValue("i", 1); + pkgSourceList *list = GetCpp<pkgSourceList*>(Self); + PyObject *pyPkgFileIter; + PyObject *pyPkgIndexFile; + + if (PyArg_ParseTuple(Args, "O!", &PackageFileType,&pyPkgFileIter) == 0) + return 0; + + pkgCache::PkgFileIterator &i = GetCpp<pkgCache::PkgFileIterator>(pyPkgFileIter); + pkgIndexFile *index; + if(list->FindIndex(i, index)) + { + pyPkgIndexFile = CppOwnedPyObject_NEW<pkgIndexFile*>(pyPkgFileIter,&PackageIndexFileType,index); + return pyPkgIndexFile; + } + + //&PackageIndexFileType,&pyPkgIndexFile) + + Py_INCREF(Py_None); + return Py_None; } static char *doc_PkgSourceListReadMainList = "xxx"; static PyObject *PkgSourceListReadMainList(PyObject *Self,PyObject *Args) { - PkgSourceListStruct &Struct = GetCpp<PkgSourceListStruct>(Self); - Struct.List.ReadMainList(); + pkgSourceList *list = GetCpp<pkgSourceList*>(Self); + bool res = list->ReadMainList(); - return Py_None; + return HandleErrors(Py_BuildValue("b",res)); +} + +static char *doc_PkgSourceListGetIndexes = "Load the indexes into the fetcher"; +static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args) +{ + pkgSourceList *list = GetCpp<pkgSourceList*>(Self); + + PyObject *pyFetcher; + + if (PyArg_ParseTuple(Args, "O!",&PkgAcquireType,&pyFetcher) == 0) + return 0; + + pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyFetcher); + bool res = list->GetIndexes(fetcher); + + return HandleErrors(Py_BuildValue("b",res)); } static PyMethodDef PkgSourceListMethods[] = { {"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, {"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, + {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListReadMainList}, {} }; @@ -56,10 +87,10 @@ PyTypeObject PkgSourceListType = PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size "pkgSourceList", // tp_name - sizeof(CppPyObject<PkgSourceListStruct>), // tp_basicsize + sizeof(CppPyObject<pkgSourceList*>), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc<PkgSourceListStruct>, // tp_dealloc + CppDealloc<pkgSourceList*>, // tp_dealloc 0, // tp_print PkgSourceListAttr, // tp_getattr 0, // tp_setattr @@ -73,6 +104,6 @@ PyTypeObject PkgSourceListType = PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) { - return CppPyObject_NEW<PkgSourceListStruct>(&PkgSourceListType); + return CppPyObject_NEW<pkgSourceList*>(&PkgSourceListType,new pkgSourceList()); } |
