summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2007-09-04 17:45:41 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2007-09-04 17:45:41 +0200
commit99f2df941c9b43bc44b02aba43ddcb6463ad129b (patch)
tree1f77e08e893e64d232edd30db496b15d2dbe147d
parentbdbe31287e41c11b40924a0d662722b395bddf73 (diff)
parent8ad58480ce8a161519339b41eacefc26059bebf7 (diff)
downloadpython-apt-99f2df941c9b43bc44b02aba43ddcb6463ad129b.tar.gz
* python/metaindex.cc:
- added support for the metaIndex objects * python/sourceslist.cc: - support new "List" attribute that returns the list of metaIndex source entries * python/string.cc: - fix overflow in SizeToStr() * NMU * Fix version to not use CPU and OS since it's not available on APT anymore (closes: #435653, #435674)
-rw-r--r--debian/changelog28
-rw-r--r--doc/examples/metaindex.py15
-rw-r--r--python/apt_pkgmodule.h3
-rw-r--r--python/makefile2
-rw-r--r--python/metaindex.cc78
-rw-r--r--python/sourcelist.cc16
-rw-r--r--python/string.cc2
7 files changed, 133 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog
index dee8c660..c3d9041c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,23 @@
+python-apt (0.7.3.1ubuntu1) gutsy; urgency=low
+
+ * python/metaindex.cc:
+ - added support for the metaIndex objects
+ * python/sourceslist.cc:
+ - support new "List" attribute that returns the list of
+ metaIndex source entries
+ * python/string.cc:
+ - fix overflow in SizeToStr()
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 04 Sep 2007 16:36:11 +0200
+
+python-apt (0.7.3.1) unstable; urgency=low
+
+ * NMU
+ * Fix version to not use CPU and OS since it's not available on APT
+ anymore (closes: #435653, #435674)
+
+ -- Otavio Salvador <otavio@debian.org> Thu, 02 Aug 2007 18:45:25 -0300
+
python-apt (0.7.3ubuntu2) gutsy; urgency=low
* rebuild against latest apt
@@ -19,14 +39,6 @@ python-apt (0.7.3ubuntu1) gutsy; urgency=low
-- Michael Vogt <michael.vogt@ubuntu.com> Tue, 31 Jul 2007 13:40:04 +0200
-python-apt (0.7.3.1) unstable; urgency=low
-
- * NMU
- * Fix version to not use CPU and OS since it's not available on APT
- anymore (closes: #435653, #435674)
-
- -- Otavio Salvador <otavio@debian.org> Thu, 02 Aug 2007 18:45:25 -0300
-
python-apt (0.7.3) unstable; urgency=low
* apt/package.py:
diff --git a/doc/examples/metaindex.py b/doc/examples/metaindex.py
new file mode 100644
index 00000000..1bce0dba
--- /dev/null
+++ b/doc/examples/metaindex.py
@@ -0,0 +1,15 @@
+
+import apt_pkg
+
+apt_pkg.init()
+
+sources = apt_pkg.GetPkgSourceList()
+sources.ReadMainList()
+
+
+for metaindex in sources.List:
+ print metaindex
+ print "URI: ",metaindex.URI
+ print "Dist: ",metaindex.Dist
+ print "IndexFiles: ","\n".join([str(i) for i in metaindex.IndexFiles])
+ print
diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h
index d58f4589..f59c8ca0 100644
--- a/python/apt_pkgmodule.h
+++ b/python/apt_pkgmodule.h
@@ -95,5 +95,8 @@ PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args);
// pkgSourceList
extern PyTypeObject PackageIndexFileType;
+// metaIndex
+extern PyTypeObject MetaIndexType;
+
#endif
diff --git a/python/makefile b/python/makefile
index 24ef3238..e0c62541 100644
--- a/python/makefile
+++ b/python/makefile
@@ -12,7 +12,7 @@ LIB_MAKES = apt-pkg/makefile
APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \
cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \
depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \
- indexfile.cc
+ indexfile.cc metaindex.cc
SOURCE := $(APT_PKG_SRC)
include $(PYTHON_H) progress.h
diff --git a/python/metaindex.cc b/python/metaindex.cc
new file mode 100644
index 00000000..c9a86ab4
--- /dev/null
+++ b/python/metaindex.cc
@@ -0,0 +1,78 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: metaindex.cc,v 1.2 2003/12/26 17:04:22 mdz Exp $
+/* ######################################################################
+
+ metaindex - Wrapper for the metaIndex functions
+
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#include "generic.h"
+#include "apt_pkgmodule.h"
+
+#include <apt-pkg/metaindex.h>
+
+#include <Python.h>
+
+
+static PyObject *MetaIndexAttr(PyObject *Self,char *Name)
+{
+ metaIndex *meta = GetCpp<metaIndex*>(Self);
+ if (strcmp("URI",Name) == 0)
+ return Safe_FromString(meta->GetURI().c_str());
+ else if (strcmp("Dist",Name) == 0)
+ return Safe_FromString(meta->GetDist().c_str());
+ else if (strcmp("IsTrusted",Name) == 0)
+ return Py_BuildValue("i",(meta->IsTrusted()));
+ else if (strcmp("IndexFiles",Name) == 0)
+ {
+ PyObject *List = PyList_New(0);
+ vector<pkgIndexFile *> *indexFiles = meta->GetIndexFiles();
+ for (vector<pkgIndexFile *>::const_iterator I = indexFiles->begin();
+ I != indexFiles->end(); I++)
+ {
+ PyObject *Obj;
+ Obj = CppPyObject_NEW<pkgIndexFile*>(&PackageIndexFileType,*I);
+ PyList_Append(List,Obj);
+ }
+ return List;
+ }
+}
+
+static PyObject *MetaIndexRepr(PyObject *Self)
+{
+ metaIndex *meta = GetCpp<metaIndex*>(Self);
+
+ char S[1024];
+ snprintf(S,sizeof(S),"<metaIndex object: "
+ "Type='%s', URI:'%s' Dist='%s' IsTrusted='%i'>",
+ meta->GetType(), meta->GetURI().c_str(), meta->GetDist().c_str(),
+ meta->IsTrusted());
+
+ return PyString_FromString(S);
+}
+
+PyTypeObject MetaIndexType =
+{
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, // ob_size
+ "metaIndex", // tp_name
+ sizeof(CppOwnedPyObject<metaIndex*>), // tp_basicsize
+ 0, // tp_itemsize
+ // Methods
+ CppOwnedDealloc<metaIndex*>, // tp_dealloc
+ 0, // tp_print
+ MetaIndexAttr, // tp_getattr
+ 0, // tp_setattr
+ 0, // tp_compare
+ MetaIndexRepr, // tp_repr
+ 0, // tp_as_number
+ 0, // tp_as_sequence
+ 0, // tp_as_mapping
+ 0, // tp_hash
+};
+
+
+
+
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 16e51368..68b764f8 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -80,7 +80,21 @@ static PyMethodDef PkgSourceListMethods[] =
static PyObject *PkgSourceListAttr(PyObject *Self,char *Name)
{
- return Py_FindMethod(PkgSourceListMethods,Self,Name);
+ pkgSourceList *list = GetCpp<pkgSourceList*>(Self);
+
+ if (strcmp("List",Name) == 0)
+ {
+ PyObject *List = PyList_New(0);
+ for (vector<metaIndex *>::const_iterator I = list->begin();
+ I != list->end(); I++)
+ {
+ PyObject *Obj;
+ Obj = CppPyObject_NEW<metaIndex*>(&MetaIndexType,*I);
+ PyList_Append(List,Obj);
+ }
+ return List;
+ }
+ return Py_FindMethod(PkgSourceListMethods,Self,Name);
}
PyTypeObject PkgSourceListType =
{
diff --git a/python/string.cc b/python/string.cc
index d0926da5..1fa5a901 100644
--- a/python/string.cc
+++ b/python/string.cc
@@ -55,7 +55,7 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args)
if (PyInt_Check(Obj))
return CppPyString(SizeToStr(PyInt_AsLong(Obj)));
if (PyLong_Check(Obj))
- return CppPyString(SizeToStr(PyLong_AsLong(Obj)));
+ return CppPyString(SizeToStr(PyLong_AsDouble(Obj)));
if (PyFloat_Check(Obj))
return CppPyString(SizeToStr(PyFloat_AsDouble(Obj)));