summaryrefslogtreecommitdiff
path: root/python/pkgmanager.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-04-19 15:17:32 +0200
committerJulian Andres Klode <jak@debian.org>2009-04-19 15:17:32 +0200
commit45cdd4f2c6b04bfdfd37ef0e1a6358b29680afb8 (patch)
treeabe54ecca53fa226b4fd354a8b5f5e4224d47b50 /python/pkgmanager.cc
parent6472bb377c1effbf2b9a17188e5e057acdf9d195 (diff)
downloadpython-apt-45cdd4f2c6b04bfdfd37ef0e1a6358b29680afb8.tar.gz
* python/*.cc: Export all types and add a __new__() method to them.
Some names may be changed before the release, but this is a good draft.
Diffstat (limited to 'python/pkgmanager.cc')
-rw-r--r--python/pkgmanager.cc52
1 files changed, 33 insertions, 19 deletions
diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc
index 8f56cddc..781acc8b 100644
--- a/python/pkgmanager.cc
+++ b/python/pkgmanager.cc
@@ -15,8 +15,32 @@
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/configuration.h>
+
#include <iostream>
+static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
+{
+ PyObject *Owner;
+ char *kwlist[] = {"depcache",0};
+ if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType,
+ &Owner) == 0)
+ return 0;
+
+ pkgPackageManager *pm = _system->CreatePM(GetCpp<pkgDepCache*>(Owner));
+
+ CppPyObject<pkgPackageManager*> *PkgManagerObj =
+ CppPyObject_NEW<pkgPackageManager*>(type,pm);
+
+ return PkgManagerObj;
+}
+
+PyObject *GetPkgManager(PyObject *Self,PyObject *Args)
+{
+ return PkgManagerNew(&PkgManagerType,Args,0);
+}
+
static PyObject *PkgManagerGetArchives(PyObject *Self,PyObject *Args)
{
@@ -98,7 +122,7 @@ PyTypeObject PkgManagerType =
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
- "PackageManager", // tp_name
+ "apt_pkg.PackageManager", // tp_name
sizeof(CppPyObject<pkgPackageManager*>), // tp_basicsize
0, // tp_itemsize
// Methods
@@ -128,26 +152,16 @@ PyTypeObject PkgManagerType =
PkgManagerMethods, // tp_methods
0, // tp_members
PkgManagerGetSet, // 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
+ PkgManagerNew, // tp_new
};
-#include <apt-pkg/init.h>
-#include <apt-pkg/configuration.h>
-
-PyObject *GetPkgManager(PyObject *Self,PyObject *Args)
-{
- PyObject *Owner;
- if (PyArg_ParseTuple(Args,"O!",&PkgDepCacheType,&Owner) == 0)
- return 0;
-
- pkgPackageManager *pm = _system->CreatePM(GetCpp<pkgDepCache*>(Owner));
-
- CppPyObject<pkgPackageManager*> *PkgManagerObj =
- CppPyObject_NEW<pkgPackageManager*>(&PkgManagerType,pm);
-
- return PkgManagerObj;
-}
-
-
/*}}}*/