summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog8
-rwxr-xr-xdoc/examples/build-deps.py2
-rw-r--r--doc/examples/sources.py6
-rw-r--r--python/pkgrecords.cc2
-rw-r--r--python/pkgsrcrecords.cc27
-rw-r--r--tests/pkgsrcrecords.py2
6 files changed, 39 insertions, 8 deletions
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 <michael.vogt@ubuntu.com> 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<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));
}
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