|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "generic.h" |
|
#include "apt_pkgmodule.h" |
|
|
|
#include <apt-pkg/indexfile.h> |
|
|
|
#include <Python.h> |
|
|
|
static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args) |
|
{ |
|
pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self); |
|
PyApt_Filename path; |
|
|
|
if (PyArg_ParseTuple(Args, "O&", PyApt_Filename::Converter, &path) == 0) |
|
return 0; |
|
return HandleErrors(CppPyString(File->ArchiveURI(path).c_str())); |
|
} |
|
|
|
static PyMethodDef IndexFileMethods[] = |
|
{ |
|
{"archive_uri",IndexFileArchiveURI,METH_VARARGS, |
|
"archive_uri(path: str) -> str\n\n" |
|
"Return the URI to the given path in the archive."}, |
|
{} |
|
}; |
|
|
|
#define File (GetCpp<pkgIndexFile*>(Self)) |
|
static PyObject *IndexFileGetLabel(PyObject *Self,void*) { |
|
return CppPyString(File->GetType()->Label); |
|
} |
|
static PyObject *IndexFileGetDescribe(PyObject *Self,void*) { |
|
return CppPyString(File->Describe().c_str()); |
|
} |
|
static PyObject *IndexFileGetExists(PyObject *Self,void*) { |
|
return PyBool_FromLong((File->Exists())); |
|
} |
|
static PyObject *IndexFileGetHasPackages(PyObject *Self,void*) { |
|
return PyBool_FromLong((File->HasPackages())); |
|
} |
|
static PyObject *IndexFileGetSize(PyObject *Self,void*) { |
|
return MkPyNumber((File->Size())); |
|
} |
|
static PyObject *IndexFileGetIsTrusted(PyObject *Self,void*) { |
|
return PyBool_FromLong((File->IsTrusted())); |
|
} |
|
#undef File |
|
|
|
#define S(x) (x ? x : "") |
|
static PyObject *IndexFileRepr(PyObject *Self) |
|
{ |
|
pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self); |
|
return PyString_FromFormat("<pkIndexFile object: " |
|
"Label:'%s' Describe='%s' Exists='%i' " |
|
"HasPackages='%i' Size='%lu' " |
|
"IsTrusted='%i' ArchiveURI='%s'>", |
|
S(File->GetType()->Label), File->Describe().c_str(), File->Exists(), |
|
File->HasPackages(), File->Size(), |
|
File->IsTrusted(), File->ArchiveURI("").c_str()); |
|
} |
|
#undef S |
|
|
|
static PyGetSetDef IndexFileGetSet[] = { |
|
{"describe",IndexFileGetDescribe,0, |
|
"A string describing the index file."}, |
|
{"exists",IndexFileGetExists,0, |
|
"A boolean value determining whether the index file exists."}, |
|
{"has_packages",IndexFileGetHasPackages,0, |
|
"A boolean value determining whether the index file has packages."}, |
|
{"is_trusted",IndexFileGetIsTrusted,0, |
|
"A boolean value determining whether the file can be trusted; e.g.\n" |
|
"because it is from a source with a GPG signed Release file."}, |
|
{"label",IndexFileGetLabel,0, |
|
"The label of the index file."}, |
|
{"size",IndexFileGetSize,0, |
|
"The size of the files, measured in bytes."}, |
|
{} |
|
}; |
|
|
|
static const char *indexfile_doc = |
|
"Represent an index file, i.e. package indexes, translation indexes,\n" |
|
"and source indexes."; |
|
|
|
PyTypeObject PyIndexFile_Type = |
|
{ |
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
"apt_pkg.IndexFile", |
|
sizeof(CppPyObject<pkgIndexFile*>), |
|
0, |
|
|
|
|
|
CppDeallocPtr<pkgIndexFile*>, |
|
0, |
|
0, |
|
0, |
|
0, |
|
IndexFileRepr, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
0, |
|
_PyAptObject_getattro, |
|
0, |
|
0, |
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, |
|
indexfile_doc, |
|
CppTraverse<pkgIndexFile*>, |
|
CppClear<pkgIndexFile*>, |
|
0, |
|
0, |
|
0, |
|
0, |
|
IndexFileMethods, |
|
0, |
|
IndexFileGetSet, |
|
}; |
|
|
|
|
|
|
|
|
|
|