summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2006-04-29 21:43:22 +0200
committerMichael Vogt <egon@bottom>2006-04-29 21:43:22 +0200
commitb2027f3494dcc42846c8a1106a4fd4b71cd8ed24 (patch)
treeef83cdce0261661c21f588edbe838acf47166d3c /python
parenta6d05b8fe1d75e27ca938e684971e4e0cb0ea8c9 (diff)
parent0e8fd33b1b741cc65c284a08faa50b3a2995ac3c (diff)
downloadpython-apt-b2027f3494dcc42846c8a1106a4fd4b71cd8ed24.tar.gz
* merged from mainline
Diffstat (limited to 'python')
-rw-r--r--python/indexfile.cc20
-rw-r--r--python/pkgrecords.cc2
-rw-r--r--python/pkgsrcrecords.cc31
-rw-r--r--python/tar.cc4
4 files changed, 48 insertions, 9 deletions
diff --git a/python/indexfile.cc b/python/indexfile.cc
index 4e106e25..ef6ffc8a 100644
--- a/python/indexfile.cc
+++ b/python/indexfile.cc
@@ -15,6 +15,22 @@
#include <Python.h>
+static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args)
+{
+ pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self);
+ char *path;
+
+ if (PyArg_ParseTuple(Args, "s",&path) == 0)
+ return 0;
+
+ return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str()));
+}
+
+static PyMethodDef PackageIndexFileMethods[] =
+{
+ {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"},
+ {}
+};
static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name)
@@ -33,8 +49,7 @@ static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name)
else if (strcmp("IsTrusted",Name) == 0)
return Py_BuildValue("i",(File->IsTrusted()));
- PyErr_SetString(PyExc_AttributeError,Name);
- return 0;
+ return Py_FindMethod(PackageIndexFileMethods,Self,Name);
}
static PyObject *PackageIndexFileRepr(PyObject *Self)
@@ -51,6 +66,7 @@ static PyObject *PackageIndexFileRepr(PyObject *Self)
File->IsTrusted(), File->ArchiveURI("").c_str());
return PyString_FromString(S);
}
+
PyTypeObject PackageIndexFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
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..5e04f5fc 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},
{}
};
@@ -81,8 +96,10 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name)
*b != 0;
++b)
PyList_Append(List, CppPyString(*b));
-
return List; // todo
+ } else if (strcmp("Index",Name) == 0) {
+ const pkgIndexFile &tmp = Struct.Last->Index();
+ return CppOwnedPyObject_NEW<pkgIndexFile*>(Self,&PackageIndexFileType, (pkgIndexFile*)&tmp);
} else if (strcmp("Files",Name) == 0) {
PyObject *List = PyList_New(0);
@@ -126,10 +143,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 +162,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/python/tar.cc b/python/tar.cc
index 20fb1f5f..22c0327e 100644
--- a/python/tar.cc
+++ b/python/tar.cc
@@ -88,7 +88,7 @@ bool ProcessTar::DoItem(Item &Itm,int &Fd)
// ---------------------------------------------------------------------
/* */
char *doc_tarExtract =
-"tarExtract(File,Func,Comp) -> None"
+"tarExtract(File,Func,Comp) -> None\n"
"The tar file referenced by the file object File, Func called for each\n"
"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n";
PyObject *tarExtract(PyObject *Self,PyObject *Args)
@@ -128,7 +128,7 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args)
// ---------------------------------------------------------------------
/* */
char *doc_debExtract =
-"debExtract(File,Func,Chunk) -> None"
+"debExtract(File,Func,Chunk) -> None\n"
"The deb referenced by the file object File is examined. The AR member\n"
"given by Chunk is treated as a tar.gz and fed through Func like\n"
"tarExtract\n";