From c187e828e1661d09a8437214b2f90dcc25c05c99 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 18 Nov 2005 01:01:37 +0000 Subject: * basic pkgAcquire + pkgPackageManager support added --- python/pkgrecords.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'python/pkgrecords.cc') diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 7f5aa0e2..a85b570a 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -10,20 +10,12 @@ // Include Files /*{{{*/ #include "generic.h" #include "apt_pkgmodule.h" +#include "pkgrecords.h" -#include #include /*}}}*/ -struct PkgRecordsStruct -{ - pkgRecords Records; - pkgRecords::Parser *Last; - - PkgRecordsStruct(pkgCache *Cache) : Records(*Cache), Last(0) {}; - PkgRecordsStruct() : Records(*(pkgCache *)0) {abort();}; // G++ Bug.. -}; // PkgRecords Class /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3 From 940c6ecb9e7494414c4554fa4487cb5d17b5dadb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 24 Jan 2006 17:30:07 +0000 Subject: * added pkgRecords.Record --- debian/changelog | 1 + python/pkgrecords.cc | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'python/pkgrecords.cc') diff --git a/debian/changelog b/debian/changelog index 2e8ec5c7..3b84dd1e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.6.16.1) unstable; urgency=low * memleak fixed when pkgCache objects are deallocated * typos fixed (thanks to Gustavo Franco) + * pkgRecords.Record added to get raw record data -- diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index a85b570a..c6f5aeb9 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -73,6 +73,12 @@ static PyObject *PkgRecordsAttr(PyObject *Self,char *Name) return CppPyString(Struct.Last->LongDesc()); else if (strcmp("Name",Name) == 0) return CppPyString(Struct.Last->Name()); + else if (strcmp("Record", Name) == 0) + { + const char *start, *stop; + Struct.Last->GetRec(start, stop); + return PyString_FromStringAndSize(start,stop-start); + } } return Py_FindMethod(PkgRecordsMethods,Self,Name); -- cgit v1.2.3 From e02913b6f336d4bf5bc2c17032c91ade974de04f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 22 Mar 2006 14:56:29 +0100 Subject: * fixes for the pkgSrcRecords code --- debian/changelog | 8 ++++++-- doc/examples/build-deps.py | 2 +- doc/examples/sources.py | 6 ++++++ python/pkgrecords.cc | 2 +- python/pkgsrcrecords.cc | 27 ++++++++++++++++++++++++--- tests/pkgsrcrecords.py | 2 +- 6 files changed, 39 insertions(+), 8 deletions(-) (limited to 'python/pkgrecords.cc') diff --git a/debian/changelog b/debian/changelog index e621b8d6..4b677c2e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,12 @@ python-apt (0.6.16.2) unstable; urgency=low - return useful values on Cache.update() * apt/cache.py, apt/package.py: fix various pychecker warnings * apt/cache.py: Release locks on failure (thanks to Colin Watson) - - -- + * python/srcrecords.cc: + - add "Restart" method + - don't run auto "Restart" before performing a Lookup + - fix the initalization (no need to pass a PkgCacheType to the records) + + -- Michael Vogt Wed, 22 Mar 2006 11:19:34 +0100 python-apt (0.6.16.1) unstable; urgency=low diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index b580f5de..65e35f3d 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -24,7 +24,7 @@ cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) depcache.Init() records = apt_pkg.GetPkgRecords(cache) -srcrecords = apt_pkg.GetPkgSrcRecords(cache) +srcrecords = apt_pkg.GetPkgSrcRecords() # base package that we use for build-depends calculation if len(sys.argv) < 2: diff --git a/doc/examples/sources.py b/doc/examples/sources.py index 79514621..0a90bae9 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -4,6 +4,12 @@ import apt_pkg apt_pkg.init() +#cache = apt_pkg.GetCache() +#sources = apt_pkg.GetPkgSrcRecords(cache) + sources = apt_pkg.GetPkgSrcRecords() +sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries` + #print sources.Files + 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(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), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // 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(Owner, &PkgSrcRecordsType)); +#endif + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + + return HandleErrors(CppPyObject_NEW(&PkgSrcRecordsType)); } diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py index dc4881dd..28df3f7c 100644 --- a/tests/pkgsrcrecords.py +++ b/tests/pkgsrcrecords.py @@ -14,7 +14,7 @@ def main(): print "Running PkgSrcRecords test on all packages:" for x in cache.Packages: i += 1 - src = apt_pkg.GetPkgSrcRecords(cache) + src = apt_pkg.GetPkgSrcRecords() if src.Lookup(x.Name): #print src.Package pass -- cgit v1.2.3