summaryrefslogtreecommitdiff
path: root/python/apt_instmodule.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-08-07 17:47:25 +0200
committerJulian Andres Klode <jak@debian.org>2009-08-07 17:47:25 +0200
commite526904d0440e720cbeebf895faf884717f3fbb3 (patch)
tree8438ba618219fd3525627225d5634a091524d6a7 /python/apt_instmodule.cc
parent68120a33ecb68da02cfb8124244be79ff5a2fad8 (diff)
downloadpython-apt-e526904d0440e720cbeebf895faf884717f3fbb3.tar.gz
python/arfile.cc: Introduce apt_inst.ArArchive and apt_inst.ArMember.
This is part one of wishlist Bug#536096, introducing classes in apt_inst.
Diffstat (limited to 'python/apt_instmodule.cc')
-rw-r--r--python/apt_instmodule.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc
index 5aca4e00..aedccb47 100644
--- a/python/apt_instmodule.cc
+++ b/python/apt_instmodule.cc
@@ -169,11 +169,22 @@ static PyMethodDef methods[] =
{}
};
+
+static const char *apt_inst_doc =
+ "Functions for working with AR,tar archives and .deb packages.\n\n"
+ "This module provides useful classes and functions to work with\n"
+ "archives, modelled after the 'TarFile' class in the 'tarfile' module.";
+#define ADDTYPE(mod,name,type) { \
+ if (PyType_Ready(type) == -1) RETURN(0); \
+ Py_INCREF(type); \
+ PyModule_AddObject(mod,name,(PyObject *)type); }
+
+
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"apt_inst",
- "Functions for working with packages and ar,tar archives (apt-inst)",
+ apt_inst_doc,
-1,
methods,
0,
@@ -181,14 +192,20 @@ static struct PyModuleDef moduledef = {
0,
0
};
-
+#define RETURN(x) return x
extern "C" PyObject * PyInit_apt_inst()
-{
- return PyModule_Create(&moduledef);
-}
#else
extern "C" void initapt_inst()
+#define RETURN(x)
+#endif
{
- Py_InitModule("apt_inst",methods);
+#if PY_MAJOR_VERSION >= 3
+ PyObject *module = PyModule_Create(&moduledef);
+#else
+ PyObject *module = Py_InitModule3("apt_inst",methods, apt_inst_doc);
+#endif
+
+ ADDTYPE(module,"ArMember",&PyArMember_Type);
+ ADDTYPE(module,"ArArchive",&PyArArchive_Type);
+ RETURN(module);
}
-#endif /*}}}*/