summaryrefslogtreecommitdiff
path: root/python/metaindex.cc
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2007-11-29 12:25:33 +0100
committerMichael Vogt <egon@bottom>2007-11-29 12:25:33 +0100
commit0fc4aa9466d57ddc4a54191eeb8775e41ad35525 (patch)
tree93b7f4e949c3c013309d397de200d058ec7b5af5 /python/metaindex.cc
parentbe3ddb25ea0baa259f20936f1d7a62cafa019b99 (diff)
parentabf6c5801c6b162a9dcda5099e8eb746525dc826 (diff)
downloadpython-apt-0fc4aa9466d57ddc4a54191eeb8775e41ad35525.tar.gz
* apt/package.py:
- fix apt.package.Dependency.relation initialization * python/string.cc: - fix overflow in SizeToStr() * 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/depcache.cc: - be more threading friendly * python/tag.cc - support "None" as default in ParseSection(control).get(field, default), LP: #44470 * python/progress.cc: - fix refcount problem in OpProgress - fix refcount problem in FetchProgress - fix refcount problem in CdromProgress * apt/README.apt: - fix typo (thanks to Thomas Schoepf, closes: #387787) * po/fr.po: - merge update, thanks to Christian Perrier (closes: #435918)
Diffstat (limited to 'python/metaindex.cc')
-rw-r--r--python/metaindex.cc78
1 files changed, 78 insertions, 0 deletions
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
+};
+
+
+
+