summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-15 22:20:02 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-15 22:20:02 +0200
commit48097301f9cc685a8ad1229a28f34d36ad19665b (patch)
tree369c1c8baf8ed6dda156e0b24049209ccd6fa4ff /python
parentaaf5907863bed9a044fa0e3e2eacd1ca2de53c59 (diff)
downloadpython-apt-48097301f9cc685a8ad1229a28f34d36ad19665b.tar.gz
python/acquire.cc: Add AcquireItemDesc.
Diffstat (limited to 'python')
-rw-r--r--python/acquire.cc73
-rw-r--r--python/apt_pkgmodule.cc2
-rw-r--r--python/apt_pkgmodule.h1
-rw-r--r--python/python-apt.h6
4 files changed, 81 insertions, 1 deletions
diff --git a/python/acquire.cc b/python/acquire.cc
index c3f2fc5d..6c4baf9c 100644
--- a/python/acquire.cc
+++ b/python/acquire.cc
@@ -20,6 +20,78 @@ struct PyAcquireObject : public CppPyObject<pkgAcquire*> {
vector<PyAcquireItemObject *> items;
};
+static PyObject *acquireitemdesc_get_uri(PyObject *self, void *closure)
+{
+ return CppPyString(GetCpp<pkgAcquire::ItemDesc>(self).URI);
+}
+static PyObject *acquireitemdesc_get_description(PyObject *self, void *closure)
+{
+ return CppPyString(GetCpp<pkgAcquire::ItemDesc>(self).Description);
+}
+static PyObject *acquireitemdesc_get_shortdesc(PyObject *self, void *closure)
+{
+ return CppPyString(GetCpp<pkgAcquire::ItemDesc>(self).ShortDesc);
+}
+static PyObject *acquireitemdesc_get_owner(PyObject *self, void *closure)
+{
+ return GetOwner<pkgAcquire::ItemDesc>(self);
+}
+
+static PyGetSetDef acquireitemdesc_getset[] = {
+ {"uri",acquireitemdesc_get_uri,0,"The URI from which to download this item."},
+ {"description",acquireitemdesc_get_description},
+ {"shortdesc",acquireitemdesc_get_shortdesc},
+ {"owner",acquireitemdesc_get_owner},
+ {NULL}
+};
+
+static char *acquireitemdesc_doc =
+ "Represent an AcquireItemDesc";
+
+PyTypeObject PyAcquireItemDesc_Type =
+{
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "apt_pkg.AcquireItemDesc", // tp_name
+ sizeof(CppOwnedPyObject<pkgAcquire::ItemDesc>),// tp_basicsize
+ 0, // tp_itemsize
+ // Methods
+ CppOwnedDealloc<pkgAcquire::ItemDesc>, // tp_dealloc
+ 0, // tp_print
+ 0, // tp_getattr
+ 0, // tp_setattr
+ 0, // tp_compare
+ 0, // 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
+ Py_TPFLAGS_HAVE_GC),
+ acquireitemdesc_doc, // tp_doc
+ CppOwnedTraverse<pkgAcquire::ItemDesc>,// tp_traverse
+ CppOwnedClear<pkgAcquire::ItemDesc>, // tp_clear
+ 0, // tp_richcompare
+ 0, // tp_weaklistoffset
+ 0, // tp_iter
+ 0, // tp_iternext
+ 0, // tp_methods
+ 0, // tp_members
+ acquireitemdesc_getset, // tp_getset
+ 0, // tp_base
+ 0, // tp_dict
+ 0, // tp_descr_get
+ 0, // tp_descr_set
+ 0, // tp_dictoffset
+ 0, // tp_init
+ 0, // tp_alloc
+ 0, // tp_new
+};
+
inline pkgAcquire::Item *acquireitem_tocpp(PyObject *self) {
pkgAcquire::Item *itm = GetCpp<pkgAcquire::Item*>(self);
if (itm == 0)
@@ -47,7 +119,6 @@ MkGet(AcquireItemGetIsTrusted,Py_BuildValue("i",Itm->IsTrusted()));
MkGet(AcquireItemGetLocal,Py_BuildValue("i",Itm->Local));
MkGet(AcquireItemGetStatus,Py_BuildValue("i",Itm->Status));
-
// Constants
MkGet(AcquireItemGetStatIdle,Py_BuildValue("i", pkgAcquire::Item::StatIdle));
MkGet(AcquireItemGetStatFetching,Py_BuildValue("i", pkgAcquire::Item::StatFetching));
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 4f948847..5d7b6c47 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -502,6 +502,7 @@ static struct _PyAptPkgAPIStruct API = {
&PyAcquire_Type, // acquire_type
&PyAcquireFile_Type, // acquirefile_type
&PyAcquireItem_Type, // acquireitem_type
+ &PyAcquireItemDesc_Type, // acquireitemdesc_type
&PyActionGroup_Type, // actiongroup_type
&PyCache_Type, // cache_type
&PyCacheFile_Type, // cachefile_type
@@ -623,6 +624,7 @@ extern "C" void initapt_pkg()
ADDTYPE(Module,"Hashes",&PyHashes_Type);
ADDTYPE(Module,"OpProgress",&PyOpProgress_Type);
ADDTYPE(Module,"AcquireProgress",&PyAcquireProgress_Type);
+ ADDTYPE(Module,"AcquireItemDesc",&PyAcquireItemDesc_Type);
// Tag file constants
PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER",
CharCharToList(TFRewritePackageOrder));
diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h
index 34bc2ae5..835cfd9b 100644
--- a/python/apt_pkgmodule.h
+++ b/python/apt_pkgmodule.h
@@ -114,6 +114,7 @@ extern PyTypeObject PyPolicy_Type;
extern PyTypeObject PyHashes_Type;
extern PyTypeObject PyOpProgress_Type;
extern PyTypeObject PyAcquireProgress_Type;
+extern PyTypeObject PyAcquireItemDesc_Type;
#include "python-apt.h"
#endif
diff --git a/python/python-apt.h b/python/python-apt.h
index 16734238..53f6b0bb 100644
--- a/python/python-apt.h
+++ b/python/python-apt.h
@@ -28,6 +28,7 @@ struct _PyAptPkgAPIStruct {
PyTypeObject *acquire_type;
PyTypeObject *acquirefile_type;
PyTypeObject *acquireitem_type;
+ PyTypeObject *acquireitemdesc_type;
PyTypeObject *actiongroup_type;
PyTypeObject *cache_type;
PyTypeObject *cachefile_type;
@@ -60,6 +61,7 @@ struct _PyAptPkgAPIStruct {
# define PyAcquire_Type *(_PyAptPkg_API->acquire_type)
# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type)
# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type)
+# define PyAcquireItemDesc_Type *(_PyAptPkg_API->acquireitemdesc_type)
# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type)
# define PyCache_Type *(_PyAptPkg_API->cache_type)
# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type)
@@ -119,6 +121,7 @@ static int import_apt_pkg(void) {
# define PyAcquire_Check(op) PyObject_TypeCheck(op, &PyAcquire_Type)
# define PyAcquireFile_Check(op) PyObject_TypeCheck(op, &PyAcquireFile_Type)
# define PyAcquireItem_Check(op) PyObject_TypeCheck(op, &PyAcquireItem_Type)
+# define PyAcquireItemDesc_Check(op) PyObject_TypeCheck(op, &PyAcquireItemDesc_Type)
# define PyActionGroup_Check(op) PyObject_TypeCheck(op, &PyActionGroup_Type)
# define PyCache_Check(op) PyObject_TypeCheck(op, &PyCache_Type)
# define PyCacheFile_Check(op) PyObject_TypeCheck(op, &PyCacheFile_Type)
@@ -149,6 +152,7 @@ static int import_apt_pkg(void) {
# define PyAcquire_CheckExact(op) (Py_TYPE(op) == &PyAcquire_Type)
# define PyAcquireFile_CheckExact(op) (Py_TYPE(op) == &PyAcquireFile_Type)
# define PyAcquireItem_CheckExact(op) (Py_TYPE(op) == &PyAcquireItem_Type)
+# define PyAcquireItemDesc_CheckExact(op) (Py_TYPE(op) == &PyAcquireItemDesc_Type)
# define PyActionGroup_CheckExact(op) (Py_TYPE(op) == &PyActionGroup_Type)
# define PyCache_CheckExact(op) (Py_TYPE(op) == &PyCache_Type)
# define PyCacheFile_CheckExact(op) (Py_TYPE(op) == &PyCacheFile_Type)
@@ -180,6 +184,7 @@ static int import_apt_pkg(void) {
# define PyAcquire_ToCpp GetCpp<pkgAcquire*>
# define PyAcquireFile_ToCpp GetCpp<pkgAcqFile*>
# define PyAcquireItem_ToCpp GetCpp<pkgAcquire::Item*>
+# define PyAcquireItemDesc_ToCpp GetCpp<pkgAcquire::ItemDesc>
# define PyActionGroup_ToCpp GetCpp<pkgDepCache::ActionGroup*>
# define PyCache_ToCpp GetCpp<pkgCache*>
# define PyCacheFile_ToCpp GetCpp<pkgCacheFile*>
@@ -229,6 +234,7 @@ inline PyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj,
# define PyAcquire_FromCpp(...) FromCpp<pkgAcquire*>(&PyAcquire_Type, ##__VA_ARGS__)
# define PyAcquireFile_FromCpp(...) FromCppOwned<pkgAcqFile*>(&PyAcquireFile_Type, ##__VA_ARGS__)
# define PyAcquireItem_FromCpp(...) FromCppOwned<pkgAcquire::Item*>(&PyAcquireItemType,##__VA_ARGS__)
+# define PyAcquireItemDesc_FromCpp(...) FromCppOwned<pkgAcquire::ItemDesc>(&PyAcquireItemDesc_Type,##__VA_ARGS__)
# define PyActionGroup_FromCpp(...) FromCppOwned<pkgDepCache::ActionGroup*>(&PyActionGroup_Type,##__VA_ARGS__)
# define PyCache_FromCpp(...) FromCppOwned<pkgCache*>(&PyCache_Type,##__VA_ARGS__)
# define PyCacheFile_FromCpp(...) FromCpp<pkgCacheFile*>(&PyCacheFile_Type,##__VA_ARGS__)