1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: indexfile.cc,v 1.2 2003/12/26 17:04:22 mdz Exp $
/* ######################################################################
pkgIndexFile - Wrapper for the pkgIndexFilefunctions
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include "generic.h"
#include "apt_pkgmodule.h"
#include <apt-pkg/indexfile.h>
#include <Python.h>
static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args)
{
pkgIndexFile *File = GetCpp<pkgIndexFile*>(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"},
{}
};
#define File (GetCpp<pkgIndexFile*>(Self))
static PyObject *PackageIndexFileGetLabel(PyObject *Self,void*) {
return Safe_FromString(File->GetType()->Label);
}
static PyObject *PackageIndexFileGetDescribe(PyObject *Self,void*) {
return Safe_FromString(File->Describe().c_str());
}
static PyObject *PackageIndexFileGetExists(PyObject *Self,void*) {
return Py_BuildValue("i",(File->Exists()));
}
static PyObject *PackageIndexFileGetHasPackages(PyObject *Self,void*) {
return Py_BuildValue("i",(File->HasPackages()));
}
static PyObject *PackageIndexFileGetSize(PyObject *Self,void*) {
return Py_BuildValue("i",(File->Size()));
}
static PyObject *PackageIndexFileGetIsTrusted(PyObject *Self,void*) {
return Py_BuildValue("i",(File->IsTrusted()));
}
#undef File
static PyObject *PackageIndexFileRepr(PyObject *Self)
{
pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self);
char S[1024];
snprintf(S,sizeof(S),"<pkIndexFile object: "
"Label:'%s' Describe='%s' Exists='%i' "
"HasPackages='%i' Size='%i' "
"IsTrusted='%i' ArchiveURI='%s'>",
File->GetType()->Label, File->Describe().c_str(), File->Exists(),
File->HasPackages(), File->Size(),
File->IsTrusted(), File->ArchiveURI("").c_str());
return PyString_FromString(S);
}
static PyGetSetDef PackageIndexFileGetSet[] = {
{"Describe",PackageIndexFileGetDescribe},
{"Exists",PackageIndexFileGetExists},
{"HasPackages",PackageIndexFileGetHasPackages},
{"IsTrusted",PackageIndexFileGetIsTrusted},
{"Label",PackageIndexFileGetLabel},
{"Size",PackageIndexFileGetSize},
{}
};
PyTypeObject PackageIndexFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
"pkgIndexFile", // tp_name
sizeof(CppOwnedPyObject<pkgIndexFile*>), // tp_basicsize
0, // tp_itemsize
// Methods
CppOwnedDealloc<pkgIndexFile*>, // tp_dealloc
0, // tp_print
0, // tp_getattr
0, // tp_setattr
0, // tp_compare
PackageIndexFileRepr, // tp_repr
0, // tp_as_number
0, // tp_as_sequence
0, // tp_as_mapping
0, // tp_hash
0, // tp_call
0, // tp_str
0, // tp_getattro
0, // tp_setattro
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT, // tp_flags
"pkgIndexFile Object", // tp_doc
0, // tp_traverse
0, // tp_clear
0, // tp_richcompare
0, // tp_weaklistoffset
0, // tp_iter
0, // tp_iternext
PackageIndexFileMethods, // tp_methods
0, // tp_members
PackageIndexFileGetSet, // tp_getset
};
|