From eef094d6218739bc0147910bfdd478ac10f18ec1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 22 Mar 2006 15:07:21 +0100 Subject: * added indexFile.ArchiveURI(string) --- python/indexfile.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'python') 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 +static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) +{ + pkgIndexFile *File = GetCpp(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) -- cgit v1.2.3 From 4399788cb0202968a7fe5098050cec8a851bd58f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 22 Mar 2006 15:23:18 +0100 Subject: * add PkgSrcRecords.Index to the code --- doc/examples/sources.py | 2 +- python/pkgsrcrecords.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/doc/examples/sources.py b/doc/examples/sources.py index 0a90bae9..78913523 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -12,4 +12,4 @@ sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries` #print sources.Files - + print sources.Index.ArchiveURI("") diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index abb29c74..5e04f5fc 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -96,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(Self,&PackageIndexFileType, (pkgIndexFile*)&tmp); } else if (strcmp("Files",Name) == 0) { PyObject *List = PyList_New(0); -- cgit v1.2.3 From 8cc9bc319a5ed5237e4c4a40da241ee1159d9233 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Tue, 28 Mar 2006 08:31:14 -0300 Subject: Fix documentation format. --- python/tar.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python') 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"; -- cgit v1.2.3 From e7fde76bef8ba317cd6cc681c21c27d4aad13199 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jul 2006 18:46:03 +0200 Subject: * support sha256 as well --- debian/changelog | 4 +++- python/apt_pkgmodule.cc | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index a086ded0..ba6c47f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ python-apt (0.6.19) unstable; urgency=low * doc/examples/print_uris.py: - added a example to show how the indexfile.ArchiveURI() can be used with binary packages + * python/apt_pkgmodule.cc: + - export sha256 generation [ Otavio Salvador ] * apt/cache.py: @@ -11,7 +13,7 @@ python-apt (0.6.19) unstable; urgency=low - allow change of rootdir for APT database loading - add dh_installexamples in package building Closes: #376014 - -- + -- python-apt (0.6.18-0.2) unstable; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e73628c3..01e9c200 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -232,6 +233,43 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) return CppPyString(Sum.Result().Value()); } + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); + return 0; +} + /*}}}*/ +// sha256sum - Compute the sha1sum of a file or string /*{{{*/ +// --------------------------------------------------------------------- +static char *doc_sha256sum = "sha256sum(String) -> String or sha256sum(File) -> String"; +static PyObject *sha256sum(PyObject *Self,PyObject *Args) +{ + PyObject *Obj; + if (PyArg_ParseTuple(Args,"O",&Obj) == 0) + return 0; + + // Digest of a string. + if (PyString_Check(Obj) != 0) + { + SHA256Summation Sum; + Sum.Add(PyString_AsString(Obj)); + return CppPyString(Sum.Result().Value()); + } + + // Digest of a file + if (PyFile_Check(Obj) != 0) + { + SHA256Summation Sum; + int Fd = fileno(PyFile_AsFile(Obj)); + struct stat St; + if (fstat(Fd,&St) != 0 || + Sum.AddFD(Fd,St.st_size) == false) + { + PyErr_SetFromErrno(PyExc_SystemError); + return 0; + } + + return CppPyString(Sum.Result().Value()); + } + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); return 0; } @@ -370,6 +408,7 @@ static PyMethodDef methods[] = // Stuff {"md5sum",md5sum,METH_VARARGS,doc_md5sum}, {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, + {"sha256sum",sha1sum,METH_VARARGS,doc_sha256sum}, // Strings {"CheckDomainList",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, -- cgit v1.2.3 From 8d79b99c1a3338e31e8def858cee3209824ae8bf Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jul 2006 18:59:40 +0200 Subject: * #cough# - actually use sha256 --- debian/changelog | 2 +- python/apt_pkgmodule.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index ba6c47f6..783e510f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,7 +13,7 @@ python-apt (0.6.19) unstable; urgency=low - allow change of rootdir for APT database loading - add dh_installexamples in package building Closes: #376014 - -- + -- Michael Vogt Wed, 26 Jul 2006 18:51:56 +0200 python-apt (0.6.18-0.2) unstable; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 01e9c200..b1c5c2a5 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -408,7 +408,7 @@ static PyMethodDef methods[] = // Stuff {"md5sum",md5sum,METH_VARARGS,doc_md5sum}, {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, - {"sha256sum",sha1sum,METH_VARARGS,doc_sha256sum}, + {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, // Strings {"CheckDomainList",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, -- cgit v1.2.3