summaryrefslogtreecommitdiff
path: root/python/sourcelist.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-04-15 20:29:30 +0200
committerJulian Andres Klode <jak@debian.org>2009-04-15 20:29:30 +0200
commit49c10e3b9f6760280761f1255f3182637ba0ac9e (patch)
tree611819fece2da28d796b184457fb413f1f7b497d /python/sourcelist.cc
parent23d29169c30b2f05a0c2943832a7cf7288ff5802 (diff)
parentabc7c861e85265b0725aa82a51fe41f9183bc506 (diff)
downloadpython-apt-49c10e3b9f6760280761f1255f3182637ba0ac9e.tar.gz
python-apt (0.7.90) experimental; urgency=low
* Introduce support for Python 3 (Closes: #523645) * Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub} objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection()) * Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). * Add support for the Breaks fields * Only create Package objects when they are requested, do not keep them in a dict. Saves 10MB for 25,000 packages on my machine. * apt/package.py: Allow to set the candidate of a package (Closes: #523997) - Support assignments to the 'candidate' property of Package objects. - Initial patch by Sebastian Heinlein -- Julian Andres Klode <jak@debian.org> Wed, 15 Apr 2009 13:47:42 +0200
Diffstat (limited to 'python/sourcelist.cc')
-rw-r--r--python/sourcelist.cc49
1 files changed, 34 insertions, 15 deletions
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 5dcaf86b..48b3b7c8 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -74,39 +74,42 @@ static PyMethodDef PkgSourceListMethods[] =
{
{"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex},
{"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList},
- {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListReadMainList},
+ {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes},
{}
};
-static PyObject *PkgSourceListAttr(PyObject *Self,char *Name)
+static PyObject *PkgSourceListGetList(PyObject *Self,void*)
{
pkgSourceList *list = GetCpp<pkgSourceList*>(Self);
-
- if (strcmp("List",Name) == 0)
+ PyObject *List = PyList_New(0);
+ for (vector<metaIndex *>::const_iterator I = list->begin();
+ I != list->end(); I++)
{
- PyObject *List = PyList_New(0);
- for (vector<metaIndex *>::const_iterator I = list->begin();
- I != list->end(); I++)
- {
- PyObject *Obj;
- Obj = CppPyObject_NEW<metaIndex*>(&MetaIndexType,*I);
- PyList_Append(List,Obj);
- }
- return List;
+ PyObject *Obj;
+ Obj = CppPyObject_NEW<metaIndex*>(&MetaIndexType,*I);
+ PyList_Append(List,Obj);
}
- return Py_FindMethod(PkgSourceListMethods,Self,Name);
+ return List;
}
+
+static PyGetSetDef PkgSourceListGetSet[] = {
+ {"List",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0},
+ {}
+};
+
PyTypeObject PkgSourceListType =
{
PyObject_HEAD_INIT(&PyType_Type)
+ #if PY_MAJOR_VERSION < 3
0, // ob_size
+ #endif
"pkgSourceList", // tp_name
sizeof(CppPyObject<pkgSourceList*>), // tp_basicsize
0, // tp_itemsize
// Methods
CppDealloc<pkgSourceList*>, // tp_dealloc
0, // tp_print
- PkgSourceListAttr, // tp_getattr
+ 0, // tp_getattr
0, // tp_setattr
0, // tp_compare
0, // tp_repr
@@ -114,6 +117,22 @@ PyTypeObject PkgSourceListType =
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
+ "pkgSourceList Object", // tp_doc
+ 0, // tp_traverse
+ 0, // tp_clear
+ 0, // tp_richcompare
+ 0, // tp_weaklistoffset
+ 0, // tp_iter
+ 0, // tp_iternext
+ PkgSourceListMethods, // tp_methods
+ 0, // tp_members
+ PkgSourceListGetSet, // tp_getset
};
PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args)