|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "generic.h" |
|
#include "apt_pkgmodule.h" |
|
|
|
#include <apt-pkg/metaindex.h> |
|
|
|
#include <Python.h> |
|
|
|
static PyObject *MetaIndexGetURI(PyObject *Self,void*) { |
|
metaIndex *meta = GetCpp<metaIndex*>(Self); |
|
return CppPyString(meta->GetURI().c_str()); |
|
} |
|
|
|
static PyObject *MetaIndexGetDist(PyObject *Self,void*) { |
|
metaIndex *meta = GetCpp<metaIndex*>(Self); |
|
return CppPyString(meta->GetDist().c_str()); |
|
} |
|
|
|
static PyObject *MetaIndexGetIsTrusted(PyObject *Self,void*) { |
|
metaIndex *meta = GetCpp<metaIndex*>(Self); |
|
return PyBool_FromLong((meta->IsTrusted())); |
|
} |
|
|
|
static PyObject *MetaIndexGetIndexFiles(PyObject *Self,void*) { |
|
metaIndex *meta = GetCpp<metaIndex*>(Self); |
|
PyObject *List = PyList_New(0); |
|
std::vector<pkgIndexFile *> *indexFiles = meta->GetIndexFiles(); |
|
for (std::vector<pkgIndexFile *>::const_iterator I = indexFiles->begin(); |
|
I != indexFiles->end(); I++) |
|
{ |
|
CppPyObject<pkgIndexFile*> *Obj; |
|
Obj = CppPyObject_NEW<pkgIndexFile*>(Self, &PyIndexFile_Type,*I); |
|
|
|
Obj->NoDelete = true; |
|
PyList_Append(List,Obj); |
|
Py_DECREF(Obj); |
|
} |
|
return List; |
|
} |
|
|
|
static PyGetSetDef MetaIndexGetSet[] = { |
|
{"dist",MetaIndexGetDist,0,"The distribution, as a string."}, |
|
{"index_files",MetaIndexGetIndexFiles,0, |
|
"A list of all IndexFile objects associated with this meta index."}, |
|
{"is_trusted",MetaIndexGetIsTrusted,0, |
|
"A boolean value determining whether the file can be trusted."}, |
|
{"uri",MetaIndexGetURI,0, |
|
"The uri the meta index is located at."}, |
|
{} |
|
}; |
|
|
|
#define S(x) (x ? x : "") |
|
static PyObject *MetaIndexRepr(PyObject *Self) |
|
{ |
|
metaIndex *meta = GetCpp<metaIndex*>(Self); |
|
return PyString_FromFormat("<%s object: type='%s', uri:'%s' dist='%s' " |
|
"is_trusted='%i'>", Self->ob_type->tp_name, |
|
S(meta->GetType()), meta->GetURI().c_str(), |
|
meta->GetDist().c_str(), meta->IsTrusted()); |
|
} |
|
#undef S |
|
|
|
|
|
static const char *metaindex_doc = |
|
"Provide information on meta-indexes (i.e. Release files), such as\n" |
|
"whether they are trusted or their URI."; |
|
|
|
PyTypeObject PyMetaIndex_Type = |
|
{ |
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
"apt_pkg.MetaIndex", |
|
sizeof(CppPyObject<metaIndex*>), |
|
0, |
|
|
|
CppDeallocPtr<metaIndex*>, |
|
0, |
|
0, |
|
0, |
|
0, |
|
MetaIndexRepr, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
_PyAptObject_getattro, |
|
0, |
|
0, |
|
Py_TPFLAGS_DEFAULT, |
|
metaindex_doc, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
MetaIndexGetSet, |
|
}; |
|
|