From daaa814658b6d2b8e3e2437fcc625096c46395dd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 23:24:42 +0200 Subject: * python/cdrom.cc, python/depcache.cc: Use tp_methods for Cdrom, ProblemResolver, ActionGroup --- python/depcache.cc | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/depcache.cc b/python/depcache.cc index 0e83c956..b23eecd9 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -749,15 +749,6 @@ static PyMethodDef PkgProblemResolverMethods[] = {} }; - -static PyObject *ProblemResolverAttr(PyObject *Self,char *Name) -{ - pkgProblemResolver *fixer = GetCpp(Self); - - return Py_FindMethod(PkgProblemResolverMethods,Self,Name); -} - - PyTypeObject PkgProblemResolverType = { PyObject_HEAD_INIT(&PyType_Type) @@ -768,7 +759,7 @@ PyTypeObject PkgProblemResolverType = // Methods CppOwnedDealloc, // tp_dealloc 0, // tp_print - ProblemResolverAttr, // tp_getattr + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr @@ -776,6 +767,20 @@ PyTypeObject PkgProblemResolverType = 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 + "ProblemResolver Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + PkgProblemResolverMethods, // tp_methods }; /*}}}*/ @@ -800,15 +805,6 @@ static PyMethodDef PkgActionGroupMethods[] = {} }; - -static PyObject *ActionGroupAttr(PyObject *Self,char *Name) -{ - pkgDepCache::ActionGroup *ag = GetCpp(Self); - - return Py_FindMethod(PkgActionGroupMethods,Self,Name); -} - - PyTypeObject PkgActionGroupType = { PyObject_HEAD_INIT(&PyType_Type) @@ -819,7 +815,7 @@ PyTypeObject PkgActionGroupType = // Methods CppOwnedDealloc, // tp_dealloc 0, // tp_print - ActionGroupAttr, // tp_getattr + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr @@ -827,6 +823,20 @@ PyTypeObject PkgActionGroupType = 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 + "ActionGroup Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + PkgActionGroupMethods, // tp_methods }; PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) -- cgit v1.2.3 From 8413810c46f802490280b0be1beebaaadf1aa9f2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 14 Apr 2009 00:47:23 +0200 Subject: * Remove any trailing whitespace --- apt/package.py | 3 +-- doc/source/apt_pkg/index.rst | 2 +- python/apt_pkgmodule.cc | 2 +- python/cache.cc | 2 +- python/cdrom.cc | 6 +++--- python/configuration.cc | 18 +++++++++--------- python/depcache.cc | 12 ++++++------ python/progress.cc | 2 +- python/tag.cc | 12 ++++++------ python/tar.cc | 2 +- tests/getcache_mem_corruption.py | 6 +++--- 11 files changed, 33 insertions(+), 34 deletions(-) (limited to 'python/depcache.cc') diff --git a/apt/package.py b/apt/package.py index 5adef15c..3ea1105d 100644 --- a/apt/package.py +++ b/apt/package.py @@ -639,7 +639,6 @@ class Package(object): def installedPriority(self): """Return the priority (of the installed version). - .. deprecated:: 0.7.9 """ return getattr(self.installed, 'priority', None) @@ -800,7 +799,7 @@ class Package(object): contain multiple named variables which will be substitued. These variables are (src_section, prefix, src_pkg, src_ver). An example is the Ubuntu changelog:: - + "http://changelogs.ubuntu.com/changelogs/pool" \\ "/%(src_section)s/%(prefix)s/%(src_pkg)s" \\ "/%(src_pkg)s_%(src_ver)s/changelog" diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index 38310bb5..60c3ba9b 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -252,7 +252,7 @@ Dependencies >>> apt_pkg.ParseDepends("PkgA (>= VerA) | PkgB (>= VerB)") [[('PkgA', 'VerA', '>='), ('PkgB', 'VerB', '>=')]] - + Furthemore, this function also supports to limit the architectures, as used in e.g. Build-Depends:: diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 5d0b2c0a..145a2bab 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -481,7 +481,7 @@ extern "C" void initapt_pkg() if (PyType_Ready(&PkgCdromType) == -1) return; if (PyType_Ready(&PkgProblemResolverType) == -1) return; if (PyType_Ready(&PkgActionGroupType) == -1) return; - + // Initialize the module PyObject *Module = Py_InitModule("apt_pkg",methods); diff --git a/python/cache.cc b/python/cache.cc index 4db097c7..31d8c45d 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -951,7 +951,7 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) progress.setCallbackInst(pyCallbackInst); if (Cache->Open(progress,false) == false) return HandleErrors(); - } + } else { OpTextProgress Prog; if (Cache->Open(Prog,false) == false) diff --git a/python/cdrom.cc b/python/cdrom.cc index 1278d6b7..0816d93e 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -84,16 +84,16 @@ PyTypeObject PkgCdromType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "Cdrom Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext PkgCdromMethods, // tp_methods }; diff --git a/python/configuration.cc b/python/configuration.cc index a95ac029..b4adf357 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -498,16 +498,16 @@ PyTypeObject ConfigurationType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "Configuration Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods }; @@ -532,16 +532,16 @@ PyTypeObject ConfigurationPtrType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "ConfigurationPtr Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods }; @@ -566,16 +566,16 @@ PyTypeObject ConfigurationSubType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "ConfigurationSub Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods }; diff --git a/python/depcache.cc b/python/depcache.cc index b23eecd9..2c73a1a9 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -769,16 +769,16 @@ PyTypeObject PkgProblemResolverType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "ProblemResolver Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext PkgProblemResolverMethods, // tp_methods }; @@ -825,16 +825,16 @@ PyTypeObject PkgActionGroupType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "ActionGroup Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext PkgActionGroupMethods, // tp_methods }; diff --git a/python/progress.cc b/python/progress.cc index c5a1c138..bec40ce9 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -185,7 +185,7 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) bool res = true; if(!PyArg_Parse(result, "b", &res)) { - // most of the time the user who subclasses the pulse() + // most of the time the user who subclasses the pulse() // method forgot to add a return {True,False} so we just // assume he wants a True return true; diff --git a/python/tag.cc b/python/tag.cc index baf97b59..cdea3e03 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -401,16 +401,16 @@ PyTypeObject TagSecType = 0, // tp_hash 0, // tp_call TagSecStr, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "TagSection Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext TagSecMethods // tp_methods }; @@ -459,16 +459,16 @@ PyTypeObject TagFileType = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + 0, // tp_getattro 0, // tp_setattro - 0, // tp_as_buffer + 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags "TagFile Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter + 0, // tp_iter 0, // tp_iternext TagFileMethods, // tp_methods 0, // tp_members diff --git a/python/tar.cc b/python/tar.cc index f0d57823..217554c2 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -111,7 +111,7 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) int fileno = PyObject_AsFileDescriptor(File); if (fileno == -1) return 0; - + FileFd Fd(fileno,false); ExtractTar Tar(Fd,0xFFFFFFFF,Comp); if (_error->PendingError() == true) diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py index 42e9af00..c3f6eff3 100644 --- a/tests/getcache_mem_corruption.py +++ b/tests/getcache_mem_corruption.py @@ -6,16 +6,16 @@ import re import unittest class TestGetCache(unittest.TestCase): - + def setUp(self): apt_pkg.InitConfig() apt_pkg.InitSystem() - + def testWrongInvocation(self): # wrongly invoke GetCache() rather than GetDepCache() apt_cache = apt_pkg.GetCache() self.assertRaises(ValueError, apt_pkg.GetCache, apt_cache) - + def testProperInvocation(self): apt_cache = apt_pkg.GetCache(apt.progress.OpTextProgress()) apt_depcache = apt_pkg.GetDepCache(apt_cache) -- cgit v1.2.3 From caef6ff047586413cbd2daef969f29c38481fa86 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 14 Apr 2009 19:07:07 +0200 Subject: * python/depcache.cc: Use tp_methods and tp_getset for PkgDepCacheType --- python/apt_pkgmodule.cc | 1 + python/depcache.cc | 77 +++++++++++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 28 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 49b6a35f..8ed3e599 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -484,6 +484,7 @@ extern "C" void initapt_pkg() if (PyType_Ready(&PkgSourceListType) == -1) return; if (PyType_Ready(&PkgCacheType) == -1) return; if (PyType_Ready(&DependencyType) == -1) return; + if (PyType_Ready(&PkgDepCacheType) == -1) return; // Initialize the module diff --git a/python/depcache.cc b/python/depcache.cc index 2c73a1a9..ade3d4f5 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -560,50 +560,71 @@ static PyMethodDef PkgDepCacheMethods[] = {} }; - -static PyObject *DepCacheAttr(PyObject *Self,char *Name) -{ - pkgDepCache *depcache = GetCpp(Self); - - // size querries - if(strcmp("KeepCount",Name) == 0) - return Py_BuildValue("l", depcache->KeepCount()); - else if(strcmp("InstCount",Name) == 0) - return Py_BuildValue("l", depcache->InstCount()); - else if(strcmp("DelCount",Name) == 0) - return Py_BuildValue("l", depcache->DelCount()); - else if(strcmp("BrokenCount",Name) == 0) - return Py_BuildValue("l", depcache->BrokenCount()); - else if(strcmp("UsrSize",Name) == 0) - return Py_BuildValue("d", depcache->UsrSize()); - else if(strcmp("DebSize",Name) == 0) - return Py_BuildValue("d", depcache->DebSize()); - - - return Py_FindMethod(PkgDepCacheMethods,Self,Name); +#define depcache (GetCpp(Self)) +static PyObject *PkgDepCacheGetKeepCount(PyObject *Self,void*) { + return Py_BuildValue("l", depcache->KeepCount()); } +static PyObject *PkgDepCacheGetInstCount(PyObject *Self,void*) { + return Py_BuildValue("l", depcache->InstCount()); +} +static PyObject *PkgDepCacheGetDelCount(PyObject *Self,void*) { + return Py_BuildValue("l", depcache->DelCount()); +} +static PyObject *PkgDepCacheGetBrokenCount(PyObject *Self,void*) { + return Py_BuildValue("l", depcache->BrokenCount()); +} +static PyObject *PkgDepCacheGetUsrSize(PyObject *Self,void*) { + return Py_BuildValue("d", depcache->UsrSize()); +} +static PyObject *PkgDepCacheGetDebSize(PyObject *Self,void*) { + return Py_BuildValue("d", depcache->DebSize()); +} +#undef depcache - - +static PyGetSetDef PkgDepCacheGetSet[] = { + {"BrokenCount",PkgDepCacheGetBrokenCount}, + {"DebSize",PkgDepCacheGetDebSize}, + {"DelCount",PkgDepCacheGetDelCount}, + {"InstCount",PkgDepCacheGetInstCount}, + {"KeepCount",PkgDepCacheGetKeepCount}, + {"UsrSize",PkgDepCacheGetUsrSize}, + {} +}; PyTypeObject PkgDepCacheType = { PyObject_HEAD_INIT(&PyType_Type) - 0, // ob_size - "pkgDepCache", // tp_name + 0, // ob_size + "pkgDepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDealloc, // tp_dealloc 0, // tp_print - DepCacheAttr, // tp_getattr + 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_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 + "pkgDepCache Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + PkgDepCacheMethods, // tp_methods + 0, // tp_members + PkgDepCacheGetSet, // tp_getset }; -- cgit v1.2.3 From c876c5095673a2f1c0f2c0eef6eadef2ce200e19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 16:19:12 +0200 Subject: * Introduce support for Python 3 (Closes: #523645) This is the first initial port to Python 3. The API is almost completely identical to the one found in Python 2, except that functions working with binary data require bytes (md5sum,sha1sum,sha256sum,Base64Encode). Using setup3.py to install the modules will not work, because the apt package still has to be converted to Python 3. For the package, we call 2to3-3.1 in debian/rules to do this automatically. --- apt/package.py | 6 +++- debian/changelog | 2 ++ debian/control | 2 ++ debian/rules | 26 +++++++++++++-- po/python-apt.pot | 10 +++--- python/acquire.cc | 6 ++++ python/apt_instmodule.cc | 35 ++++++++++++++++++- python/apt_pkgmodule.cc | 87 +++++++++++++++++++++++++++++++++++------------- python/cache.cc | 18 ++++++++++ python/cdrom.cc | 2 ++ python/configuration.cc | 6 ++++ python/depcache.cc | 6 ++++ python/generic.h | 25 ++++++++++++++ python/indexfile.cc | 2 ++ python/metaindex.cc | 2 ++ python/pkgmanager.cc | 2 ++ python/pkgrecords.cc | 2 ++ python/pkgsrcrecords.cc | 2 ++ python/sourcelist.cc | 2 ++ python/string.cc | 16 ++++++++- python/tag.cc | 4 +++ setup3.py | 77 ++++++++++++++++++++++++++++++++++++++++++ 22 files changed, 307 insertions(+), 33 deletions(-) create mode 100644 setup3.py (limited to 'python/depcache.cc') diff --git a/apt/package.py b/apt/package.py index 3ea1105d..f12f5559 100644 --- a/apt/package.py +++ b/apt/package.py @@ -272,8 +272,12 @@ class Version(object): """ self.summary # This does the lookup for us. desc = '' + + dsc = self.package._pcache._records.LongDesc try: - dsc = unicode(self.package._pcache._records.LongDesc, "utf-8") + if not isinstance(dsc, unicode): + # Only convert where needed (i.e. Python 2.X) + dsc = unicode(dsc, "utf-8") except UnicodeDecodeError, err: return _("Invalid unicode in description for '%s' (%s). " "Please report.") % (self.package.name, err) diff --git a/debian/changelog b/debian/changelog index 6cbdaac7..a9518d7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ python-apt (0.7.11) UNRELEASED; 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 diff --git a/debian/control b/debian/control index 72476c58..08ee329f 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,8 @@ Build-Depends: apt-utils, libapt-pkg-dev (>= 0.7.10), python-all-dbg, python-all-dev, + python3.1-dev, + python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 1.9.0), python-gtk2, diff --git a/debian/rules b/debian/rules index 6d709ecd..7de945f2 100755 --- a/debian/rules +++ b/debian/rules @@ -11,22 +11,44 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk +PY3K = y PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) export DEBVER + +ifeq ($(PY3K),y) +build/python-apt:: + python3.1 setup3.py build + +install/python-apt:: + python3.1 ./setup3.py install --root $(CURDIR)/debian/python-apt \ + --install-layout=deb --no-compile + + find $(CURDIR)/debian/python-apt/usr/lib/python3.1/dist-packages/ -name '*.py' \ + | xargs 2to3-3.1 | patch -p0 +endif + build/python-apt-dbg:: set -e; \ for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py build + endif install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ - python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg; \ + python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ + --no-compile; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ + --install-layout=deb --no-compile + endif find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; @@ -39,4 +61,4 @@ binary-predeb/python-apt-dbg:: ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg clean:: - rm -rf build/lib* build/temp* + rm -rf build/lib* build/temp* build diff --git a/po/python-apt.pot b/po/python-apt.pot index 9c23c579..d12ae967 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-12 19:07+0200\n" +"POT-Creation-Date: 2009-04-15 16:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -354,16 +354,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:278 +#: ../apt/package.py:282 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:745 ../apt/package.py:849 +#: ../apt/package.py:830 ../apt/package.py:934 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:853 +#: ../apt/package.py:938 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -372,7 +372,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:859 +#: ../apt/package.py:944 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." diff --git a/python/acquire.cc b/python/acquire.cc index d39ee495..053753cd 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -72,7 +72,9 @@ static PyObject *AcquireItemRepr(PyObject *Self) PyTypeObject AcquireItemType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquire::ItemIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -175,7 +177,9 @@ static PyGetSetDef PkgAcquireGetSet[] = { PyTypeObject PkgAcquireType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Acquire", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -234,7 +238,9 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) PyTypeObject PkgAcquireFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquireFile", // tp_name sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index a9d81be4..09e3937e 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -162,8 +162,41 @@ static PyMethodDef methods[] = {} }; +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +extern "C" PyObject * PyInit_apt_inst() +{ + return PyModule_Create(&moduledef); +} +#else extern "C" void initapt_inst() { Py_InitModule("apt_inst",methods); } - /*}}}*/ +#endif /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fe6a739e..e71d8ee6 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -173,12 +173,12 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; MD5Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -213,12 +213,12 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA1Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -253,12 +253,12 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA256Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -470,30 +470,68 @@ static void AddInt(PyObject *Dict,const char *Itm,unsigned long I) Py_DECREF(Obj); } +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; + +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +#define INIT_ERROR return 0 +extern "C" PyObject * PyInit_apt_pkg() +#else +#define INIT_ERROR return extern "C" void initapt_pkg() +#endif { // Finalize our types to add slots, etc. - if (PyType_Ready(&TagSecType) == -1) return; - if (PyType_Ready(&TagFileType) == -1) return; - if (PyType_Ready(&ConfigurationType) == -1) return; - if (PyType_Ready(&ConfigurationPtrType) == -1) return; - if (PyType_Ready(&ConfigurationSubType) == -1) return; - if (PyType_Ready(&PkgCdromType) == -1) return; - if (PyType_Ready(&PkgProblemResolverType) == -1) return; - if (PyType_Ready(&PkgActionGroupType) == -1) return; - if (PyType_Ready(&PkgSourceListType) == -1) return; - if (PyType_Ready(&PkgCacheType) == -1) return; - if (PyType_Ready(&DependencyType) == -1) return; - if (PyType_Ready(&PkgDepCacheType) == -1) return; - if (PyType_Ready(&PkgAcquireType) == -1) return; - if (PyType_Ready(&PackageIndexFileType) == -1) return; - if (PyType_Ready(&PkgManagerType) == -1) return; - if (PyType_Ready(&PkgSrcRecordsType) == -1) return; - if (PyType_Ready(&PkgRecordsType) == -1) return; + if (PyType_Ready(&TagSecType) == -1) INIT_ERROR; + if (PyType_Ready(&TagFileType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationPtrType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationSubType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCdromType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgProblemResolverType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgActionGroupType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSourceListType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&DependencyType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgDepCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgAcquireType) == -1) INIT_ERROR; + if (PyType_Ready(&PackageIndexFileType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgManagerType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSrcRecordsType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgRecordsType) == -1) INIT_ERROR; // Initialize the module + #if PY_MAJOR_VERSION >= 3 + PyObject *Module = PyModule_Create(&moduledef); + #else PyObject *Module = Py_InitModule("apt_pkg",methods); + #endif PyObject *Dict = PyModule_GetDict(Module); // Global variable linked to the global configuration class @@ -549,6 +587,9 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); + #if PY_MAJOR_VERSION >= 3 + return Module; + #endif } /*}}}*/ diff --git a/python/cache.cc b/python/cache.cc index 2d8b8db7..957681ba 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -239,7 +239,9 @@ static PyMappingMethods CacheMap = {0,CacheMapOp,0}; PyTypeObject PkgCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -277,7 +279,9 @@ PyTypeObject PkgCacheType = PyTypeObject PkgCacheFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCacheFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -345,7 +349,9 @@ static PySequenceMethods PkgListSeq = PyTypeObject PkgListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -435,7 +441,9 @@ static PyObject *PackageRepr(PyObject *Self) PyTypeObject PackageType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::Package", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -498,7 +506,9 @@ static PyObject *DescriptionRepr(PyObject *Self) PyTypeObject DescriptionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DescIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -684,7 +694,9 @@ static PyObject *VersionRepr(PyObject *Self) PyTypeObject VersionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::VerIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -759,7 +771,9 @@ static PyObject *PackageFileRepr(PyObject *Self) PyTypeObject PackageFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgFileIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -905,7 +919,9 @@ static PyGetSetDef DependencyGetSet[] = { PyTypeObject DependencyType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -991,7 +1007,9 @@ static PySequenceMethods RDepListSeq = PyTypeObject RDepListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/cdrom.cc b/python/cdrom.cc index 0816d93e..b3a38438 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -67,7 +67,9 @@ static PyMethodDef PkgCdromMethods[] = PyTypeObject PkgCdromType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Cdrom", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/configuration.cc b/python/configuration.cc index b4adf357..eaac48ec 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -481,7 +481,9 @@ static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; PyTypeObject ConfigurationType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -515,7 +517,9 @@ PyTypeObject ConfigurationType = PyTypeObject ConfigurationPtrType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationPtr", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -549,7 +553,9 @@ PyTypeObject ConfigurationPtrType = PyTypeObject ConfigurationSubType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationSub", // tp_name sizeof(SubConfiguration), // tp_basicsize 0, // tp_itemsize diff --git a/python/depcache.cc b/python/depcache.cc index ade3d4f5..1c9eeff7 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -594,7 +594,9 @@ static PyGetSetDef PkgDepCacheGetSet[] = { PyTypeObject PkgDepCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgDepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -773,7 +775,9 @@ static PyMethodDef PkgProblemResolverMethods[] = PyTypeObject PkgProblemResolverType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgProblemResolver", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -829,7 +833,9 @@ static PyMethodDef PkgActionGroupMethods[] = PyTypeObject PkgActionGroupType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgActionGroup", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/generic.h b/python/generic.h index ce79a54c..6e66d24c 100644 --- a/python/generic.h +++ b/python/generic.h @@ -35,6 +35,31 @@ typedef int Py_ssize_t; #endif +/* Define compatibility for Python 3. + * + * We will use the names PyString_* to refer to the default string type + * of the current Python version (PyString on 2.X, PyUnicode on 3.X). + * + * When we really need unicode strings, we will use PyUnicode_* directly, as + * long as it exists in Python 2 and Python 3. + * + * When we want bytes in Python 3, we use PyBytes*_ instead of PyString_* and + * define aliases from PyBytes_* to PyString_* for Python 2. + */ + +#if PY_MAJOR_VERSION >= 3 +#define PyString_Check PyUnicode_Check +#define PyString_FromString PyUnicode_FromString +#define PyString_FromStringAndSize PyUnicode_FromStringAndSize +#define PyString_AsString(op) PyBytes_AsString(PyUnicode_AsUTF8String(op)) +#define PyInt_Check PyLong_Check +#define PyInt_AsLong PyLong_AsLong +#else +#define PyBytes_Check PyString_Check +#define PyBytes_AsString PyString_AsString +#define PyBytes_AsStringAndSize PyString_AsStringAndSize +#endif + template struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the diff --git a/python/indexfile.cc b/python/indexfile.cc index dc55634f..bb40cdd0 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -81,7 +81,9 @@ static PyGetSetDef PackageIndexFileGetSet[] = { PyTypeObject PackageIndexFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgIndexFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/metaindex.cc b/python/metaindex.cc index efbc38af..cbaeafbd 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -59,7 +59,9 @@ static PyObject *MetaIndexRepr(PyObject *Self) PyTypeObject MetaIndexType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "metaIndex", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 52f86228..8f56cddc 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -95,7 +95,9 @@ static PyGetSetDef PkgManagerGetSet[] = { PyTypeObject PkgManagerType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "PackageManager", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 577aaf1c..978de6b7 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -135,7 +135,9 @@ static PyGetSetDef PkgRecordsGetSet[] = { PyTypeObject PkgRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index c830f8d2..97667d7a 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -183,7 +183,9 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { PyTypeObject PkgSrcRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSrcRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 9f8f8878..48b3b7c8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -100,7 +100,9 @@ static PyGetSetDef PkgSourceListGetSet[] = { PyTypeObject PkgSourceListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSourceList", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/string.cc b/python/string.cc index 8168ea5b..b95ee3eb 100644 --- a/python/string.cc +++ b/python/string.cc @@ -38,7 +38,21 @@ PyObject *Python(PyObject *Self,PyObject *Args) \ } MkStr(StrDeQuote,DeQuoteString); -MkStr(StrBase64Encode,Base64Encode); + +/* + * Input bytes(Py3k)/str(Py2), output str. + */ +PyObject *StrBase64Encode(PyObject *Self,PyObject *Args) { + char *Str = 0; + #if PY_MAJOR_VERSION >= 3 + if (PyArg_ParseTuple(Args,"y",&Str) == 0) + #else + if (PyArg_ParseTuple(Args,"s",&Str) == 0) + #endif + return 0; + return CppPyString(Base64Encode(Str)); +} + MkStr(StrURItoFileName,URItoFileName); //MkFloat(StrSizeToStr,SizeToStr); diff --git a/python/tag.cc b/python/tag.cc index cdea3e03..18d08580 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -384,7 +384,9 @@ PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; PyTypeObject TagSecType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize @@ -442,7 +444,9 @@ static PyGetSetDef TagFileGetSet[] = { PyTypeObject TagFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagFile", // tp_name sizeof(TagFileData), // tp_basicsize 0, // tp_itemsize diff --git a/setup3.py b/setup3.py new file mode 100644 index 00000000..a3cbdc8e --- /dev/null +++ b/setup3.py @@ -0,0 +1,77 @@ +#! /usr/bin/env python3 +# $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ +import glob +import os +import shutil +import sys + +from distutils.core import setup, Extension +from distutils.sysconfig import parse_makefile +#from DistUtilsExtra.command import build_extra, build_i18n + + +# The apt_pkg module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_PKG_SRC"].split()] +apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) + +# The apt_inst module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_INST_SRC"].split()] +apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) + +# Replace the leading _ that is used in the templates for translation +templates = [] + +# build doc +if len(sys.argv) > 1 and sys.argv[1] == "build": + if not os.path.exists("build/data/templates/"): + os.makedirs("build/data/templates") + for template in glob.glob('data/templates/*.info.in'): + source = open(template, "r") + build = open(os.path.join("build", template[:-3]), "w") + lines = source.readlines() + for line in lines: + build.write(line.lstrip("_")) + source.close() + build.close() + + +if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: + for dirname in "build/doc", "doc/build", "build/data", "build/mo": + if os.path.exists(dirname): + print("Removing", dirname) + shutil.rmtree(dirname) + else: + print("Not removing", dirname, "because it does not exist") + +setup(name="python-apt", + description="Python bindings for APT", + version=os.environ.get('DEBVER'), + author="APT Development Team", + author_email="deity@lists.debian.org", + ext_modules=[apt_pkg, apt_inst], + packages=['apt', 'apt.progress', 'aptsources'], + data_files = [('share/python-apt/templates', + glob.glob('build/data/templates/*.info')), + ('share/python-apt/templates', + glob.glob('data/templates/*.mirrors'))], +# cmdclass = {"build": build_extra.build_extra, +# "build_i18n": build_i18n.build_i18n}, + license = 'GNU GPL', + platforms = 'posix') + +if len(sys.argv) > 1 and sys.argv[1] == "build": + try: + import sphinx + except ImportError: + print(('W: Sphinx not available - Not building' + 'documentation'), file=sys.stderr) + try: + import pygtk + except ImportError: + print(('W: Not building documentation because python-' + 'gtk2 is not available at the moment.'), file=sys.stderr) + sys.exit(0) + sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/html"]) + sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From 45cdd4f2c6b04bfdfd37ef0e1a6358b29680afb8 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 19 Apr 2009 15:17:32 +0200 Subject: * 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. --- python/acquire.cc | 119 ++++++++++++++++++++++++++++++++-------- python/apt_pkgmodule.cc | 49 +++++++++++++++++ python/apt_pkgmodule.h | 1 + python/cache.cc | 125 ++++++++++++++++++++++++------------------ python/cdrom.cc | 38 +++++++++---- python/configuration.cc | 23 ++++++-- python/depcache.cc | 140 +++++++++++++++++++++++++++++++++--------------- python/indexfile.cc | 2 +- python/metaindex.cc | 2 +- python/pkgmanager.cc | 52 +++++++++++------- python/pkgrecords.cc | 31 ++++++++--- python/pkgsrcrecords.cc | 18 ++++++- python/sourcelist.cc | 18 ++++++- python/tag.cc | 75 ++++++++++++++++++++------ 14 files changed, 519 insertions(+), 174 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index abd3884d..1cdf0cb9 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -194,13 +194,41 @@ static PyGetSetDef PkgAcquireGetSet[] = { {} }; +static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { + pkgAcquire *fetcher; + + PyObject *pyFetchProgressInst = NULL; + static char *kwlist[] = {"progress", 0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"|O",kwlist,&pyFetchProgressInst) == 0) + return 0; + + if (pyFetchProgressInst != NULL) { + // FIXME: memleak? + PyFetchProgress *progress = new PyFetchProgress(); + progress->setCallbackInst(pyFetchProgressInst); + fetcher = new pkgAcquire(progress); + } else { + fetcher = new pkgAcquire(); + } + + CppPyObject *FetcherObj = + CppPyObject_NEW(type, fetcher); + + return FetcherObj; +} + +static const char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n" + "Create a new acquire object. The parameter *progress* can be used to\n" + "specify a apt.progress.FetchProgress() object, which will display the\n" + "progress of the fetching."; + PyTypeObject PkgAcquireType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "Acquire", // tp_name + "apt_pkg.Acquire", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -220,7 +248,7 @@ PyTypeObject PkgAcquireType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "pkgAcquire Object", // tp_doc + doc_PkgAcquire, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -230,38 +258,66 @@ PyTypeObject PkgAcquireType = PkgAcquireMethods, // tp_methods 0, // tp_members PkgAcquireGetSet, // 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 + PkgAcquireNew, // tp_new }; + PyObject *GetAcquire(PyObject *Self,PyObject *Args) { - pkgAcquire *fetcher; + return PkgAcquireNew(&PkgAcquireType,Args,0); +} - PyObject *pyFetchProgressInst = NULL; - if (PyArg_ParseTuple(Args,"|O",&pyFetchProgressInst) == 0) - return 0; +static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject * kwds) +{ + PyObject *pyfetcher; + char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; + int size = 0; + uri = md5 = descr = shortDescr = destDir = destFile = ""; - if (pyFetchProgressInst != NULL) { - // FIXME: memleak? - PyFetchProgress *progress = new PyFetchProgress(); - progress->setCallbackInst(pyFetchProgressInst); - fetcher = new pkgAcquire(progress); - } else { - fetcher = new pkgAcquire(); - } + char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortdescr", + "destdir", "destfile", NULL}; - CppPyObject *FetcherObj = - CppPyObject_NEW(&PkgAcquireType, fetcher); + if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, + &PkgAcquireType, &pyfetcher, &uri, &md5, + &size, &descr, &shortDescr, &destDir, &destFile) == 0) + return 0; - return FetcherObj; + pkgAcquire *fetcher = GetCpp(pyfetcher); + pkgAcqFile *af = new pkgAcqFile(fetcher, // owner + uri, // uri + md5, // md5 + size, // size + descr, // descr + shortDescr, + destDir, + destFile); // short-desc + CppPyObject *AcqFileObj = CppPyObject_NEW(type); + AcqFileObj->Object = af; + + return AcqFileObj; } + +static const char *doc_PkgAcquireFile = + "AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir," + "dest_file]) -> New AcquireFile() object\n\n" + "The parameter *owner* refers to an apt_pkg.Acquire() object. You can use\n" + "*destdir* OR *destfile* to specify the destination directory/file."; + PyTypeObject PkgAcquireFileType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgAcquireFile", // tp_name + "apt_pkg.AcquireFile", // tp_name sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize // Methods @@ -275,6 +331,30 @@ PyTypeObject PkgAcquireFileType = 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 + doc_PkgAcquireFile, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + 0, // tp_methods + 0, // tp_members + 0, // 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 + PkgAcquireFileNew, // tp_new }; char *doc_GetPkgAcqFile = @@ -308,6 +388,3 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) return AcqFileObj; } - - - /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 0fcf1f29..a54b3922 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -385,14 +385,18 @@ static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args) static PyMethodDef methods[] = { // Constructors + #ifdef COMPAT_0_7 {"newConfiguration",newConfiguration,METH_VARARGS,doc_newConfiguration}, + #endif {"init",Init,METH_VARARGS,doc_Init}, {"InitConfig",InitConfig,METH_VARARGS,doc_InitConfig}, {"InitSystem",InitSystem,METH_VARARGS,doc_InitSystem}, // Tag File + #ifdef COMPAT_0_7 {"ParseSection",ParseSection,METH_VARARGS,doc_ParseSection}, {"ParseTagFile",ParseTagFile,METH_VARARGS,doc_ParseTagFile}, + #endif {"RewriteSection",RewriteSection,METH_VARARGS,doc_RewriteSection}, // Locking @@ -433,6 +437,7 @@ static PyMethodDef methods[] = {"StrToTime",StrStrToTime,METH_VARARGS,"StrToTime(String) -> Int"}, // Cache + #ifdef COMPAT_0_7 {"GetCache",TmpGetCache,METH_VARARGS,"GetCache() -> PkgCache"}, {"GetDepCache",GetDepCache,METH_VARARGS,"GetDepCache(Cache) -> DepCache"}, {"GetPkgRecords",GetPkgRecords,METH_VARARGS,"GetPkgRecords(Cache) -> PkgRecords"}, @@ -452,11 +457,16 @@ static PyMethodDef methods[] = // PkgManager {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"}, + #endif {} }; +#define ADDTYPE(mod,name,type) { Py_INCREF(type); \ + PyModule_AddObject(mod,name,(PyObject *)type); } + + #if PY_MAJOR_VERSION >= 3 struct module_state { PyObject *error; @@ -527,6 +537,45 @@ extern "C" void initapt_pkg() Config->Object = _config; PyModule_AddObject(Module,"Config",Config); + // Add our classes. + /* ============================ tag.cc ============================ */ + ADDTYPE(Module,"TagSection",&TagSecType); + ADDTYPE(Module,"TagFile",&TagFileType); + /* ============================ acquire.cc ============================ */ + ADDTYPE(Module,"Acquire",&PkgAcquireType); + ADDTYPE(Module,"AcquireFile",&PkgAcquireFileType); + ADDTYPE(Module,"AcquireItem",&AcquireItemType); // NO __new__() + /* ============================ cache.cc ============================ */ + ADDTYPE(Module,"Cache",&PkgCacheType); + ADDTYPE(Module,"Dependency",&DependencyType); // NO __new__() + ADDTYPE(Module,"Description",&DescriptionType); // NO __new__() + ADDTYPE(Module,"PackageFile",&PackageFileType); // NO __new__() + //ADDTYPE(Module,"PackageList",&PkgListType); // NO __new__(), internal + //ADDTYPE(Module,"DependencyList",&RDepListType); // NO __new__(), internal + ADDTYPE(Module,"Package",&PackageType); // NO __new__() + ADDTYPE(Module,"Version",&VersionType); // NO __new__() + /* ============================ cdrom.cc ============================ */ + ADDTYPE(Module,"Cdrom",&PkgCdromType); + /* ========================= configuration.cc ========================= */ + ADDTYPE(Module,"Configuration",&ConfigurationType); + //ADDTYPE(Module,"ConfigurationSub",&ConfigurationSubType); // NO __new__() + //ADDTYPE(Module,"ConfigurationPtr",&ConfigurationPtrType); // NO __new__() + /* ========================= depcache.cc ========================= */ + ADDTYPE(Module,"ActionGroup",&PkgActionGroupType); + ADDTYPE(Module,"DepCache",&PkgDepCacheType); + ADDTYPE(Module,"ProblemResolver",&PkgProblemResolverType); + /* ========================= indexfile.cc ========================= */ + ADDTYPE(Module,"PackageIndexFile",&PackageIndexFileType); // NO __new__() + /* ========================= metaindex.cc ========================= */ + ADDTYPE(Module,"MetaIndex",&MetaIndexType); // NO __new__() + /* ========================= pkgmanager.cc ========================= */ + ADDTYPE(Module,"PackageManager",&PkgManagerType); + /* ========================= pkgrecords.cc ========================= */ + ADDTYPE(Module,"PackageRecords",&PkgRecordsType); + /* ========================= pkgsrcrecords.cc ========================= */ + ADDTYPE(Module,"SourceRecords",&PkgSrcRecordsType); + /* ========================= sourcelist.cc ========================= */ + ADDTYPE(Module,"SourceList",&PkgSourceListType); // Tag file constants PyModule_AddObject(Module,"RewritePackageOrder", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 424c4788..f7ef63c2 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -80,6 +80,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args); // acquire extern PyTypeObject AcquireItemType; extern PyTypeObject PkgAcquireType; +extern PyTypeObject PkgAcquireFileType; extern char *doc_GetPkgAcqFile; PyObject *GetAcquire(PyObject *Self,PyObject *Args); PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject *kwds); diff --git a/python/cache.cc b/python/cache.cc index 92e064b2..0862cd77 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -235,6 +235,61 @@ void PkgCacheFileDealloc(PyObject *Self) CppOwnedDealloc(Self); } +static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + PyObject *pyCallbackInst = 0; + static char *kwlist[] = {"progress", 0}; + if (PyArg_ParseTupleAndKeywords (Args, kwds, "|O", kwlist, &pyCallbackInst) == 0) + return 0; + + if (_system == 0) { + PyErr_SetString(PyExc_ValueError,"_system not initialized"); + return 0; + } + + pkgCacheFile *Cache = new pkgCacheFile(); + + if(pyCallbackInst != 0) { + // sanity check for the progress object, see #497049 + if (PyObject_HasAttrString(pyCallbackInst, "done") != true) { + PyErr_SetString(PyExc_ValueError, + "OpProgress object must implement done()"); + return 0; + } + if (PyObject_HasAttrString(pyCallbackInst, "update") != true) { + PyErr_SetString(PyExc_ValueError, + "OpProgress object must implement update()"); + return 0; + } + PyOpProgress progress; + progress.setCallbackInst(pyCallbackInst); + if (Cache->Open(progress,false) == false) + return HandleErrors(); + } + else { + OpTextProgress Prog; + if (Cache->Open(Prog,false) == false) + return HandleErrors(); + } + + CppOwnedPyObject *CacheFileObj = + CppOwnedPyObject_NEW(0,&PkgCacheFileType, Cache); + + CppOwnedPyObject *CacheObj = + CppOwnedPyObject_NEW(CacheFileObj,type, + (pkgCache *)(*Cache)); + + //Py_DECREF(CacheFileObj); + return CacheObj; +} + +static const char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" + "The cache provides access to the packages and other stuff.\n\n" + "The optional parameter *progress* can be used to specify an \n" + "apt.progress.OpProgress() object (or similar) which displays\n" + "the opening progress.\n\n" + "If not specified, the progress is displayed in simple text form."; + static PyMappingMethods CacheMap = {0,CacheMapOp,0}; PyTypeObject PkgCacheType = { @@ -242,7 +297,7 @@ PyTypeObject PkgCacheType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache", // tp_name + "apt_pkg.Cache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -262,7 +317,7 @@ PyTypeObject PkgCacheType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT , // tp_flags - "Cache Object", // tp_doc + doc_PkgCache, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -272,6 +327,14 @@ PyTypeObject PkgCacheType = PkgCacheMethods, // tp_methods 0, // tp_members PkgCacheGetSet, // 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 + PkgCacheNew, // tp_new }; /*}}}*/ // PkgCacheFile Class /*{{{*/ @@ -352,7 +415,7 @@ PyTypeObject PkgListType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::PkgIterator", // tp_name + "apt_pkg.PackageList", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -452,7 +515,7 @@ PyTypeObject PackageType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::Package", // tp_name + "apt_pkg.Package", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -539,7 +602,7 @@ PyTypeObject DescriptionType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::DescIterator", // tp_name + "apt_pkg.Description", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -743,7 +806,7 @@ PyTypeObject VersionType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::VerIterator", // tp_name + "apt_pkg.Version", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -820,7 +883,7 @@ PyTypeObject PackageFileType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::PkgFileIterator", // tp_name + "apt_pkg.PackageFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -968,7 +1031,7 @@ PyTypeObject DependencyType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::DepIterator", // tp_name + "apt_pkg.Dependency", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -1056,7 +1119,7 @@ PyTypeObject RDepListType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgCache::DepIterator", // tp_name + "apt_pkg.DependencyList", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -1078,47 +1141,5 @@ PyTypeObject RDepListType = PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { - PyObject *pyCallbackInst = 0; - if (PyArg_ParseTuple(Args, "|O", &pyCallbackInst) == 0) - return 0; - - if (_system == 0) { - PyErr_SetString(PyExc_ValueError,"_system not initialized"); - return 0; - } - - pkgCacheFile *Cache = new pkgCacheFile(); - - if(pyCallbackInst != 0) { - // sanity check for the progress object, see #497049 - if (PyObject_HasAttrString(pyCallbackInst, "done") != true) { - PyErr_SetString(PyExc_ValueError, - "OpProgress object must implement done()"); - return 0; - } - if (PyObject_HasAttrString(pyCallbackInst, "update") != true) { - PyErr_SetString(PyExc_ValueError, - "OpProgress object must implement update()"); - return 0; - } - PyOpProgress progress; - progress.setCallbackInst(pyCallbackInst); - if (Cache->Open(progress,false) == false) - return HandleErrors(); - } - else { - OpTextProgress Prog; - if (Cache->Open(Prog,false) == false) - return HandleErrors(); - } - - CppOwnedPyObject *CacheFileObj = - CppOwnedPyObject_NEW(0,&PkgCacheFileType, Cache); - - CppOwnedPyObject *CacheObj = - CppOwnedPyObject_NEW(CacheFileObj,&PkgCacheType, - (pkgCache *)(*Cache)); - - //Py_DECREF(CacheFileObj); - return CacheObj; + return PkgCacheNew(&PkgCacheType,Args,0); } diff --git a/python/cdrom.cc b/python/cdrom.cc index b3a38438..bf94a390 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -58,19 +58,34 @@ static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args) static PyMethodDef PkgCdromMethods[] = { - {"Add",PkgCdromAdd,METH_VARARGS,"Add a cdrom"}, - {"Ident",PkgCdromIdent,METH_VARARGS,"Ident a cdrom"}, + {"Add",PkgCdromAdd,METH_VARARGS,"Add(progress) -> Add a cdrom"}, + {"Ident",PkgCdromIdent,METH_VARARGS,"Ident(progress) -> Ident a cdrom"}, {} }; +static PyObject *PkgCdromNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + pkgCdrom *cdrom = new pkgCdrom(); + + static char *kwlist[] = {}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"",kwlist) == 0) + return 0; + + CppOwnedPyObject *CdromObj = + CppOwnedPyObject_NEW(0,type, *cdrom); + + return CdromObj; +} + + PyTypeObject PkgCdromType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "Cdrom", // tp_name + "apt_pkg.Cdrom", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -98,16 +113,21 @@ PyTypeObject PkgCdromType = 0, // tp_iter 0, // tp_iternext PkgCdromMethods, // tp_methods + 0, // tp_members + 0, // 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 + PkgCdromNew, // tp_new }; PyObject *GetCdrom(PyObject *Self,PyObject *Args) { - pkgCdrom *cdrom = new pkgCdrom(); - - CppOwnedPyObject *CdromObj = - CppOwnedPyObject_NEW(0,&PkgCdromType, *cdrom); - - return CdromObj; + return PkgCdromNew(&PkgCdromType,Args,0); } diff --git a/python/configuration.cc b/python/configuration.cc index eaac48ec..abbed6d9 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -475,6 +475,13 @@ static PyMethodDef CnfMethods[] = {} }; +static PyObject *CnfNew(PyTypeObject *type, PyObject *args, PyObject *kwds) { + static char *kwlist[] = {}; + if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) + return 0; + return CppPyObject_NEW(type); +} + // Type for a Normal Configuration object static PySequenceMethods ConfigurationSeq = {0,0,0,0,0,0,0,CnfContains,0,0}; static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; @@ -484,7 +491,7 @@ PyTypeObject ConfigurationType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "Configuration", // tp_name + "apt_pkg.Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -512,6 +519,16 @@ PyTypeObject ConfigurationType = 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods + 0, // tp_members + 0, // 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 + CnfNew, // tp_new }; PyTypeObject ConfigurationPtrType = @@ -520,7 +537,7 @@ PyTypeObject ConfigurationPtrType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "ConfigurationPtr", // tp_name + "apt_pkg.ConfigurationPtr", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -556,7 +573,7 @@ PyTypeObject ConfigurationSubType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "ConfigurationSub", // tp_name + "apt_pkg.ConfigurationSub", // tp_name sizeof(SubConfiguration), // tp_basicsize 0, // tp_itemsize // Methods diff --git a/python/depcache.cc b/python/depcache.cc index 1c9eeff7..0cadee64 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -591,13 +591,39 @@ static PyGetSetDef PkgDepCacheGetSet[] = { {} }; +static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + PyObject *Owner; + static char *kwlist[] = {"cache", 0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgCacheType, + &Owner) == 0) + return 0; + + + // the owner of the Python cache object is a cachefile object, get it + PyObject *CacheFilePy = GetOwner(Owner); + // get the pkgCacheFile from the cachefile + pkgCacheFile *CacheF = GetCpp(CacheFilePy); + // and now the depcache + pkgDepCache *depcache = (pkgDepCache *)(*CacheF); + + CppOwnedPyObject *DepCachePyObj; + DepCachePyObj = CppOwnedPyObject_NEW(Owner,type,depcache); + HandleErrors(DepCachePyObj); + + return DepCachePyObj; +} + +static const char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" + "A DepCache() holds extra information on the state of the packages.\n\n" + "The parameter *cache* refers to an apt_pkg.Cache() object."; PyTypeObject PkgDepCacheType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgDepCache", // tp_name + "apt_pkg.DepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -617,7 +643,7 @@ PyTypeObject PkgDepCacheType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "pkgDepCache Object", // tp_doc + doc_PkgDepCache, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -627,30 +653,20 @@ PyTypeObject PkgDepCacheType = PkgDepCacheMethods, // tp_methods 0, // tp_members PkgDepCacheGetSet, // 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 + PkgDepCacheNew, // tp_new }; PyObject *GetDepCache(PyObject *Self,PyObject *Args) { - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) - return 0; - - - // the owner of the Python cache object is a cachefile object, get it - PyObject *CacheFilePy = GetOwner(Owner); - // get the pkgCacheFile from the cachefile - pkgCacheFile *CacheF = GetCpp(CacheFilePy); - // and now the depcache - pkgDepCache *depcache = (pkgDepCache *)(*CacheF); - - CppOwnedPyObject *DepCachePyObj; - DepCachePyObj = CppOwnedPyObject_NEW(Owner, - &PkgDepCacheType, - depcache); - HandleErrors(DepCachePyObj); - - return DepCachePyObj; + return PkgDepCacheNew(&PkgDepCacheType,Args,0); } @@ -661,26 +677,28 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args) // pkgProblemResolver Class /*{{{*/ // --------------------------------------------------------------------- - - -PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) +static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgDepCacheType,&Owner) == 0) + static char *kwlist[] = {"depcache",0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType, + &Owner) == 0) return 0; pkgDepCache *depcache = GetCpp(Owner); pkgProblemResolver *fixer = new pkgProblemResolver(depcache); CppOwnedPyObject *PkgProblemResolverPyObj; PkgProblemResolverPyObj = CppOwnedPyObject_NEW(Owner, - &PkgProblemResolverType, + type, fixer); HandleErrors(PkgProblemResolverPyObj); return PkgProblemResolverPyObj; - } +PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { + return PkgProblemResolverNew(&PkgProblemResolverType,Args,0); +} static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) { @@ -778,7 +796,7 @@ PyTypeObject PkgProblemResolverType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgProblemResolver", // tp_name + "apt_pkg.ProblemResolver", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -806,6 +824,16 @@ PyTypeObject PkgProblemResolverType = 0, // tp_iter 0, // tp_iternext PkgProblemResolverMethods, // tp_methods + 0, // tp_members + 0, // 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 + PkgProblemResolverNew, // tp_new }; /*}}}*/ @@ -830,13 +858,40 @@ static PyMethodDef PkgActionGroupMethods[] = {} }; +static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + PyObject *Owner; + static char *kwlist[] = {"depcache", 0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType, + &Owner) == 0) + return 0; + + pkgDepCache *depcache = GetCpp(Owner); + pkgDepCache::ActionGroup *group = new pkgDepCache::ActionGroup(*depcache); + CppOwnedPyObject *PkgActionGroupPyObj; + PkgActionGroupPyObj = CppOwnedPyObject_NEW(Owner, + type, + group); + HandleErrors(PkgActionGroupPyObj); + + return PkgActionGroupPyObj; + +} + +static const char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" + "Create a new ActionGroup() object. ActionGroups disable certain cleanup\n" + "actions, so modifying many packages is much faster.\n\n" + "Creating an ActionGroup() makes it active, use release() to disable it\n" + "again.\n\n" + "The parameter *depcache* refers to an apt_pkg.DepCache() object."; + PyTypeObject PkgActionGroupType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgActionGroup", // tp_name + "apt_pkg.ActionGroup", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -856,7 +911,7 @@ PyTypeObject PkgActionGroupType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "ActionGroup Object", // tp_doc + doc_PkgActionGroup, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -864,24 +919,21 @@ PyTypeObject PkgActionGroupType = 0, // tp_iter 0, // tp_iternext PkgActionGroupMethods, // tp_methods + 0, // tp_members + 0, // 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 + PkgActionGroupNew, // tp_new }; PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) { - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgDepCacheType,&Owner) == 0) - return 0; - - pkgDepCache *depcache = GetCpp(Owner); - pkgDepCache::ActionGroup *group = new pkgDepCache::ActionGroup(*depcache); - CppOwnedPyObject *PkgActionGroupPyObj; - PkgActionGroupPyObj = CppOwnedPyObject_NEW(Owner, - &PkgActionGroupType, - group); - HandleErrors(PkgActionGroupPyObj); - - return PkgActionGroupPyObj; - + return PkgActionGroupNew(&PkgActionGroupType,Args,0); } diff --git a/python/indexfile.cc b/python/indexfile.cc index bb40cdd0..600dc853 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -84,7 +84,7 @@ PyTypeObject PackageIndexFileType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgIndexFile", // tp_name + "apt_pkg.PackageIndexFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods diff --git a/python/metaindex.cc b/python/metaindex.cc index cbaeafbd..557aacd8 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -62,7 +62,7 @@ PyTypeObject MetaIndexType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "metaIndex", // tp_name + "apt_pkg.MetaIndex", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods 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 #include #include +#include +#include + #include +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(Owner)); + + CppPyObject *PkgManagerObj = + CppPyObject_NEW(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), // 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 -#include - -PyObject *GetPkgManager(PyObject *Self,PyObject *Args) -{ - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgDepCacheType,&Owner) == 0) - return 0; - - pkgPackageManager *pm = _system->CreatePM(GetCpp(Owner)); - - CppPyObject *PkgManagerObj = - CppPyObject_NEW(&PkgManagerType,pm); - - return PkgManagerObj; -} - - /*}}}*/ diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 978de6b7..1cccfce2 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -132,13 +132,25 @@ static PyGetSetDef PkgRecordsGetSet[] = { {} }; +static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + PyObject *Owner; + char *kwlist[] = {"cache",0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgCacheType, + &Owner) == 0) + return 0; + + return HandleErrors(CppOwnedPyObject_NEW(Owner,type, + GetCpp(Owner))); +} + PyTypeObject PkgRecordsType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgRecords", // tp_name + "apt_pkg.PackageRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -168,17 +180,22 @@ PyTypeObject PkgRecordsType = PkgRecordsMethods, // tp_methods 0, // tp_members PkgRecordsGetSet, // 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 + PkgRecordsNew, // tp_new }; /*}}}*/ + + PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) { - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) - return 0; - - return HandleErrors(CppOwnedPyObject_NEW(Owner,&PkgRecordsType, - GetCpp(Owner))); + return PkgRecordsNew(&PkgRecordsType,Args,0); } diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 97667d7a..8b4dce3e 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -180,13 +180,21 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { {} }; +static PyObject *PkgSrcRecordsNew(PyTypeObject *type,PyObject *args,PyObject *kwds) { + char *kwlist[] = {0}; + if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) + return 0; + + return HandleErrors(CppPyObject_NEW(type)); +} + PyTypeObject PkgSrcRecordsType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgSrcRecords", // tp_name + "apt_pkg.SourceRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -216,6 +224,14 @@ PyTypeObject PkgSrcRecordsType = PkgSrcRecordsMethods, // tp_methods 0, // tp_members PkgSrcRecordsGetSet, // 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 + PkgSrcRecordsNew, // tp_new }; /*}}}*/ diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 48b3b7c8..15311e94 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -97,13 +97,21 @@ static PyGetSetDef PkgSourceListGetSet[] = { {} }; +static PyObject *PkgSourceListNew(PyTypeObject *type,PyObject *args,PyObject *kwds) +{ + char *kwlist[] = {0}; + if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) + return 0; + return CppPyObject_NEW(type,new pkgSourceList()); +} + PyTypeObject PkgSourceListType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgSourceList", // tp_name + "apt_pkg.SourceList", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -133,6 +141,14 @@ PyTypeObject PkgSourceListType = PkgSourceListMethods, // tp_methods 0, // tp_members PkgSourceListGetSet, // 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 + PkgSourceListNew, // tp_new }; PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) diff --git a/python/tag.cc b/python/tag.cc index 18d08580..007a6122 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -239,15 +239,14 @@ static PyObject *TagFileJump(PyObject *Self,PyObject *Args) /*}}}*/ // ParseSection - Parse a single section from a tag file /*{{{*/ // --------------------------------------------------------------------- -char *doc_ParseSection ="ParseSection(Text) -> SectionObject"; -PyObject *ParseSection(PyObject *self,PyObject *Args) -{ +static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { char *Data; - if (PyArg_ParseTuple(Args,"s",&Data) == 0) + static char *kwlist[] = {"text", 0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"s",kwlist,&Data) == 0) return 0; // Create the object.. - TagSecData *New = PyObject_NEW(TagSecData,&TagSecType); + TagSecData *New = PyObject_NEW(TagSecData,type); new (&New->Object) pkgTagSection(); New->Data = new char[strlen(Data)+2]; snprintf(New->Data,strlen(Data)+2,"%s\n",Data); @@ -264,21 +263,28 @@ PyObject *ParseSection(PyObject *self,PyObject *Args) return New; } + +char *doc_ParseSection ="ParseSection(Text) -> TagSection() object. Deprecated."; +PyObject *ParseSection(PyObject *self,PyObject *Args) +{ + return TagSecNew(&TagSecType,Args,0); +} /*}}}*/ // ParseTagFile - Parse a tagd file /*{{{*/ // --------------------------------------------------------------------- /* This constructs the parser state. */ -char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile"; -PyObject *ParseTagFile(PyObject *self,PyObject *Args) + +static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *File; - if (PyArg_ParseTuple(Args,"O",&File) == 0) + static char *kwlist[] = {"file", 0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O",kwlist,&File) == 0) return 0; int fileno = PyObject_AsFileDescriptor(File); if (fileno == -1) return 0; - TagFileData *New = PyObject_NEW(TagFileData,&TagFileType); + TagFileData *New = PyObject_NEW(TagFileData,type); new (&New->Fd) FileFd(fileno,false); New->File = File; Py_INCREF(New->File); @@ -290,6 +296,10 @@ PyObject *ParseTagFile(PyObject *self,PyObject *Args) New->Section->Data = 0; return HandleErrors(New); +} +char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile() object. Deprecated."; +PyObject *ParseTagFile(PyObject *self,PyObject *Args) { + return TagFileNew(&TagFileType,Args,0); } /*}}}*/ // RewriteSection - Rewrite a section.. /*{{{*/ @@ -381,13 +391,20 @@ static PyMethodDef TagSecMethods[] = PySequenceMethods TagSecSeqMeth = {0,0,0,0,0,0,0,TagSecContains,0,0}; PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; + + +static const char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n" + "TagSection() objects provide methods to access rfc822-style formatted\n" + "header sections, like those in debian/control or Packages files.\n\n" + "TagSection() behave like read-only dictionaries and also provide access\n" + "to the functions provided by the C++ class (e.g. Find)"; PyTypeObject TagSecType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "TagSection", // tp_name + "apt_pkg.TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize // Methods @@ -407,14 +424,24 @@ PyTypeObject TagSecType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "TagSection Object", // tp_doc + doc_TagSec, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter 0, // tp_iternext - TagSecMethods // tp_methods + TagSecMethods, // tp_methods + 0, // tp_members + 0, // 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 + TagSecNew, // tp_new }; // Method table for the Tag File object @@ -440,6 +467,15 @@ static PyGetSetDef TagFileGetSet[] = { {} }; +static const char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" + "TagFile() objects provide access to debian control files, which consists\n" + "of multiple RFC822-like formatted sections.\n\n" + "A file may consists of multiple sections, and you can use Step() to move\n" + "forward. The current TagSection() is available via the attribute section" + ".\n\n" + "The parameter *file* refers to an object providing a fileno() method or\n" + "a file descriptor (an integer)"; + // Type for a Tag File PyTypeObject TagFileType = { @@ -447,7 +483,7 @@ PyTypeObject TagFileType = #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "TagFile", // tp_name + "apt_pkg.TagFile", // tp_name sizeof(TagFileData), // tp_basicsize 0, // tp_itemsize // Methods @@ -467,7 +503,7 @@ PyTypeObject TagFileType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "TagFile Object", // tp_doc + doc_TagFile, // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -476,5 +512,14 @@ PyTypeObject TagFileType = 0, // tp_iternext TagFileMethods, // tp_methods 0, // tp_members - TagFileGetSet // tp_getset + TagFileGetSet, // 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 + TagFileNew, // tp_new + }; -- cgit v1.2.3 From a7026989dd1ea3b70cbfc80cf92077efb2f52ba3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 19 Apr 2009 15:57:07 +0200 Subject: ActionGroups can be used as a context manager for the 'with' statement. --- debian/changelog | 1 + python/depcache.cc | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'python/depcache.cc') diff --git a/debian/changelog b/debian/changelog index e8e14306..30d54a29 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.7.91) UNRELEASED; urgency=low * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) * Where possible, derive apt.package.Record from collections.Mapping. + * ActionGroups can be used as a context manager for the 'with' statement. -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 diff --git a/python/depcache.cc b/python/depcache.cc index 0cadee64..70d5af4e 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -852,9 +852,24 @@ static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static PyObject *PkgActionGroupEnter(PyObject *Self,PyObject *Args) { + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + return Self; +} +static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) { + pkgDepCache::ActionGroup *ag = GetCpp(Self); + ag->release(); + Py_RETURN_FALSE; +} + static PyMethodDef PkgActionGroupMethods[] = { {"release", PkgActionGroupRelease, METH_VARARGS, "release()"}, + {"__exit__", PkgActionGroupExit, METH_VARARGS, "__exit__(...) -> " + "Release the action group, for 'with' statement."}, + {"__enter__", PkgActionGroupEnter, METH_VARARGS, "__enter__() -> " + "Enter, for the 'with' statement. Does nothing."}, {} }; @@ -879,11 +894,18 @@ static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *k } static const char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" - "Create a new ActionGroup() object. ActionGroups disable certain cleanup\n" - "actions, so modifying many packages is much faster.\n\n" - "Creating an ActionGroup() makes it active, use release() to disable it\n" - "again.\n\n" - "The parameter *depcache* refers to an apt_pkg.DepCache() object."; + "Create a new ActionGroup() object. The parameter *depcache* refers to an\n" + "apt_pkg.DepCache() object.\n\n" + "ActionGroups disable certain cleanup actions, so modifying many packages\n" + "is much faster.\n\n" + "ActionGroup() can also be used with the 'with' statement, but be aware\n" + "that the ActionGroup() is active as soon as it is created, and not just\n" + "when entering the context. This means you can write::\n\n" + " with apt_pkg.ActionGroup(depcache):\n" + " depcache.markInstall(pkg)\n\n" + "Once the block of the with statement is left, the action group is \n" + "automatically released from the cache."; + PyTypeObject PkgActionGroupType = { -- cgit v1.2.3 From 55eaca76738417f719c1e3b66da94c7307308d74 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 24 Apr 2009 19:01:38 +0200 Subject: * python/*.cc: Fix build failures with python2.4-dbg. --- python/acquire.cc | 4 ++-- python/apt_pkgmodule.cc | 4 ++-- python/cache.cc | 2 +- python/depcache.cc | 4 ++-- python/tag.cc | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 1cdf0cb9..ccd3a479 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -217,7 +217,7 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return FetcherObj; } -static const char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n" +static char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n" "Create a new acquire object. The parameter *progress* can be used to\n" "specify a apt.progress.FetchProgress() object, which will display the\n" "progress of the fetching."; @@ -305,7 +305,7 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject } -static const char *doc_PkgAcquireFile = +static char *doc_PkgAcquireFile = "AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir," "dest_file]) -> New AcquireFile() object\n\n" "The parameter *owner* refers to an apt_pkg.Acquire() object. You can use\n" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index a54b3922..bdea5fae 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -584,8 +584,8 @@ extern "C" void initapt_pkg() CharCharToList(TFRewriteSourceOrder)); // Version.. - PyModule_AddStringConstant(Module,"Version",pkgVersion); - PyModule_AddStringConstant(Module,"LibVersion",pkgLibVersion); + PyModule_AddStringConstant(Module,"Version",(char *)pkgVersion); + PyModule_AddStringConstant(Module,"LibVersion",(char *)pkgLibVersion); PyModule_AddStringConstant(Module,"Date",__DATE__); PyModule_AddStringConstant(Module,"Time",__TIME__); diff --git a/python/cache.cc b/python/cache.cc index 0862cd77..f545a605 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -283,7 +283,7 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return CacheObj; } -static const char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" +static char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" "The cache provides access to the packages and other stuff.\n\n" "The optional parameter *progress* can be used to specify an \n" "apt.progress.OpProgress() object (or similar) which displays\n" diff --git a/python/depcache.cc b/python/depcache.cc index 70d5af4e..ef2240ce 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -614,7 +614,7 @@ static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds return DepCachePyObj; } -static const char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" +static char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" "A DepCache() holds extra information on the state of the packages.\n\n" "The parameter *cache* refers to an apt_pkg.Cache() object."; PyTypeObject PkgDepCacheType = @@ -893,7 +893,7 @@ static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *k } -static const char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" +static char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" "Create a new ActionGroup() object. The parameter *depcache* refers to an\n" "apt_pkg.DepCache() object.\n\n" "ActionGroups disable certain cleanup actions, so modifying many packages\n" diff --git a/python/tag.cc b/python/tag.cc index 007a6122..bc23e98b 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -393,7 +393,7 @@ PySequenceMethods TagSecSeqMeth = {0,0,0,0,0,0,0,TagSecContains,0,0}; PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; -static const char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n" +static char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n" "TagSection() objects provide methods to access rfc822-style formatted\n" "header sections, like those in debian/control or Packages files.\n\n" "TagSection() behave like read-only dictionaries and also provide access\n" @@ -467,7 +467,7 @@ static PyGetSetDef TagFileGetSet[] = { {} }; -static const char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" +static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" "TagFile() objects provide access to debian control files, which consists\n" "of multiple RFC822-like formatted sections.\n\n" "A file may consists of multiple sections, and you can use Step() to move\n" -- cgit v1.2.3 From 7051066cf258caa2a3fd45271faa3d46b8a6d98a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Jun 2009 17:27:33 +0200 Subject: python/: Convert most names to PEP8 naming conventions (except Version,PackageFile,MetaIndex). On our way to close Bug#481061, this converts almost all names to PEP 8 naming conventions. Missing are now apt_pkg.Version, apt_pkg.PackageFile, apt_pkg.MetaIndex and apt.progress.*. In case of the missing apt_pkg classes, they are not converted yet because they do not use getset descriptors yet. apt.progress.* has not been converted yet because the extension interacts with it, and we first need to modify the extension to recognize the new names, as well as the old names (old applications shouldn't break). --- python/acquire.cc | 29 +++++++++++++++ python/apt_instmodule.cc | 21 +++++++---- python/apt_pkgmodule.cc | 94 ++++++++++++++++++++++++++++++++++++++++++++++-- python/cache.cc | 49 ++++++++++++++++++++++++- python/cdrom.cc | 4 +++ python/configuration.cc | 21 +++++++++-- python/depcache.cc | 57 ++++++++++++++++++++++++----- python/indexfile.cc | 11 ++++++ python/pkgmanager.cc | 10 ++++++ python/pkgrecords.cc | 17 +++++++++ python/pkgsrcrecords.cc | 15 ++++++++ python/sourcelist.cc | 8 +++++ python/tag.cc | 15 ++++++++ 13 files changed, 329 insertions(+), 22 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index ccd3a479..6cb2130c 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -38,6 +38,21 @@ MkGet(AcquireItemGetStatAuthError,Py_BuildValue("i", pkgAcquire::Item::StatAuthE #undef MkGet static PyGetSetDef AcquireItemGetSet[] = { + {"complete",AcquireItemGetComplete}, + {"descuri",AcquireItemGetDescURI}, + {"destfile",AcquireItemGetDestFile}, + {"errortext",AcquireItemGetErrorText}, + {"filesize",AcquireItemGetFileSize}, + {"is",AcquireItemGetID}, + {"is_trusted",AcquireItemGetIsTrusted}, + {"local",AcquireItemGetLocal}, + {"status",AcquireItemGetStatus}, + {"stat_idle",AcquireItemGetStatIdle}, + {"stat_fetching",AcquireItemGetStatFetching}, + {"stat_done",AcquireItemGetStatDone}, + {"stat_error",AcquireItemGetStatError}, + {"stat_auth_error",AcquireItemGetStatAuthError}, +#ifdef COMPAT_0_7 {"Complete",AcquireItemGetComplete}, {"DescURI",AcquireItemGetDescURI}, {"DestFile",AcquireItemGetDestFile}, @@ -52,6 +67,7 @@ static PyGetSetDef AcquireItemGetSet[] = { {"StatDone",AcquireItemGetStatDone}, {"StatError",AcquireItemGetStatError}, {"StatAuthError",AcquireItemGetStatAuthError}, +#endif {} }; @@ -140,8 +156,12 @@ static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args) static PyMethodDef PkgAcquireMethods[] = { + {"run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, + {"shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, + #ifdef COMPAT_0_7 {"Run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, {"Shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, + #endif {} }; @@ -184,6 +204,14 @@ static PyObject *PkgAcquireGetResultCancelled(PyObject *Self,void*) { } static PyGetSetDef PkgAcquireGetSet[] = { + {"fetch_needed",PkgAcquireGetFetchNeeded}, + {"items",PkgAcquireGetItems}, + {"partial_present",PkgAcquireGetPartialPresent}, + {"result_cancelled",PkgAcquireGetResultCancelled}, + {"result_continue",PkgAcquireGetResultContinue}, + {"result_failed",PkgAcquireGetResultFailed}, + {"total_needed",PkgAcquireGetTotalNeeded}, + #ifdef COMPAT_0_7 {"FetchNeeded",PkgAcquireGetFetchNeeded}, {"Items",PkgAcquireGetItems}, {"PartialPresent",PkgAcquireGetPartialPresent}, @@ -191,6 +219,7 @@ static PyGetSetDef PkgAcquireGetSet[] = { {"ResultContinue",PkgAcquireGetResultContinue}, {"ResultFailed",PkgAcquireGetResultFailed}, {"TotalNeeded",PkgAcquireGetTotalNeeded}, + #endif {} }; diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 09e3937e..84479fcb 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -29,7 +29,7 @@ expose the full range of the apt-inst .deb processing will join it some day. */ static char *doc_debExtractControl = -"debExtractControl(File[,Member]) -> String\n" +"deb_extract_control(file[,member]) -> String\n" "Returns the indicated file from the control tar. The default is 'control'\n"; static PyObject *debExtractControl(PyObject *Self,PyObject *Args) { @@ -72,7 +72,7 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args) // debExtractArchive - Exctract the archive /*{{{*/ // --------------------------------------------------------------------- static char *doc_debExtractArchive = -"debExtractArchve(File,rootdir) -> Bool\n" +"deb_extract_archive(File,rootdir) -> Bool\n" "Extracts the Archive into the given root dir"; static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { @@ -118,7 +118,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) // arFindMember - Find member in AR archive /*{{{*/ // --------------------------------------------------------------------- static char *doc_arCheckMember = -"arCheckMember(File, membername) -> Bool\n"; +"ar_check_member(file, membername) -> Bool\n"; static PyObject *arCheckMember(PyObject *Self,PyObject *Args) { char *Member = NULL; @@ -149,16 +149,23 @@ static PyObject *arCheckMember(PyObject *Self,PyObject *Args) static PyMethodDef methods[] = { // access to ar files - {"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember}, + {"ar_check_member", arCheckMember, METH_VARARGS, doc_arCheckMember}, // access to deb files - {"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl}, - {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive}, + {"deb_extract_control",debExtractControl,METH_VARARGS,doc_debExtractControl}, + {"deb_extract_archive",debExtractArchive,METH_VARARGS,doc_debExtractArchive}, // access to tar streams + {"tar_extract",tarExtract,METH_VARARGS,doc_tarExtract}, + {"deb_extract",debExtract,METH_VARARGS,doc_debExtract}, + +#ifdef COMPAT_0_7 + {"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember}, + {"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl}, + {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive}, {"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract}, {"debExtract",debExtract,METH_VARARGS,doc_debExtract}, - +#endif {} }; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index bdea5fae..ddd6d38b 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -389,35 +389,60 @@ static PyMethodDef methods[] = {"newConfiguration",newConfiguration,METH_VARARGS,doc_newConfiguration}, #endif {"init",Init,METH_VARARGS,doc_Init}, + {"init_config",InitConfig,METH_VARARGS,doc_InitConfig}, + {"init_system",InitSystem,METH_VARARGS,doc_InitSystem}, + #ifdef COMPAT_0_7 {"InitConfig",InitConfig,METH_VARARGS,doc_InitConfig}, {"InitSystem",InitSystem,METH_VARARGS,doc_InitSystem}, + #endif // Tag File #ifdef COMPAT_0_7 {"ParseSection",ParseSection,METH_VARARGS,doc_ParseSection}, {"ParseTagFile",ParseTagFile,METH_VARARGS,doc_ParseTagFile}, - #endif {"RewriteSection",RewriteSection,METH_VARARGS,doc_RewriteSection}, + #endif + {"rewrite_section",RewriteSection,METH_VARARGS,doc_RewriteSection}, // Locking + {"get_lock",GetLock,METH_VARARGS,doc_GetLock}, + {"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, + {"pkgsystem_unlock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, + #ifdef COMPAT_0_7 {"GetLock",GetLock,METH_VARARGS,doc_GetLock}, {"PkgSystemLock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, {"PkgSystemUnLock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, + #endif // Command line + {"read_configfile",LoadConfig,METH_VARARGS,doc_LoadConfig}, + {"read_configdir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, + {"read_configfile_isc",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, + {"parse_commandline",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, + #ifdef COMPAT_0_7 {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, + #endif // Versioning + {"version_compare",VersionCompare,METH_VARARGS,doc_VersionCompare}, + {"check_dep",CheckDep,METH_VARARGS,doc_CheckDep}, + {"upstream_version",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion}, + #ifdef COMPAT_0_7 {"VersionCompare",VersionCompare,METH_VARARGS,doc_VersionCompare}, {"CheckDep",CheckDep,METH_VARARGS,doc_CheckDep}, {"UpstreamVersion",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion}, + #endif // Depends + {"parse_depends",ParseDepends,METH_VARARGS,doc_ParseDepends}, + {"parse_srcdepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, + #ifdef COMPAT_0_7 {"ParseDepends",ParseDepends,METH_VARARGS,doc_ParseDepends}, {"ParseSrcDepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, + #endif // Stuff {"md5sum",md5sum,METH_VARARGS,doc_md5sum}, @@ -425,6 +450,17 @@ static PyMethodDef methods[] = {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, // Strings + {"check_domainlist",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, + {"quote_string",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"}, + {"dequote_string",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, + {"size_to_str",StrSizeToStr,METH_VARARGS,"SizeToStr(int) -> String"}, + {"time_to_str",StrTimeToStr,METH_VARARGS,"TimeToStr(int) -> String"}, + {"uri_to_filename",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, + {"base64_encode",StrBase64Encode,METH_VARARGS,"Base64Encode(String) -> String"}, + {"string_to_bool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"}, + {"time_rfc1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"}, + {"str_to_time",StrStrToTime,METH_VARARGS,"StrToTime(String) -> Int"}, + #ifdef COMPAT_0_7 {"CheckDomainList",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, {"QuoteString",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"}, {"DeQuoteString",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, @@ -435,6 +471,7 @@ static PyMethodDef methods[] = {"StringToBool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"}, {"TimeRFC1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"}, {"StrToTime",StrStrToTime,METH_VARARGS,"StrToTime(String) -> Int"}, + #endif // Cache #ifdef COMPAT_0_7 @@ -535,7 +572,10 @@ extern "C" void initapt_pkg() // Global variable linked to the global configuration class CppPyObject *Config = CppPyObject_NEW(&ConfigurationPtrType); Config->Object = _config; + PyModule_AddObject(Module,"config",Config); + #ifdef COMPAT_0_7 PyModule_AddObject(Module,"Config",Config); + #endif // Add our classes. /* ============================ tag.cc ============================ */ @@ -577,20 +617,40 @@ extern "C" void initapt_pkg() /* ========================= sourcelist.cc ========================= */ ADDTYPE(Module,"SourceList",&PkgSourceListType); // Tag file constants + PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", + CharCharToList(TFRewritePackageOrder)); + + PyModule_AddObject(Module,"REWRITE_SOURCE_ORDER", + CharCharToList(TFRewriteSourceOrder)); +#ifdef COMPAT_0_7 PyModule_AddObject(Module,"RewritePackageOrder", CharCharToList(TFRewritePackageOrder)); PyModule_AddObject(Module,"RewriteSourceOrder", CharCharToList(TFRewriteSourceOrder)); +#endif // Version.. + PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion); + PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion); + PyModule_AddStringConstant(Module,"DATE",__DATE__); + PyModule_AddStringConstant(Module,"TIME",__TIME__); +#ifdef COMPAT_0_7 PyModule_AddStringConstant(Module,"Version",(char *)pkgVersion); PyModule_AddStringConstant(Module,"LibVersion",(char *)pkgLibVersion); PyModule_AddStringConstant(Module,"Date",__DATE__); PyModule_AddStringConstant(Module,"Time",__TIME__); +#endif // My constants - + PyModule_AddIntConstant(Module,"DEP_DEPENDS",pkgCache::Dep::Depends); + PyModule_AddIntConstant(Module,"DEP_PREDEPENDS",pkgCache::Dep::PreDepends); + PyModule_AddIntConstant(Module,"DEP_SUGGESTS",pkgCache::Dep::Suggests); + PyModule_AddIntConstant(Module,"DEP_RECOMMENDS",pkgCache::Dep::Recommends); + PyModule_AddIntConstant(Module,"DEP_CONFLICTS",pkgCache::Dep::Conflicts); + PyModule_AddIntConstant(Module,"DEP_REPLACES",pkgCache::Dep::Replaces); + PyModule_AddIntConstant(Module,"DEP_OBSOLTES",pkgCache::Dep::Obsoletes); +#ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"DepDepends",pkgCache::Dep::Depends); PyModule_AddIntConstant(Module,"DepPreDepends",pkgCache::Dep::PreDepends); PyModule_AddIntConstant(Module,"DepSuggests",pkgCache::Dep::Suggests); @@ -598,13 +658,40 @@ extern "C" void initapt_pkg() PyModule_AddIntConstant(Module,"DepConflicts",pkgCache::Dep::Conflicts); PyModule_AddIntConstant(Module,"DepReplaces",pkgCache::Dep::Replaces); PyModule_AddIntConstant(Module,"DepObsoletes",pkgCache::Dep::Obsoletes); +#endif + PyModule_AddIntConstant(Module,"PRI_IMPORTANT",pkgCache::State::Important); + PyModule_AddIntConstant(Module,"PRI_REQUIRED",pkgCache::State::Required); + PyModule_AddIntConstant(Module,"PRI_STANDARD",pkgCache::State::Standard); + PyModule_AddIntConstant(Module,"PRI_OPTIONAL",pkgCache::State::Optional); + PyModule_AddIntConstant(Module,"PRI_EXTRA",pkgCache::State::Extra); +#ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"PriImportant",pkgCache::State::Important); PyModule_AddIntConstant(Module,"PriRequired",pkgCache::State::Required); PyModule_AddIntConstant(Module,"PriStandard",pkgCache::State::Standard); PyModule_AddIntConstant(Module,"PriOptional",pkgCache::State::Optional); PyModule_AddIntConstant(Module,"PriExtra",pkgCache::State::Extra); - +#endif + // CurState + PyModule_AddIntConstant(Module,"STATE_NOTINSTALLED",pkgCache::State::NotInstalled); + PyModule_AddIntConstant(Module,"STATE_UNPACKED",pkgCache::State::UnPacked); + PyModule_AddIntConstant(Module,"STATE_HALFCONFIGURED",pkgCache::State::HalfConfigured); + PyModule_AddIntConstant(Module,"STATE_HALFINSTALLED",pkgCache::State::HalfInstalled); + PyModule_AddIntConstant(Module,"STATE_CONFIGFILES",pkgCache::State::ConfigFiles); + PyModule_AddIntConstant(Module,"STATE_INSTALLED",pkgCache::State::Installed); + // SelState + PyModule_AddIntConstant(Module,"STATE_UNKNOWN",pkgCache::State::Unknown); + PyModule_AddIntConstant(Module,"STATE_INSTALL",pkgCache::State::Install); + PyModule_AddIntConstant(Module,"STATE_HOLD",pkgCache::State::Hold); + PyModule_AddIntConstant(Module,"STATE_DEINSTALL",pkgCache::State::DeInstall); + PyModule_AddIntConstant(Module,"STATE_PURGE",pkgCache::State::Purge); + // InstState + PyModule_AddIntConstant(Module,"STATE_OK",pkgCache::State::Ok); + PyModule_AddIntConstant(Module,"STATE_REINSTREQ",pkgCache::State::ReInstReq); + PyModule_AddIntConstant(Module,"STATE_HOLD",pkgCache::State::Hold); + PyModule_AddIntConstant(Module,"STATE_HOLD_REINSTREQ",pkgCache::State::HoldReInstReq); + +#ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"CurStateNotInstalled",pkgCache::State::NotInstalled); PyModule_AddIntConstant(Module,"CurStateUnPacked",pkgCache::State::UnPacked); PyModule_AddIntConstant(Module,"CurStateHalfConfigured",pkgCache::State::HalfConfigured); @@ -622,6 +709,7 @@ extern "C" void initapt_pkg() PyModule_AddIntConstant(Module,"InstStateReInstReq",pkgCache::State::ReInstReq); PyModule_AddIntConstant(Module,"InstStateHold",pkgCache::State::Hold); PyModule_AddIntConstant(Module,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); +#endif #ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"_COMPAT_0_7",1); diff --git a/python/cache.cc b/python/cache.cc index f545a605..644646a1 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -136,9 +136,14 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) static PyMethodDef PkgCacheMethods[] = { + {"update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, + {"open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, + {"close", PkgCacheClose, METH_VARARGS,"Close the cache"}, +#ifdef COMPAT_0_7 {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, {"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, {"Close", PkgCacheClose, METH_VARARGS,"Close the cache"}, +#endif {} }; @@ -190,6 +195,15 @@ static PyObject *PkgCacheGetFileList(PyObject *Self, void*) { } static PyGetSetDef PkgCacheGetSet[] = { + {"depends_count",PkgCacheGetDependsCount}, + {"filelist",PkgCacheGetFileList}, + {"package_count",PkgCacheGetPackageCount}, + {"packagefile_count",PkgCacheGetPackageFileCount}, + {"packages",PkgCacheGetPackages}, + {"provides_count",PkgCacheGetProvidesCount}, + {"verfile_count",PkgCacheGetVerFileCount}, + {"version_count",PkgCacheGetVersionCount}, +#ifdef COMPAT_0_7 {"DependsCount",PkgCacheGetDependsCount}, {"FileList",PkgCacheGetFileList}, {"PackageCount",PkgCacheGetPackageCount}, @@ -198,6 +212,7 @@ static PyGetSetDef PkgCacheGetSet[] = { {"ProvidesCount",PkgCacheGetProvidesCount}, {"VerFileCount",PkgCacheGetVerFileCount}, {"VersionCount",PkgCacheGetVersionCount}, +#endif {} }; @@ -482,6 +497,20 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*) } static PyGetSetDef PackageGetSet[] = { + {"name",PackageGetName}, + {"section",PackageGetSection}, + {"revdependslist",PackageGetRevDependsList}, + {"provideslist",PackageGetProvidesList}, + {"selected_state",PackageGetSelectedState}, + {"inst_state",PackageGetInstState}, + {"current_state",PackageGetCurrentState}, + {"id",PackageGetID}, + {"auto",PackageGetAuto}, + {"essential",PackageGetEssential}, + {"important",PackageGetImportant}, + {"versionlist",PackageGetVersionList}, + {"currentver",PackageGetCurrentVer}, + #ifdef COMPAT_0_7 {"Name",PackageGetName}, {"Section",PackageGetSection}, {"RevDependsList",PackageGetRevDependsList}, @@ -495,6 +524,7 @@ static PyGetSetDef PackageGetSet[] = { {"Important",PackageGetImportant}, {"VersionList",PackageGetVersionList}, {"CurrentVer",PackageGetCurrentVer}, + #endif {} }; @@ -579,9 +609,13 @@ static PyObject *DescriptionGetFileList(PyObject *Self,void*) } static PyGetSetDef DescriptionGetSet[] = { - {"LanguageCode",DescriptionGetLanguageCode}, + {"languagecode",DescriptionGetLanguageCode}, {"md5",DescriptionGetMd5}, + {"filelist",DescriptionGetFileList}, + #ifdef COMPAT_0_7 + {"LanguageCode",DescriptionGetLanguageCode}, {"FileList",DescriptionGetFileList}, + #endif {} }; @@ -955,8 +989,12 @@ static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) static PyMethodDef DependencyMethods[] = { + {"smart_target_pkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"}, + {"all_targets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"}, +#ifdef COMPAT_0_7 {"SmartTargetPkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"}, {"AllTargets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"}, +#endif {} }; @@ -1014,6 +1052,14 @@ static PyObject *DependencyGetID(PyObject *Self,void*) } static PyGetSetDef DependencyGetSet[] = { + {"comptype",DependencyGetCompType}, + {"deptype",DependencyGetDepType}, + {"id",DependencyGetID}, + {"parentpkg",DependencyGetParentPkg}, + {"parentver",DependencyGetParentVer}, + {"targetpkg",DependencyGetTargetPkg}, + {"targetver",DependencyGetTargetVer}, +#ifdef COMPAT_0_7 {"CompType",DependencyGetCompType}, {"DepType",DependencyGetDepType}, {"ID",DependencyGetID}, @@ -1021,6 +1067,7 @@ static PyGetSetDef DependencyGetSet[] = { {"ParentVer",DependencyGetParentVer}, {"TargetPkg",DependencyGetTargetPkg}, {"TargetVer",DependencyGetTargetVer}, +#endif {} }; diff --git a/python/cdrom.cc b/python/cdrom.cc index bf94a390..044bbf30 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -58,8 +58,12 @@ static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args) static PyMethodDef PkgCdromMethods[] = { + {"add",PkgCdromAdd,METH_VARARGS,"add(progress) -> Add a cdrom"}, + {"ident",PkgCdromIdent,METH_VARARGS,"ident(progress) -> Ident a cdrom"}, +#ifdef COMPAT_0_7 {"Add",PkgCdromAdd,METH_VARARGS,"Add(progress) -> Add a cdrom"}, {"Ident",PkgCdromIdent,METH_VARARGS,"Ident(progress) -> Ident a cdrom"}, +#endif {} }; diff --git a/python/configuration.cc b/python/configuration.cc index abbed6d9..107cf90f 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -453,13 +453,26 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args) static PyMethodDef CnfMethods[] = { // Query + {"find",CnfFind,METH_VARARGS,doc_Find}, + {"find_file",CnfFindFile,METH_VARARGS,doc_FindFile}, + {"find_dir",CnfFindDir,METH_VARARGS,doc_FindDir}, + {"find_i",CnfFindI,METH_VARARGS,doc_FindI}, + {"find_b",CnfFindB,METH_VARARGS,doc_FindB}, + + // Others + {"set",CnfSet,METH_VARARGS,doc_Set}, + {"exists",CnfExists,METH_VARARGS,doc_Exists}, + {"subtree",CnfSubTree,METH_VARARGS,doc_SubTree}, + {"list",CnfList,METH_VARARGS,doc_List}, + {"valuelist",CnfValueList,METH_VARARGS,doc_ValueList}, + {"mytag",CnfMyTag,METH_VARARGS,doc_MyTag}, + {"clear",CnfClear,METH_VARARGS,doc_Clear}, +#ifdef COMPAT_0_7 {"Find",CnfFind,METH_VARARGS,doc_Find}, {"FindFile",CnfFindFile,METH_VARARGS,doc_FindFile}, {"FindDir",CnfFindDir,METH_VARARGS,doc_FindDir}, {"FindI",CnfFindI,METH_VARARGS,doc_FindI}, {"FindB",CnfFindB,METH_VARARGS,doc_FindB}, - - // Others {"Set",CnfSet,METH_VARARGS,doc_Set}, {"Exists",CnfExists,METH_VARARGS,doc_Exists}, {"SubTree",CnfSubTree,METH_VARARGS,doc_SubTree}, @@ -467,10 +480,12 @@ static PyMethodDef CnfMethods[] = {"ValueList",CnfValueList,METH_VARARGS,doc_ValueList}, {"MyTag",CnfMyTag,METH_VARARGS,doc_MyTag}, {"Clear",CnfClear,METH_VARARGS,doc_Clear}, - +#endif // Python Special {"keys",CnfKeys,METH_VARARGS,doc_Keys}, + #if PY_MAJOR_VERSION < 3 {"has_key",CnfExists,METH_VARARGS,doc_Exists}, + #endif {"get",CnfFind,METH_VARARGS,doc_Find}, {} }; diff --git a/python/depcache.cc b/python/depcache.cc index ef2240ce..f3b16211 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -528,21 +528,47 @@ static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) static PyMethodDef PkgDepCacheMethods[] = { + {"init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, + {"get_candidate",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, + {"set_candidate",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"}, + + // global cache operations + {"upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"}, + {"fix_broken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"}, + {"read_pinfile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, + {"minimize_upgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."}, + // Manipulators + {"mark_keep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, + {"mark_delete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, + {"mark_install",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, + {"set_reinstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, + // state information + {"is_upgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, + {"is_now_broken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, + {"is_inst_broken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"}, + {"is_garbage",PkgDepCacheIsGarbage,METH_VARARGS,"Is pkg garbage (mark-n-sweep)"}, + {"is_auto_installed",PkgDepCacheIsAutoInstalled,METH_VARARGS,"Is pkg marked as auto installed"}, + {"marked_install",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"}, + {"marked_upgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"}, + {"marked_delete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"}, + {"marked_keep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, + {"marked_reinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"}, + {"marked_downgrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"}, + + // Action + {"commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, +#ifdef COMPAT_0_7 {"Init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, {"GetCandidateVer",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, {"SetCandidateVer",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"}, - - // global cache operations {"Upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"}, {"FixBroken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"}, {"ReadPinFile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, {"MinimizeUpgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."}, - // Manipulators {"MarkKeep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, {"MarkDelete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, {"MarkInstall",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, {"SetReInstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, - // state information {"IsUpgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, {"IsNowBroken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, {"IsInstBroken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"}, @@ -554,9 +580,8 @@ static PyMethodDef PkgDepCacheMethods[] = {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, {"MarkedReinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"}, {"MarkedDowngrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"}, - - // Action {"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, +#endif {} }; @@ -582,12 +607,20 @@ static PyObject *PkgDepCacheGetDebSize(PyObject *Self,void*) { #undef depcache static PyGetSetDef PkgDepCacheGetSet[] = { + {"brokencount",PkgDepCacheGetBrokenCount}, + {"debsize",PkgDepCacheGetDebSize}, + {"delcount",PkgDepCacheGetDelCount}, + {"instcount",PkgDepCacheGetInstCount}, + {"keepcount",PkgDepCacheGetKeepCount}, + {"usrsize",PkgDepCacheGetUsrSize}, + #ifdef COMPAT_0_7 {"BrokenCount",PkgDepCacheGetBrokenCount}, {"DebSize",PkgDepCacheGetDebSize}, {"DelCount",PkgDepCacheGetDelCount}, {"InstCount",PkgDepCacheGetInstCount}, {"KeepCount",PkgDepCacheGetKeepCount}, {"UsrSize",PkgDepCacheGetUsrSize}, + #endif {} }; @@ -779,14 +812,22 @@ static PyObject *PkgProblemResolverInstallProtect(PyObject *Self,PyObject *Args) static PyMethodDef PkgProblemResolverMethods[] = { // config + {"protect", PkgProblemResolverProtect, METH_VARARGS, "protect(PkgIterator)"}, + {"remove", PkgProblemResolverRemove, METH_VARARGS, "remove(PkgIterator)"}, + {"clear", PkgProblemResolverClear, METH_VARARGS, "clear(PkgIterator)"}, + {"install_protect", PkgProblemResolverInstallProtect, METH_VARARGS, "install_protect()"}, + + // Actions + {"resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"}, + {"resolve_by_keep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"}, + #ifdef COMPAT_0_7 {"Protect", PkgProblemResolverProtect, METH_VARARGS, "Protect(PkgIterator)"}, {"Remove", PkgProblemResolverRemove, METH_VARARGS, "Remove(PkgIterator)"}, {"Clear", PkgProblemResolverClear, METH_VARARGS, "Clear(PkgIterator)"}, {"InstallProtect", PkgProblemResolverInstallProtect, METH_VARARGS, "ProtectInstalled()"}, - - // Actions {"Resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"}, {"ResolveByKeep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"}, + #endif {} }; diff --git a/python/indexfile.cc b/python/indexfile.cc index 600dc853..795931fb 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -28,7 +28,10 @@ static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) static PyMethodDef PackageIndexFileMethods[] = { + {"archive_uri",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, + #ifdef COMPAT_0_7 {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, + #endif {} }; @@ -69,12 +72,20 @@ static PyObject *PackageIndexFileRepr(PyObject *Self) } static PyGetSetDef PackageIndexFileGetSet[] = { + {"describe",PackageIndexFileGetDescribe}, + {"exists",PackageIndexFileGetExists}, + {"has_packages",PackageIndexFileGetHasPackages}, + {"is_trusted",PackageIndexFileGetIsTrusted}, + {"label",PackageIndexFileGetLabel}, + {"size",PackageIndexFileGetSize}, + #ifdef COMPAT_0_7 {"Describe",PackageIndexFileGetDescribe}, {"Exists",PackageIndexFileGetExists}, {"HasPackages",PackageIndexFileGetHasPackages}, {"IsTrusted",PackageIndexFileGetIsTrusted}, {"Label",PackageIndexFileGetLabel}, {"Size",PackageIndexFileGetSize}, + #endif {} }; diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 781acc8b..cae2b580 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -92,9 +92,14 @@ static PyObject *PkgManagerFixMissing(PyObject *Self,PyObject *Args) static PyMethodDef PkgManagerMethods[] = { + {"get_archives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"}, + {"do_install",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"}, + {"fix_missing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"}, +#ifdef COMPAT_0_7 {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"}, {"DoInstall",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"}, {"FixMissing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"}, +#endif {} }; @@ -110,9 +115,14 @@ static PyObject *PkgManagerGetResultIncomplete(PyObject *Self,void*) { } static PyGetSetDef PkgManagerGetSet[] = { + {"result_completed",PkgManagerGetResultCompleted}, + {"result_failed",PkgManagerGetResultFailed}, + {"result_incomplete",PkgManagerGetResultIncomplete}, +#ifdef COMPAT_0_7 {"ResultCompleted",PkgManagerGetResultCompleted}, {"ResultFailed",PkgManagerGetResultFailed}, {"ResultIncomplete",PkgManagerGetResultIncomplete}, +#endif {} }; diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 1cccfce2..f9e48352 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -49,7 +49,10 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) static PyMethodDef PkgRecordsMethods[] = { + {"lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, + #ifdef COMPAT_0_7 {"Lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, + #endif {} }; @@ -117,6 +120,19 @@ static PyObject *PkgRecordsGetRecord(PyObject *Self,void*) { return PyString_FromStringAndSize(start,stop-start); } static PyGetSetDef PkgRecordsGetSet[] = { + {"filename",PkgRecordsGetFileName}, + {"homepage",PkgRecordsGetHomepage}, + {"longdesc",PkgRecordsGetLongDesc}, + {"md5",PkgRecordsGetMD5Hash}, + {"maintainer",PkgRecordsGetMaintainer}, + {"name",PkgRecordsGetName}, + {"record",PkgRecordsGetRecord}, + {"sha1",PkgRecordsGetSHA1Hash}, + {"sha256",PkgRecordsGetSHA256Hash}, + {"shortdesc",PkgRecordsGetShortDesc}, + {"sourcepkg",PkgRecordsGetSourcePkg}, + {"sourcever",PkgRecordsGetSourceVer}, +#ifdef COMPAT_0_7 {"FileName",PkgRecordsGetFileName}, {"Homepage",PkgRecordsGetHomepage}, {"LongDesc",PkgRecordsGetLongDesc}, @@ -129,6 +145,7 @@ static PyGetSetDef PkgRecordsGetSet[] = { {"ShortDesc",PkgRecordsGetShortDesc}, {"SourcePkg",PkgRecordsGetSourcePkg}, {"SourceVer",PkgRecordsGetSourceVer}, +#endif {} }; diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 8b4dce3e..2a8b7bab 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -70,8 +70,12 @@ static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) static PyMethodDef PkgSrcRecordsMethods[] = { + {"lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, + {"restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, +#ifdef COMPAT_0_7 {"Lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, {"Restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, +#endif {} }; @@ -168,6 +172,16 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { } static PyGetSetDef PkgSrcRecordsGetSet[] = { + {"binaries",PkgSrcRecordsGetBinaries}, + {"builddepends",PkgSrcRecordsGetBuildDepends}, + {"files",PkgSrcRecordsGetFiles}, + {"index",PkgSrcRecordsGetIndex}, + {"maintainer",PkgSrcRecordsGetMaintainer}, + {"package",PkgSrcRecordsGetPackage}, + {"record",PkgSrcRecordsGetRecord}, + {"section",PkgSrcRecordsGetSection}, + {"version",PkgSrcRecordsGetVersion}, +#ifdef COMPAT_0_7 {"Binaries",PkgSrcRecordsGetBinaries}, {"BuildDepends",PkgSrcRecordsGetBuildDepends}, {"Files",PkgSrcRecordsGetFiles}, @@ -177,6 +191,7 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { {"Record",PkgSrcRecordsGetRecord}, {"Section",PkgSrcRecordsGetSection}, {"Version",PkgSrcRecordsGetVersion}, +#endif {} }; diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 15311e94..daf0c08c 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -72,9 +72,14 @@ static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args) static PyMethodDef PkgSourceListMethods[] = { + {"find_index",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, + {"read_main_list",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, + {"get_indexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes}, +#ifdef COMPAT_0_7 {"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, {"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes}, +#endif {} }; @@ -93,7 +98,10 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*) } static PyGetSetDef PkgSourceListGetSet[] = { + {"list",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0}, +#ifdef COMPAT_0_7 {"List",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0}, +#endif {} }; diff --git a/python/tag.cc b/python/tag.cc index bc23e98b..846123ba 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -377,13 +377,20 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) static PyMethodDef TagSecMethods[] = { // Query + {"find",TagSecFind,METH_VARARGS,doc_Find}, + {"findflag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, + {"bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, +#ifdef COMPAT_0_7 {"Find",TagSecFind,METH_VARARGS,doc_Find}, {"FindFlag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, {"Bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, +#endif // Python Special {"keys",TagSecKeys,METH_VARARGS,doc_Keys}, +#if PY_MAJOR_VERSION < 3 {"has_key",TagSecExists,METH_VARARGS,doc_Exists}, +#endif {"get",TagSecFind,METH_VARARGS,doc_Find}, {} }; @@ -448,9 +455,14 @@ PyTypeObject TagSecType = static PyMethodDef TagFileMethods[] = { // Query + {"step",TagFileStep,METH_VARARGS,doc_Step}, + {"offset",TagFileOffset,METH_VARARGS,doc_Offset}, + {"jump",TagFileJump,METH_VARARGS,doc_Jump}, +#ifdef COMPAT_0_7 {"Step",TagFileStep,METH_VARARGS,doc_Step}, {"Offset",TagFileOffset,METH_VARARGS,doc_Offset}, {"Jump",TagFileJump,METH_VARARGS,doc_Jump}, +#endif {} }; @@ -463,7 +475,10 @@ static PyObject *TagFileGetSection(PyObject *Self,void*) { } static PyGetSetDef TagFileGetSet[] = { + {"section",TagFileGetSection,0,"Return a TagSection.",0}, +#ifdef COMPAT_0_7 {"Section",TagFileGetSection,0,"Return a TagSection.",0}, +#endif {} }; -- cgit v1.2.3 From 884c8a4ebdfcedf8143dcb2ce8ef92779c353e06 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 4 Jun 2009 17:18:29 +0200 Subject: python/: Unify naming conventions for all new names. Unify all names to follow these rules: 1. Replace the first [A-Z] with the lowercase version [a-z] 2. Replace multiple [A-Z] with [A-Z][a-z] (one upper, remaining ones lowercase) 3. Replace all remaining [A-Z] with _[a-z] This brings us from 'FileName' to 'file_name' and from 'DescURI' to 'desc_uri'. We will at a later stage add some exceptions to this rule, like 'filename' instead of 'file_name', to improve readability. --- python/acquire.cc | 8 ++++---- python/apt_pkgmodule.cc | 36 ++++++++++++++++++------------------ python/cache.cc | 30 +++++++++++++++--------------- python/configuration.cc | 6 +++--- python/depcache.cc | 20 ++++++++++---------- python/pkgrecords.cc | 16 ++++++++-------- python/pkgsrcrecords.cc | 2 +- python/tag.cc | 2 +- 8 files changed, 60 insertions(+), 60 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 6cb2130c..1b1c5dd8 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -39,10 +39,10 @@ MkGet(AcquireItemGetStatAuthError,Py_BuildValue("i", pkgAcquire::Item::StatAuthE static PyGetSetDef AcquireItemGetSet[] = { {"complete",AcquireItemGetComplete}, - {"descuri",AcquireItemGetDescURI}, - {"destfile",AcquireItemGetDestFile}, - {"errortext",AcquireItemGetErrorText}, - {"filesize",AcquireItemGetFileSize}, + {"desc_uri",AcquireItemGetDescURI}, + {"dest_file",AcquireItemGetDestFile}, + {"error_text",AcquireItemGetErrorText}, + {"file_size",AcquireItemGetFileSize}, {"is",AcquireItemGetID}, {"is_trusted",AcquireItemGetIsTrusted}, {"local",AcquireItemGetLocal}, diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 44234f8d..8259d7c3 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -407,7 +407,7 @@ static PyMethodDef methods[] = // Locking {"get_lock",GetLock,METH_VARARGS,doc_GetLock}, {"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, - {"pkgsystem_unlock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, + {"pkgsystem_un_lock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, #ifdef COMPAT_0_7 {"GetLock",GetLock,METH_VARARGS,doc_GetLock}, {"PkgSystemLock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, @@ -415,10 +415,10 @@ static PyMethodDef methods[] = #endif // Command line - {"read_configfile",LoadConfig,METH_VARARGS,doc_LoadConfig}, - {"read_configdir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, - {"read_configfile_isc",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, - {"parse_commandline",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, + {"read_config_file",LoadConfig,METH_VARARGS,doc_LoadConfig}, + {"read_config_dir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, + {"read_config_file_isc",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, + {"parse_command_line",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, #ifdef COMPAT_0_7 {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, @@ -438,7 +438,7 @@ static PyMethodDef methods[] = // Depends {"parse_depends",ParseDepends,METH_VARARGS,doc_ParseDepends}, - {"parse_srcdepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, + {"parse_src_depends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, #ifdef COMPAT_0_7 {"ParseDepends",ParseDepends,METH_VARARGS,doc_ParseDepends}, {"ParseSrcDepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, @@ -450,12 +450,12 @@ static PyMethodDef methods[] = {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, // Strings - {"check_domainlist",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, + {"check_domain_list",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, {"quote_string",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"}, - {"dequote_string",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, + {"de_quote_string",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, {"size_to_str",StrSizeToStr,METH_VARARGS,"SizeToStr(int) -> String"}, {"time_to_str",StrTimeToStr,METH_VARARGS,"TimeToStr(int) -> String"}, - {"uri_to_filename",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, + {"uri_to_file_name",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, {"base64_encode",StrBase64Encode,METH_VARARGS,"Base64Encode(String) -> String"}, {"string_to_bool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"}, {"time_rfc1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"}, @@ -644,7 +644,7 @@ extern "C" void initapt_pkg() // My constants PyModule_AddIntConstant(Module,"DEP_DEPENDS",pkgCache::Dep::Depends); - PyModule_AddIntConstant(Module,"DEP_PREDEPENDS",pkgCache::Dep::PreDepends); + PyModule_AddIntConstant(Module,"DEP_PRE_DEPENDS",pkgCache::Dep::PreDepends); PyModule_AddIntConstant(Module,"DEP_SUGGESTS",pkgCache::Dep::Suggests); PyModule_AddIntConstant(Module,"DEP_RECOMMENDS",pkgCache::Dep::Recommends); PyModule_AddIntConstant(Module,"DEP_CONFLICTS",pkgCache::Dep::Conflicts); @@ -673,23 +673,23 @@ extern "C" void initapt_pkg() PyModule_AddIntConstant(Module,"PriExtra",pkgCache::State::Extra); #endif // CurState - PyModule_AddIntConstant(Module,"CURSTATE_NOTINSTALLED",pkgCache::State::NotInstalled); - PyModule_AddIntConstant(Module,"CURSTATE_UNPACKED",pkgCache::State::UnPacked); - PyModule_AddIntConstant(Module,"CURSTATE_HALFCONFIGURED",pkgCache::State::HalfConfigured); - PyModule_AddIntConstant(Module,"CURSTATE_HALFINSTALLED",pkgCache::State::HalfInstalled); - PyModule_AddIntConstant(Module,"CURSTATE_CONFIGFILES",pkgCache::State::ConfigFiles); + PyModule_AddIntConstant(Module,"CURSTATE_NOT_INSTALLED",pkgCache::State::NotInstalled); + PyModule_AddIntConstant(Module,"CURSTATE_UN_PACKED",pkgCache::State::UnPacked); + PyModule_AddIntConstant(Module,"CURSTATE_HALF_CONFIGURED",pkgCache::State::HalfConfigured); + PyModule_AddIntConstant(Module,"CURSTATE_HALF_INSTALLED",pkgCache::State::HalfInstalled); + PyModule_AddIntConstant(Module,"CURSTATE_CONFIG_FILES",pkgCache::State::ConfigFiles); PyModule_AddIntConstant(Module,"CURSTATE_INSTALLED",pkgCache::State::Installed); // SelState PyModule_AddIntConstant(Module,"SELSTATE_UNKNOWN",pkgCache::State::Unknown); PyModule_AddIntConstant(Module,"SELSTATE_INSTALL",pkgCache::State::Install); PyModule_AddIntConstant(Module,"SELSTATE_HOLD",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"SELSTATE_DEINSTALL",pkgCache::State::DeInstall); + PyModule_AddIntConstant(Module,"SELSTATE_DE_INSTALL",pkgCache::State::DeInstall); PyModule_AddIntConstant(Module,"SELSTATE_PURGE",pkgCache::State::Purge); // InstState PyModule_AddIntConstant(Module,"INSTSTATE_OK",pkgCache::State::Ok); - PyModule_AddIntConstant(Module,"INSTSTATE_REINSTREQ",pkgCache::State::ReInstReq); + PyModule_AddIntConstant(Module,"INSTSTATE_RE_INST_REQ",pkgCache::State::ReInstReq); PyModule_AddIntConstant(Module,"INSTSTATE_HOLD",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_REINSTREQ",pkgCache::State::HoldReInstReq); + PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_RE_INST_REQ",pkgCache::State::HoldReInstReq); #ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"CurStateNotInstalled",pkgCache::State::NotInstalled); diff --git a/python/cache.cc b/python/cache.cc index c7694026..27b77773 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -196,12 +196,12 @@ static PyObject *PkgCacheGetFileList(PyObject *Self, void*) { static PyGetSetDef PkgCacheGetSet[] = { {"depends_count",PkgCacheGetDependsCount}, - {"filelist",PkgCacheGetFileList}, + {"file_list",PkgCacheGetFileList}, {"package_count",PkgCacheGetPackageCount}, - {"packagefile_count",PkgCacheGetPackageFileCount}, + {"package_file_count",PkgCacheGetPackageFileCount}, {"packages",PkgCacheGetPackages}, {"provides_count",PkgCacheGetProvidesCount}, - {"verfile_count",PkgCacheGetVerFileCount}, + {"ver_file_count",PkgCacheGetVerFileCount}, {"version_count",PkgCacheGetVersionCount}, #ifdef COMPAT_0_7 {"DependsCount",PkgCacheGetDependsCount}, @@ -499,8 +499,8 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*) static PyGetSetDef PackageGetSet[] = { {"name",PackageGetName}, {"section",PackageGetSection}, - {"revdependslist",PackageGetRevDependsList}, - {"provideslist",PackageGetProvidesList}, + {"rev_depends_list",PackageGetRevDependsList}, + {"provides_list",PackageGetProvidesList}, {"selected_state",PackageGetSelectedState}, {"inst_state",PackageGetInstState}, {"current_state",PackageGetCurrentState}, @@ -508,8 +508,8 @@ static PyGetSetDef PackageGetSet[] = { {"auto",PackageGetAuto}, {"essential",PackageGetEssential}, {"important",PackageGetImportant}, - {"versionlist",PackageGetVersionList}, - {"currentver",PackageGetCurrentVer}, + {"version_list",PackageGetVersionList}, + {"current_ver",PackageGetCurrentVer}, #ifdef COMPAT_0_7 {"Name",PackageGetName}, {"Section",PackageGetSection}, @@ -609,9 +609,9 @@ static PyObject *DescriptionGetFileList(PyObject *Self,void*) } static PyGetSetDef DescriptionGetSet[] = { - {"languagecode",DescriptionGetLanguageCode}, + {"language_code",DescriptionGetLanguageCode}, {"md5",DescriptionGetMd5}, - {"filelist",DescriptionGetFileList}, + {"file_list",DescriptionGetFileList}, #ifdef COMPAT_0_7 {"LanguageCode",DescriptionGetLanguageCode}, {"FileList",DescriptionGetFileList}, @@ -1212,13 +1212,13 @@ static PyObject *DependencyGetID(PyObject *Self,void*) } static PyGetSetDef DependencyGetSet[] = { - {"comptype",DependencyGetCompType}, - {"deptype",DependencyGetDepType}, + {"comp_type",DependencyGetCompType}, + {"dep_type",DependencyGetDepType}, {"id",DependencyGetID}, - {"parentpkg",DependencyGetParentPkg}, - {"parentver",DependencyGetParentVer}, - {"targetpkg",DependencyGetTargetPkg}, - {"targetver",DependencyGetTargetVer}, + {"parent_pkg",DependencyGetParentPkg}, + {"parent_ver",DependencyGetParentVer}, + {"target_pkg",DependencyGetTargetPkg}, + {"target_ver",DependencyGetTargetVer}, #ifdef COMPAT_0_7 {"CompType",DependencyGetCompType}, {"DepType",DependencyGetDepType}, diff --git a/python/configuration.cc b/python/configuration.cc index 107cf90f..7b08d90e 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -462,10 +462,10 @@ static PyMethodDef CnfMethods[] = // Others {"set",CnfSet,METH_VARARGS,doc_Set}, {"exists",CnfExists,METH_VARARGS,doc_Exists}, - {"subtree",CnfSubTree,METH_VARARGS,doc_SubTree}, + {"sub_tree",CnfSubTree,METH_VARARGS,doc_SubTree}, {"list",CnfList,METH_VARARGS,doc_List}, - {"valuelist",CnfValueList,METH_VARARGS,doc_ValueList}, - {"mytag",CnfMyTag,METH_VARARGS,doc_MyTag}, + {"value_list",CnfValueList,METH_VARARGS,doc_ValueList}, + {"my_tag",CnfMyTag,METH_VARARGS,doc_MyTag}, {"clear",CnfClear,METH_VARARGS,doc_Clear}, #ifdef COMPAT_0_7 {"Find",CnfFind,METH_VARARGS,doc_Find}, diff --git a/python/depcache.cc b/python/depcache.cc index f3b16211..650dcb23 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -529,19 +529,19 @@ static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) static PyMethodDef PkgDepCacheMethods[] = { {"init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, - {"get_candidate",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, - {"set_candidate",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"}, + {"get_candidate_ver",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, + {"set_candidate_ver",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"}, // global cache operations {"upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"}, {"fix_broken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"}, - {"read_pinfile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, + {"read_pin_file",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, {"minimize_upgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."}, // Manipulators {"mark_keep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, {"mark_delete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, {"mark_install",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, - {"set_reinstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, + {"set_re_install",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, // state information {"is_upgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, {"is_now_broken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, @@ -607,12 +607,12 @@ static PyObject *PkgDepCacheGetDebSize(PyObject *Self,void*) { #undef depcache static PyGetSetDef PkgDepCacheGetSet[] = { - {"brokencount",PkgDepCacheGetBrokenCount}, - {"debsize",PkgDepCacheGetDebSize}, - {"delcount",PkgDepCacheGetDelCount}, - {"instcount",PkgDepCacheGetInstCount}, - {"keepcount",PkgDepCacheGetKeepCount}, - {"usrsize",PkgDepCacheGetUsrSize}, + {"broken_count",PkgDepCacheGetBrokenCount}, + {"deb_size",PkgDepCacheGetDebSize}, + {"del_count",PkgDepCacheGetDelCount}, + {"inst_count",PkgDepCacheGetInstCount}, + {"keep_count",PkgDepCacheGetKeepCount}, + {"usr_size",PkgDepCacheGetUsrSize}, #ifdef COMPAT_0_7 {"BrokenCount",PkgDepCacheGetBrokenCount}, {"DebSize",PkgDepCacheGetDebSize}, diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index f9e48352..48440387 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -120,18 +120,18 @@ static PyObject *PkgRecordsGetRecord(PyObject *Self,void*) { return PyString_FromStringAndSize(start,stop-start); } static PyGetSetDef PkgRecordsGetSet[] = { - {"filename",PkgRecordsGetFileName}, + {"file_name",PkgRecordsGetFileName}, {"homepage",PkgRecordsGetHomepage}, - {"longdesc",PkgRecordsGetLongDesc}, - {"md5",PkgRecordsGetMD5Hash}, + {"long_desc",PkgRecordsGetLongDesc}, + {"md5_hash",PkgRecordsGetMD5Hash}, {"maintainer",PkgRecordsGetMaintainer}, {"name",PkgRecordsGetName}, {"record",PkgRecordsGetRecord}, - {"sha1",PkgRecordsGetSHA1Hash}, - {"sha256",PkgRecordsGetSHA256Hash}, - {"shortdesc",PkgRecordsGetShortDesc}, - {"sourcepkg",PkgRecordsGetSourcePkg}, - {"sourcever",PkgRecordsGetSourceVer}, + {"sha1_hash",PkgRecordsGetSHA1Hash}, + {"sha256_hash",PkgRecordsGetSHA256Hash}, + {"short_desc",PkgRecordsGetShortDesc}, + {"source_pkg",PkgRecordsGetSourcePkg}, + {"source_ver",PkgRecordsGetSourceVer}, #ifdef COMPAT_0_7 {"FileName",PkgRecordsGetFileName}, {"Homepage",PkgRecordsGetHomepage}, diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 2a8b7bab..dea7ff37 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -173,7 +173,7 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { static PyGetSetDef PkgSrcRecordsGetSet[] = { {"binaries",PkgSrcRecordsGetBinaries}, - {"builddepends",PkgSrcRecordsGetBuildDepends}, + {"build_depends",PkgSrcRecordsGetBuildDepends}, {"files",PkgSrcRecordsGetFiles}, {"index",PkgSrcRecordsGetIndex}, {"maintainer",PkgSrcRecordsGetMaintainer}, diff --git a/python/tag.cc b/python/tag.cc index 846123ba..c30adb0a 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -378,7 +378,7 @@ static PyMethodDef TagSecMethods[] = { // Query {"find",TagSecFind,METH_VARARGS,doc_Find}, - {"findflag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, + {"find_flag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, {"bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, #ifdef COMPAT_0_7 {"Find",TagSecFind,METH_VARARGS,doc_Find}, -- cgit v1.2.3 From 14dfadc054e9bdafd2507dbca70dbec925471ae0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 15:00:15 +0200 Subject: Introduce the rename rules formally, and add some exceptions. --- apt/cache.py | 4 +- apt/package.py | 10 ++--- doc/source/apt_pkg.rst | 36 ++++++++-------- doc/source/examples/cache-pkgfile.py | 2 +- doc/source/whatsnew/0.8.0.rst | 82 +++++++++++++++++++++++++++++++++++- python/acquire.cc | 10 ++--- python/apt_pkgmodule.cc | 16 +++---- python/cache.cc | 2 +- python/configuration.cc | 2 +- python/depcache.cc | 4 +- python/pkgrecords.cc | 2 +- 11 files changed, 124 insertions(+), 46 deletions(-) (limited to 'python/depcache.cc') diff --git a/apt/cache.py b/apt/cache.py index 56b32d45..8590510c 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -170,8 +170,8 @@ class Cache(object): reqreinst = set() for pkg in self: if (not pkg.candidate.downloadable and - (pkg._pkg.inst_state == apt_pkg.INSTSTATE_RE_INST_REQ or - pkg._pkg.inst_state == apt_pkg.INSTSTATE_HOLD_RE_INST_REQ)): + (pkg._pkg.inst_state == apt_pkg.INSTSTATE_REINSTREQ or + pkg._pkg.inst_state == apt_pkg.INSTSTATE_HOLD_REINSTREQ)): reqreinst.add(pkg.name) return reqreinst diff --git a/apt/package.py b/apt/package.py index a24486e1..48d14595 100644 --- a/apt/package.py +++ b/apt/package.py @@ -379,7 +379,7 @@ class Version(object): .. versionadded:: 0.7.10 """ - return self._records.file_name + return self._records.filename @property def md5(self): @@ -413,7 +413,7 @@ class Version(object): for (packagefile, index) in self._cand.file_list: indexfile = self.package._pcache._list.find_index(packagefile) if indexfile: - yield indexfile.archive_uri(self._records.file_name) + yield indexfile.archive_uri(self._records.filename) @property def uris(self): @@ -443,19 +443,19 @@ class Version(object): .. versionadded:: 0.7.10 """ - base = os.path.basename(self._records.file_name) + base = os.path.basename(self._records.filename) destfile = os.path.join(destdir, base) if _file_is_same(destfile, self.size, self._records.md5_hash): print 'Ignoring already existing file:', destfile return acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash, self.size, - base, dest_file=destfile) + base, destfile=destfile) acq.run() for item in acq.items: if item.status != item.stat_done: raise FetchError("The item %r could not be fetched: %s" % - (item.dest_file, item.error_text)) + (item.destfile, item.error_text)) return os.path.abspath(destfile) def fetch_source(self, destdir="", progress=None, unpack=True): diff --git a/doc/source/apt_pkg.rst b/doc/source/apt_pkg.rst index 39b48c35..c814615c 100644 --- a/doc/source/apt_pkg.rst +++ b/doc/source/apt_pkg.rst @@ -167,7 +167,7 @@ Working with the cache If *from_user* is ``True``, the package will be marked as manually installed. This is the default. - .. method:: set_re_install(pkg) + .. method:: set_reinstall(pkg) Set if the :class:`Package` *pkg* should be reinstalled. @@ -398,7 +398,7 @@ Resolving Dependencies The component (eg. main) - .. attribute:: file_name + .. attribute:: filename The name of the file. @@ -430,7 +430,7 @@ Resolving Dependencies for pkgfile in cache.file_list: if pkgfile.not_source: - print 'The file %s has no source.' % pkgfile.file_name + print 'The file %s has no source.' % pkgfile.filename .. attribute:: origin @@ -809,7 +809,7 @@ Records # Now you can access the record print records.SourcePkg # == python-apt - .. attribute:: file_name + .. attribute:: filename Return the field 'Filename' of the record. This is the path to the package, relative to the base path of the archive. @@ -1103,7 +1103,7 @@ installation. Constant for comparing :attr:`AcquireItem.status` -.. class:: AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir, dest_file]) +.. class:: AcquireFile(owner, uri[, md5, size, descr, short_descr, destdir, destfile]) Create a new :class:`AcquireFile()` object and register it with *acquire*, so it will be fetched. AcquireFile objects provide no methods or attributes @@ -1126,9 +1126,9 @@ installation. used to describe the item in the progress class. *short_descr* is the short form of it. - You can use *dest_dir* to manipulate the directory where the file will - be saved in. Instead of *dest_dir*, you can also specify the full path to - the file using the parameter *dest_file*. You can not combine both. + You can use *destdir* to manipulate the directory where the file will + be saved in. Instead of *destdir*, you can also specify the full path to + the file using the parameter *destfile*. You can not combine both. @@ -1379,7 +1379,7 @@ Configuration Check whether the key *key* exists in the configuration. - .. method:: sub_tree(key) + .. method:: subtree(key) Return a sub tree starting at *key*. The resulting object can be used like this one. @@ -1429,7 +1429,7 @@ Configuration Behaves like a :class:`Configuration()` objects, but provides access to a subsection of another Configuration-like object. This type of object is - returned by the :meth:`Configuration.sub_tree()` method. + returned by the :meth:`Configuration.subtree()` method. .. data:: config @@ -1459,7 +1459,7 @@ Modifying the settings therein to the :class:`Configuration()` object specified by the parameter *configuration* -.. function:: parse_command_line(configuration, options, argv) +.. function:: parse_commandline(configuration, options, argv) This function is like getopt except it manipulates a configuration space. output is a list of non-option arguments (filenames, etc). *options* is a @@ -1541,11 +1541,11 @@ String functions apt_pkg.check_domain_list("alioth.debian.org","debian.net,debian.org") -.. function:: de_quote_string(string) +.. function:: dequote_string(string) Dequote the string specified by the parameter *string*, e.g.:: - >>> apt_pkg.DeQuoteString("%61%70%74%20is%20cool") + >>> apt_pkg.dequote_string("%61%70%74%20is%20cool") 'apt is cool' .. function:: quote_string(string, repl) @@ -1627,14 +1627,14 @@ String functions Return the string *version*, eliminating everything following the last '-'. Thus, this should be equivalent to ``version.rsplit('-', 1)[0]``. -.. function:: uri_to_file_name(uri) +.. function:: uri_to_filename(uri) Take a string *uri* as parameter and return a filename which can be used to store the file, based on the URI. Example:: - >>> apt_pkg.uri_to_file_name('http://debian.org/index.html') + >>> apt_pkg.uri_to_filename('http://debian.org/index.html') 'debian.org_index.html' @@ -1667,7 +1667,7 @@ Package States .. data:: CURSTATE_HALF_INSTALLED .. data:: CURSTATE_INSTALLED .. data:: CURSTATE_NOT_INSTALLED -.. data:: CURSTATE_UN_PACKED +.. data:: CURSTATE_UNPACKED @@ -1687,9 +1687,9 @@ Dependency types Installed states ^^^^^^^^^^^^^^^^ .. data:: INSTSTATE_HOLD -.. data:: INSTSTATE_HOLD_RE_INST_REQ +.. data:: INSTSTATE_HOLD_REINSTREQ .. data:: INSTSTATE_OK -.. data:: INSTSTATE_RE_INST_REQ +.. data:: INSTSTATE_REINSTREQ .. _Priorities: diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py index 1300a55c..f4cc2e66 100644 --- a/doc/source/examples/cache-pkgfile.py +++ b/doc/source/examples/cache-pkgfile.py @@ -7,7 +7,7 @@ def main(): apt_pkg.init() cache = apt_pkg.Cache() for pkgfile in cache.file_list: - print 'Package-File:', pkgfile.file_name + print 'Package-File:', pkgfile.filename print 'Index-Type:', pkgfile.index_type # 'Debian Package Index' if pkgfile.not_source: print 'Source: None' diff --git a/doc/source/whatsnew/0.8.0.rst b/doc/source/whatsnew/0.8.0.rst index d1ac3ac5..d507e82a 100644 --- a/doc/source/whatsnew/0.8.0.rst +++ b/doc/source/whatsnew/0.8.0.rst @@ -15,19 +15,97 @@ Python-apt is the first Debian package to support the third major release of Python. The port is straight forward and integrates as nicely in Python 3 as the Python 2 builds integrate in Python 2. +Please be aware that python-apt builds for Python 3 are built without the +compatibility options enabled for Python 2 builds. They also do not provide +methods like :meth:`has_key` on mapping objects, because it has been removed +in Python 3. + Real classes in :mod:`apt_pkg` ------------------------------ +The 0.8 release introduces real classes in the :mod:`apt_pkg` extension. This +is an important step forward and makes writing code much easier, because you +can see the classes without having to create an object first. It also makes +it easier to talk about those classes, because they have a real name now. + +The 0.7 series shipped many functions for creating new objects, because the +classes were not exported. In 0.8, the classes themselves replace those +functions, as you can see in the following table. + +.. table:: + + ===================================== ================================= + Function Replacing class + ===================================== ================================= + :func:`apt_pkg.GetAcquire` :class:`apt_pkg.Acquire` + :func:`apt_pkg.GetCache()` :class:`apt_pkg.Cache` + :func:`apt_pkg.GetCdrom()` :class:`apt_pkg.Cdrom` + :func:`apt_pkg.GetDepCache()` :class:`apt_pkg.DepCache` + :func:`apt_pkg.GetPackageManager` :class:`apt_pkg.PackageManager` + :func:`apt_pkg.GetPkgAcqFile` :class:`apt_pkg.AcquireFile` + :func:`apt_pkg.GetPkgActionGroup` :class:`apt_pkg.ActionGroup` + :func:`apt_pkg.GetPkgProblemResolver` :class:`apt_pkg.ProblemResolver` + :func:`apt_pkg.GetPkgRecords` :class:`apt_pkg.PackageRecords` + :func:`apt_pkg.GetPkgSourceList` :class:`apt_pkg.SourceList` + :func:`apt_pkg.GetPkgSrcRecords` :class:`apt_pkg.SourceRecords` + :func:`apt_pkg.ParseSection` :class:`apt_pkg.TagSection` + :func:`apt_pkg.ParseTagFile` :class:`apt_pkg.TagFile` + ===================================== ================================= Complete rename of functions, methods and attributes ----------------------------------------------------- +In May 2008, Ben Finney reported bug 481061 against the python-apt package, +asking for PEP8 conformant names. With the release of python-apt 0.8, this +is finally happening. Supporting new language features like the :keyword:`with` statement ------------------------------------------------------------------- +This is not a real big change, but it's good to have it: +:class:`apt_pkg.ActionGroup` can now be used as a context manager for the +:keyword:`with` statement. This makes it more obvious that you are using an +action group, and is just cooler:: + + with apt_pkg.ActionGroup(depcache): + for package in my_selected_packages: + depcache.mark_install(package) + +This also works for :class:`apt.Cache`:: + + with cache.action_group(): # cache is an Instance of apt.Cache + for package in my_selected_packages: + package.mark_install() # Instance of apt.Package + Other changes ------------- This release of python-apt also features several other, smaller changes: - * Reduced memory usage by creating Package() objects in apt.Cache() only - when needed. + * Reduced memory usage by making :class:`apt.Cache` create + :class:`apt.Package()` object dynamically, instead of creating all of + them during the cache initialization. * Support to set the candidate version in :class:`apt.package.Package` + +Porting your applications to python-apt 0.8 +------------------------------------------- +Porting your application to python-apt 0.8 may be trivial. You should download +the source tarball of python-apt and run the tool utils/migrate-0.8 using +Python 2.6 over your code:: + + python2.6 utils/migrate-0.8.py -c myapp.py mypackage/ + +This will search your code for places where possibly deprecated names are +used. Using the argument ``-c``, you can turn colorized output on. + +Now that you know which parts of your code have to be changed, you have to know +how to do this. For classes, please look at the table. For all attributes, +methods, functions, and their parameters the following rules apply: + + 1. Replace leading [A-Z] with [a-z] (e.g DescURI => descURI) + 2. Replace multiple [A-Z] with [A-Z][a-z] (e.g. descURI => descUri) + 3. Replace every [A-Z] with the corresponding [a-z] (descUri => desc_uri) + +As an exception, refixes such as 'de' (e.g. 'dequote') or 'un' (e.g. 'unlock') +are normally not seperated by underscores from the next word. There are also +some other exceptions which are listed here, and apply to any name containing +this word: **filename**, **filesize**, **destdir**, **destfile**, **dequote**, +**unlock**, **reinstall**, **pinfile**, **REINSTREQ**, **UNPACKED**, +**parse_commandline**. diff --git a/python/acquire.cc b/python/acquire.cc index 1b1c5dd8..5f38f7bd 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -40,9 +40,9 @@ MkGet(AcquireItemGetStatAuthError,Py_BuildValue("i", pkgAcquire::Item::StatAuthE static PyGetSetDef AcquireItemGetSet[] = { {"complete",AcquireItemGetComplete}, {"desc_uri",AcquireItemGetDescURI}, - {"dest_file",AcquireItemGetDestFile}, + {"destfile",AcquireItemGetDestFile}, {"error_text",AcquireItemGetErrorText}, - {"file_size",AcquireItemGetFileSize}, + {"filesize",AcquireItemGetFileSize}, {"is",AcquireItemGetID}, {"is_trusted",AcquireItemGetIsTrusted}, {"local",AcquireItemGetLocal}, @@ -310,7 +310,7 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject int size = 0; uri = md5 = descr = shortDescr = destDir = destFile = ""; - char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortdescr", + char * kwlist[] = {"owner","uri", "md5", "size", "descr", "short_descr", "destdir", "destfile", NULL}; if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, @@ -335,8 +335,8 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject static char *doc_PkgAcquireFile = - "AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir," - "dest_file]) -> New AcquireFile() object\n\n" + "AcquireFile(owner, uri[, md5, size, descr, short_descr, destdir," + "destfile]) -> New AcquireFile() object\n\n" "The parameter *owner* refers to an apt_pkg.Acquire() object. You can use\n" "*destdir* OR *destfile* to specify the destination directory/file."; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index bfabc652..403e0ebf 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -407,7 +407,7 @@ static PyMethodDef methods[] = // Locking {"get_lock",GetLock,METH_VARARGS,doc_GetLock}, {"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, - {"pkgsystem_un_lock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, + {"pkgsystem_unlock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, #ifdef COMPAT_0_7 {"GetLock",GetLock,METH_VARARGS,doc_GetLock}, {"PkgSystemLock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, @@ -418,7 +418,7 @@ static PyMethodDef methods[] = {"read_config_file",LoadConfig,METH_VARARGS,doc_LoadConfig}, {"read_config_dir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, {"read_config_file_isc",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, - {"parse_command_line",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, + {"parse_commandline",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, #ifdef COMPAT_0_7 {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, @@ -452,10 +452,10 @@ static PyMethodDef methods[] = // Strings {"check_domain_list",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, {"quote_string",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"}, - {"de_quote_string",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, + {"dequote_string",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, {"size_to_str",StrSizeToStr,METH_VARARGS,"SizeToStr(int) -> String"}, {"time_to_str",StrTimeToStr,METH_VARARGS,"TimeToStr(int) -> String"}, - {"uri_to_file_name",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, + {"uri_to_filename",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, {"base64_encode",StrBase64Encode,METH_VARARGS,"Base64Encode(String) -> String"}, {"string_to_bool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"}, {"time_rfc1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"}, @@ -657,7 +657,7 @@ extern "C" void initapt_pkg() #endif // CurState PyModule_AddIntConstant(Module,"CURSTATE_NOT_INSTALLED",pkgCache::State::NotInstalled); - PyModule_AddIntConstant(Module,"CURSTATE_UN_PACKED",pkgCache::State::UnPacked); + PyModule_AddIntConstant(Module,"CURSTATE_UNPACKED",pkgCache::State::UnPacked); PyModule_AddIntConstant(Module,"CURSTATE_HALF_CONFIGURED",pkgCache::State::HalfConfigured); PyModule_AddIntConstant(Module,"CURSTATE_HALF_INSTALLED",pkgCache::State::HalfInstalled); PyModule_AddIntConstant(Module,"CURSTATE_CONFIG_FILES",pkgCache::State::ConfigFiles); @@ -666,13 +666,13 @@ extern "C" void initapt_pkg() PyModule_AddIntConstant(Module,"SELSTATE_UNKNOWN",pkgCache::State::Unknown); PyModule_AddIntConstant(Module,"SELSTATE_INSTALL",pkgCache::State::Install); PyModule_AddIntConstant(Module,"SELSTATE_HOLD",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"SELSTATE_DE_INSTALL",pkgCache::State::DeInstall); + PyModule_AddIntConstant(Module,"SELSTATE_DEINSTALL",pkgCache::State::DeInstall); PyModule_AddIntConstant(Module,"SELSTATE_PURGE",pkgCache::State::Purge); // InstState PyModule_AddIntConstant(Module,"INSTSTATE_OK",pkgCache::State::Ok); - PyModule_AddIntConstant(Module,"INSTSTATE_RE_INST_REQ",pkgCache::State::ReInstReq); + PyModule_AddIntConstant(Module,"INSTSTATE_REINSTREQ",pkgCache::State::ReInstReq); PyModule_AddIntConstant(Module,"INSTSTATE_HOLD",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_RE_INST_REQ",pkgCache::State::HoldReInstReq); + PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_REINSTREQ",pkgCache::State::HoldReInstReq); #ifdef COMPAT_0_7 PyModule_AddIntConstant(Module,"CurStateNotInstalled",pkgCache::State::NotInstalled); diff --git a/python/cache.cc b/python/cache.cc index 21a6a872..d09e22f3 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -1030,7 +1030,7 @@ static PyGetSetDef PackageFileGetSet[] = { {(char*)"architecture",PackageFile_GetArchitecture}, {(char*)"archive",PackageFile_GetArchive}, {(char*)"component",PackageFile_GetComponent}, - {(char*)"file_name",PackageFile_GetFileName}, + {(char*)"filename",PackageFile_GetFileName}, {(char*)"id",PackageFile_GetID}, {(char*)"index_type",PackageFile_GetIndexType}, {(char*)"label",PackageFile_GetLabel}, diff --git a/python/configuration.cc b/python/configuration.cc index 7b08d90e..81dd78ac 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -462,7 +462,7 @@ static PyMethodDef CnfMethods[] = // Others {"set",CnfSet,METH_VARARGS,doc_Set}, {"exists",CnfExists,METH_VARARGS,doc_Exists}, - {"sub_tree",CnfSubTree,METH_VARARGS,doc_SubTree}, + {"subtree",CnfSubTree,METH_VARARGS,doc_SubTree}, {"list",CnfList,METH_VARARGS,doc_List}, {"value_list",CnfValueList,METH_VARARGS,doc_ValueList}, {"my_tag",CnfMyTag,METH_VARARGS,doc_MyTag}, diff --git a/python/depcache.cc b/python/depcache.cc index 650dcb23..f69802f8 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -535,13 +535,13 @@ static PyMethodDef PkgDepCacheMethods[] = // global cache operations {"upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"}, {"fix_broken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"}, - {"read_pin_file",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, + {"read_pinfile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, {"minimize_upgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."}, // Manipulators {"mark_keep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, {"mark_delete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, {"mark_install",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, - {"set_re_install",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, + {"set_reinstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, // state information {"is_upgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, {"is_now_broken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 48440387..212e4ab0 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -120,7 +120,7 @@ static PyObject *PkgRecordsGetRecord(PyObject *Self,void*) { return PyString_FromStringAndSize(start,stop-start); } static PyGetSetDef PkgRecordsGetSet[] = { - {"file_name",PkgRecordsGetFileName}, + {"filename",PkgRecordsGetFileName}, {"homepage",PkgRecordsGetHomepage}, {"long_desc",PkgRecordsGetLongDesc}, {"md5_hash",PkgRecordsGetMD5Hash}, -- cgit v1.2.3 From acf0e2af557be18a31570f8e21ccf67233b20004 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 16:36:52 +0200 Subject: python/: Put all deprecated Get*() functions into #ifdef COMPAT_0_7. --- python/acquire.cc | 5 ++++- python/apt_pkgmodule.cc | 2 ++ python/cache.cc | 3 ++- python/cdrom.cc | 2 ++ python/depcache.cc | 8 ++++++-- python/pkgmanager.cc | 2 ++ python/pkgrecords.cc | 4 ++-- python/pkgsrcrecords.cc | 3 ++- python/sourcelist.cc | 5 +++-- python/tag.cc | 4 ++++ 10 files changed, 29 insertions(+), 9 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 5f38f7bd..e6a23548 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -297,11 +297,12 @@ PyTypeObject PkgAcquireType = PkgAcquireNew, // tp_new }; - +#ifdef COMPAT_0_7 PyObject *GetAcquire(PyObject *Self,PyObject *Args) { return PkgAcquireNew(&PkgAcquireType,Args,0); } +#endif static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject * kwds) { @@ -386,6 +387,7 @@ PyTypeObject PkgAcquireFileType = PkgAcquireFileNew, // tp_new }; +#ifdef COMPAT_0_7 char *doc_GetPkgAcqFile = "GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n"; PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) @@ -417,3 +419,4 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) return AcqFileObj; } +#endif diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index a34d4720..4ad4e56c 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -30,11 +30,13 @@ // newConfiguration - Build a new configuration class /*{{{*/ // --------------------------------------------------------------------- +#ifdef COMPAT_0_7 static char *doc_newConfiguration = "Construct a configuration instance"; static PyObject *newConfiguration(PyObject *self,PyObject *args) { return CppPyObject_NEW(&ConfigurationType); } +#endif /*}}}*/ // Version Wrappers /*{{{*/ diff --git a/python/cache.cc b/python/cache.cc index d09e22f3..38b715de 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -1345,8 +1345,9 @@ PyTypeObject RDepListType = /*}}}*/ - +#ifdef COMPAT_0_7 PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { return PkgCacheNew(&PkgCacheType,Args,0); } +#endif diff --git a/python/cdrom.cc b/python/cdrom.cc index 044bbf30..3e63a89c 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -129,10 +129,12 @@ PyTypeObject PkgCdromType = PkgCdromNew, // tp_new }; +#ifdef COMPAT_0_7 PyObject *GetCdrom(PyObject *Self,PyObject *Args) { return PkgCdromNew(&PkgCdromType,Args,0); } +#endif diff --git a/python/depcache.cc b/python/depcache.cc index f69802f8..a69e0723 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -696,12 +696,12 @@ PyTypeObject PkgDepCacheType = PkgDepCacheNew, // tp_new }; - +#ifdef COMPAT_0_7 PyObject *GetDepCache(PyObject *Self,PyObject *Args) { return PkgDepCacheNew(&PkgDepCacheType,Args,0); } - +#endif @@ -729,9 +729,11 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec return PkgProblemResolverPyObj; } +#ifdef COMPAT_0_7 PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { return PkgProblemResolverNew(&PkgProblemResolverType,Args,0); } +#endif static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) { @@ -994,10 +996,12 @@ PyTypeObject PkgActionGroupType = PkgActionGroupNew, // tp_new }; +#ifdef COMPAT_0_7 PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) { return PkgActionGroupNew(&PkgActionGroupType,Args,0); } +#endif /*}}}*/ diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index cae2b580..7752ce5b 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -36,10 +36,12 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return PkgManagerObj; } +#ifdef COMPAT_0_7 PyObject *GetPkgManager(PyObject *Self,PyObject *Args) { return PkgManagerNew(&PkgManagerType,Args,0); } +#endif static PyObject *PkgManagerGetArchives(PyObject *Self,PyObject *Args) diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 212e4ab0..6022097a 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -210,9 +210,9 @@ PyTypeObject PkgRecordsType = /*}}}*/ - +#ifdef COMPAT_0_7 PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) { return PkgRecordsNew(&PkgRecordsType,Args,0); } - +#endif diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index dea7ff37..50445432 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -251,6 +251,7 @@ PyTypeObject PkgSrcRecordsType = /*}}}*/ +#ifdef COMPAT_0_7 PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) { #if 0 @@ -266,4 +267,4 @@ PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) return HandleErrors(CppPyObject_NEW(&PkgSrcRecordsType)); } - +#endif diff --git a/python/sourcelist.cc b/python/sourcelist.cc index daf0c08c..1c05d83e 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -159,8 +159,9 @@ PyTypeObject PkgSourceListType = PkgSourceListNew, // tp_new }; +#ifdef COMPAT_0_7 PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) { - return CppPyObject_NEW(&PkgSourceListType,new pkgSourceList()); + return PkgSourceListNew(&PkgSourceListType,Args,0); } - +#endif diff --git a/python/tag.cc b/python/tag.cc index c30adb0a..5a31488c 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -264,11 +264,13 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { return New; } +#ifdef COMPAT_0_7 char *doc_ParseSection ="ParseSection(Text) -> TagSection() object. Deprecated."; PyObject *ParseSection(PyObject *self,PyObject *Args) { return TagSecNew(&TagSecType,Args,0); } +#endif /*}}}*/ // ParseTagFile - Parse a tagd file /*{{{*/ // --------------------------------------------------------------------- @@ -297,10 +299,12 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return HandleErrors(New); } +#ifdef COMPAT_0_7 char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile() object. Deprecated."; PyObject *ParseTagFile(PyObject *self,PyObject *Args) { return TagFileNew(&TagFileType,Args,0); } +#endif /*}}}*/ // RewriteSection - Rewrite a section.. /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3 From f652213b76f72382bab21e730bf0ccc4419a1267 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Jun 2009 18:10:19 +0200 Subject: Allow types providing __new__() to be subclassed. --- debian/changelog | 3 ++- python/acquire.cc | 6 ++++-- python/cache.cc | 3 ++- python/cdrom.cc | 3 ++- python/configuration.cc | 3 ++- python/depcache.cc | 9 ++++++--- python/hashstring.cc | 3 ++- python/indexrecords.cc | 3 ++- python/pkgmanager.cc | 3 ++- python/pkgrecords.cc | 3 ++- python/pkgsrcrecords.cc | 3 ++- python/sourcelist.cc | 3 ++- python/tag.cc | 6 ++++-- 13 files changed, 34 insertions(+), 17 deletions(-) (limited to 'python/depcache.cc') diff --git a/debian/changelog b/debian/changelog index 1a80d081..818bf630 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,9 @@ python-apt (0.7.92) experimental; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) + * Allow types providing __new__() to be subclassed. - -- Julian Andres Klode Mon, 08 Jun 2009 17:23:37 +0200 + -- Julian Andres Klode Tue, 09 Jun 2009 18:09:53 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/acquire.cc b/python/acquire.cc index 05bffc65..702d48ce 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -276,7 +276,8 @@ PyTypeObject PkgAcquireType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgAcquire, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -366,7 +367,8 @@ PyTypeObject PkgAcquireFileType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgAcquireFile, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/cache.cc b/python/cache.cc index c988145f..14484104 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -331,7 +331,8 @@ PyTypeObject PkgCacheType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT , // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgCache, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/cdrom.cc b/python/cdrom.cc index 3e63a89c..e98947d1 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -108,7 +108,8 @@ PyTypeObject PkgCdromType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Cdrom Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/configuration.cc b/python/configuration.cc index 3c6ea88c..365a35fd 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -526,7 +526,8 @@ PyTypeObject ConfigurationType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Configuration Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/depcache.cc b/python/depcache.cc index a69e0723..f1c34fef 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -675,7 +675,8 @@ PyTypeObject PkgDepCacheType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgDepCache, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -858,7 +859,8 @@ PyTypeObject PkgProblemResolverType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "ProblemResolver Object", // tp_doc 0, // tp_traverse 0, // tp_clear @@ -975,7 +977,8 @@ PyTypeObject PkgActionGroupType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgActionGroup, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/hashstring.cc b/python/hashstring.cc index 71ae5bf4..58bcca9e 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -118,7 +118,8 @@ PyTypeObject PyHashString_Type = { 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), HashString_doc, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/indexrecords.cc b/python/indexrecords.cc index 35e41c59..61ff07fc 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -104,7 +104,8 @@ PyTypeObject PyIndexRecords_Type = { 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), IndexRecords_doc, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 7752ce5b..f47e77ad 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -153,7 +153,8 @@ PyTypeObject PkgManagerType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "PackageManager Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 6022097a..8beefffd 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -186,7 +186,8 @@ PyTypeObject PkgRecordsType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Records Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 50445432..e6b78a83 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -228,7 +228,8 @@ PyTypeObject PkgSrcRecordsType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "SourceRecords Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 1c05d83e..5e5838d8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -138,7 +138,8 @@ PyTypeObject PkgSourceListType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "pkgSourceList Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/tag.cc b/python/tag.cc index 31491c90..7e7eb21c 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -434,7 +434,8 @@ PyTypeObject TagSecType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_TagSec, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -521,7 +522,8 @@ PyTypeObject TagFileType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_TagFile, // tp_doc 0, // tp_traverse 0, // tp_clear -- cgit v1.2.3 From 395b33f9f8e93223f933c625bacbf1e2d23c6673 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Jun 2009 18:56:23 +0200 Subject: Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) We previously called the destructor of the pointer. This resulted in no object using pointers being deallocated. This patch introduces CppDeallocPtr() and CppOwnedDeallocPtr() which do the same as the other CppDealloc() and CppOwnedDealloc(), but use 'delete' on the pointer instead of the deconstructor. Furthermore, this patch also changes AcquireFile to be a CppOwnedPyObject, owned by the Acquire object. Without this change, deleting the Acquire object would cause a crash when AcquireFile is deallocated. --- debian/changelog | 5 +++-- python/acquire.cc | 8 ++++---- python/cache.cc | 4 ++-- python/depcache.cc | 6 +++--- python/generic.h | 19 +++++++++++++++++++ python/hashstring.cc | 2 +- python/indexfile.cc | 2 +- python/indexrecords.cc | 2 +- python/metaindex.cc | 2 +- python/pkgmanager.cc | 2 +- python/policy.cc | 2 +- python/sourcelist.cc | 2 +- 12 files changed, 38 insertions(+), 18 deletions(-) (limited to 'python/depcache.cc') diff --git a/debian/changelog b/debian/changelog index 3e85c5be..9f9838c3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,11 @@ -python-apt (0.7.92) experimental; urgency=low +python-apt (0.7.92) UNRELEASED; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) * Add apt_pkg.Policy class (Closes: #382725) * Allow types providing __new__() to be subclassed. + * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) - -- Julian Andres Klode Tue, 09 Jun 2009 20:39:39 +0200 + -- Julian Andres Klode Fri, 12 Jun 2009 18:42:02 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/acquire.cc b/python/acquire.cc index 702d48ce..6b091479 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -261,7 +261,7 @@ PyTypeObject PkgAcquireType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -329,7 +329,7 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject shortDescr, destDir, destFile); // short-desc - CppPyObject *AcqFileObj = CppPyObject_NEW(type); + CppOwnedPyObject *AcqFileObj = CppOwnedPyObject_NEW(pyfetcher, type); AcqFileObj->Object = af; return AcqFileObj; @@ -349,10 +349,10 @@ PyTypeObject PkgAcquireFileType = 0, // ob_size #endif "apt_pkg.AcquireFile", // tp_name - sizeof(CppPyObject),// tp_basicsize + sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/cache.cc b/python/cache.cc index 14484104..22ed9ecc 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -247,7 +247,7 @@ void PkgCacheFileDealloc(PyObject *Self) PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *CacheF = GetCpp(CacheFilePy); CacheF->Close(); - CppOwnedDealloc(Self); + CppOwnedDeallocPtr(Self); } static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) @@ -365,7 +365,7 @@ PyTypeObject PkgCacheFileType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/depcache.cc b/python/depcache.cc index f1c34fef..9bbda527 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -660,7 +660,7 @@ PyTypeObject PkgDepCacheType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -844,7 +844,7 @@ PyTypeObject PkgProblemResolverType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr,// tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -962,7 +962,7 @@ PyTypeObject PkgActionGroupType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/generic.h b/python/generic.h index df4d8755..b7b958f5 100644 --- a/python/generic.h +++ b/python/generic.h @@ -153,6 +153,25 @@ void CppOwnedDealloc(PyObject *iObj) iObj->ob_type->tp_free(iObj); } +// Pointer deallocation +// Generic Dealloc type functions +template +void CppDeallocPtr(PyObject *Obj) +{ + delete GetCpp(Obj); + Obj->ob_type->tp_free(Obj); +} + +template +void CppOwnedDeallocPtr(PyObject *iObj) +{ + CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; + delete Obj->Object; + if (Obj->Owner != 0) + Py_DECREF(Obj->Owner); + iObj->ob_type->tp_free(iObj); +} + inline PyObject *CppPyString(std::string Str) { return PyString_FromStringAndSize(Str.c_str(),Str.length()); diff --git a/python/hashstring.cc b/python/hashstring.cc index 58bcca9e..23212a4b 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -103,7 +103,7 @@ PyTypeObject PyHashString_Type = { sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/indexfile.cc b/python/indexfile.cc index 795931fb..78a4f513 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -99,7 +99,7 @@ PyTypeObject PackageIndexFileType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/indexrecords.cc b/python/indexrecords.cc index 61ff07fc..fcb2b85d 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -89,7 +89,7 @@ PyTypeObject PyIndexRecords_Type = { sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/metaindex.cc b/python/metaindex.cc index b451f0b5..b5d194b4 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -80,7 +80,7 @@ PyTypeObject MetaIndexType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index f47e77ad..0fd2cd92 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -138,7 +138,7 @@ PyTypeObject PkgManagerType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/policy.cc b/python/policy.cc index 89604e9a..992a1192 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -151,7 +151,7 @@ PyTypeObject PyPolicy_Type = { sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 5e5838d8..e53fccd3 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -123,7 +123,7 @@ PyTypeObject PkgSourceListType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr -- cgit v1.2.3 From dc6cdb234d24cbcc0cb9e5c93c01ac63898c3e40 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 14 Jun 2009 16:11:35 +0200 Subject: python/cache.cc,depcache.cc: Do not delete the depcache and cache pointers. Deleting the pointers caused a crash because those pointers will also be deleted by closing the cache file. --- python/cache.cc | 4 +++- python/depcache.cc | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/cache.cc b/python/cache.cc index 22ed9ecc..80a7a8a5 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -247,7 +247,9 @@ void PkgCacheFileDealloc(PyObject *Self) PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *CacheF = GetCpp(CacheFilePy); CacheF->Close(); - CppOwnedDeallocPtr(Self); + // Do not delete the pointer here, because it has already been deleted by + // closing the cache file. + CppOwnedDealloc(Self); } static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) diff --git a/python/depcache.cc b/python/depcache.cc index 9bbda527..288eb0b0 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -660,7 +660,8 @@ PyTypeObject PkgDepCacheType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + // Not ..Ptr, because the pkgDepCache pointer is managed by the CacheFile. + CppOwnedDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr -- cgit v1.2.3 From b81133a92aa673d0d9315e9837012e59a988333a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 21 Jun 2009 14:05:49 +0200 Subject: python: Add DeprecationWarning to functions which were replaced by classes. --- python/acquire.cc | 5 +++++ python/apt_pkgmodule.cc | 2 ++ python/cache.cc | 2 ++ python/cdrom.cc | 2 ++ python/depcache.cc | 8 ++++++++ python/pkgmanager.cc | 3 +++ python/pkgrecords.cc | 3 +++ python/pkgsrcrecords.cc | 11 +++-------- python/sourcelist.cc | 3 +++ python/tag.cc | 6 ++++++ 10 files changed, 37 insertions(+), 8 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 6b091479..d0549fd9 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -301,6 +301,8 @@ PyTypeObject PkgAcquireType = #ifdef COMPAT_0_7 PyObject *GetAcquire(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated." + " Please see apt_pkg.Acquire() for the replacement.", 1); return PkgAcquireNew(&PkgAcquireType,Args,0); } #endif @@ -394,6 +396,9 @@ char *doc_GetPkgAcqFile = "GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n"; PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is " + "deprecated. Please see apt_pkg.AcquireFile() for the " + "replacement", 1); PyObject *pyfetcher; char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; int size = 0; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index bfa59f8e..3a31440c 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -34,6 +34,8 @@ static char *doc_newConfiguration = "Construct a configuration instance"; static PyObject *newConfiguration(PyObject *self,PyObject *args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " + "deprecated. Use apt_pkg.Configuration() instead.", 1); return CppPyObject_NEW(&ConfigurationType); } #endif diff --git a/python/cache.cc b/python/cache.cc index 35c8b78f..a8da6696 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -1371,6 +1371,8 @@ PyTypeObject RDepListType = #ifdef COMPAT_0_7 PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. " + "Please see apt_pkg.Cache() for the replacement.", 1); return PkgCacheNew(&PkgCacheType,Args,0); } #endif diff --git a/python/cdrom.cc b/python/cdrom.cc index e98947d1..e2651670 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -133,6 +133,8 @@ PyTypeObject PkgCdromType = #ifdef COMPAT_0_7 PyObject *GetCdrom(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. " + "Please see apt_pkg.Cdrom() for the replacement.", 1); return PkgCdromNew(&PkgCdromType,Args,0); } #endif diff --git a/python/depcache.cc b/python/depcache.cc index 288eb0b0..7cf8e0a2 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -701,6 +701,8 @@ PyTypeObject PkgDepCacheType = #ifdef COMPAT_0_7 PyObject *GetDepCache(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated" + ". Please see apt_pkg.DepCache() for the replacement.",1); return PkgDepCacheNew(&PkgDepCacheType,Args,0); } #endif @@ -733,6 +735,9 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec #ifdef COMPAT_0_7 PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is" + " deprecated. Please see apt_pkg.ProblemResolver() for the " + "replacement.", 1); return PkgProblemResolverNew(&PkgProblemResolverType,Args,0); } #endif @@ -1003,6 +1008,9 @@ PyTypeObject PkgActionGroupType = #ifdef COMPAT_0_7 PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is " + "deprecated. Please see apt_pkg.ActionGroup() for the " + "replacement.", 1); return PkgActionGroupNew(&PkgActionGroupType,Args,0); } #endif diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 0fd2cd92..668f7cfc 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -39,6 +39,9 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) #ifdef COMPAT_0_7 PyObject *GetPkgManager(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is " + "deprecated. Please see apt_pkg.PackageManager() for the " + "replacement.", 1); return PkgManagerNew(&PkgManagerType,Args,0); } #endif diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 8beefffd..1e36259d 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -214,6 +214,9 @@ PyTypeObject PkgRecordsType = #ifdef COMPAT_0_7 PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is " + "deprecated. Please see apt_pkg.Records() for the " + "replacement.", 1); return PkgRecordsNew(&PkgRecordsType,Args,0); } #endif diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index e6b78a83..f75934f9 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -255,14 +255,9 @@ PyTypeObject PkgSrcRecordsType = #ifdef COMPAT_0_7 PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) { -#if 0 - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) - return 0; - - return HandleErrors(CppOwnedPyObject_NEW(Owner, - &PkgSrcRecordsType)); -#endif + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is " + "deprecated. Please see apt_pkg.SourceRecords() for the " + "replacement.", 1); if (PyArg_ParseTuple(Args,"") == 0) return 0; diff --git a/python/sourcelist.cc b/python/sourcelist.cc index e53fccd3..2cf5eea9 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -163,6 +163,9 @@ PyTypeObject PkgSourceListType = #ifdef COMPAT_0_7 PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is " + "deprecated. Please see apt_pkg.SourceList() for the " + "replacement.", 1); return PkgSourceListNew(&PkgSourceListType,Args,0); } #endif diff --git a/python/tag.cc b/python/tag.cc index 7e7eb21c..05423e3d 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -268,6 +268,9 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { char *doc_ParseSection ="ParseSection(Text) -> TagSection() object. Deprecated."; PyObject *ParseSection(PyObject *self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is " + "deprecated. Please see apt_pkg.TagSection() for the " + "replacement.", 1); return TagSecNew(&TagSecType,Args,0); } #endif @@ -302,6 +305,9 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) #ifdef COMPAT_0_7 char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile() object. Deprecated."; PyObject *ParseTagFile(PyObject *self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is " + "deprecated. Please see apt_pkg.TagFile() for the " + "replacement.", 1); return TagFileNew(&TagFileType,Args,0); } #endif -- cgit v1.2.3 From 13423bbbafc823740126e90ef0d7ca6e76fc7341 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 21 Jun 2009 19:47:31 +0200 Subject: python: Make all CppOwnedPyObjects and similar support garbage collection. If you want to subclass apt_pkg.Cache() and create an apt_pkg.DepCache() object in it (e.g. as self.depcache) this is needed because otherwise, Python would not know about the cyclic dependency and refuse to free any of them. This also changes apt_pkg.Cache to the standard deallocation schema, because the underlying CacheFile deletes its pointers automatically on deletion. Thus a second call is not needed. --- python/acquire.cc | 7 +++--- python/cache.cc | 62 ++++++++++++++++++++++++---------------------------- python/depcache.cc | 23 ++++++++++--------- python/generic.h | 44 +++++++++++++++++++++++++++++++++---- python/indexfile.cc | 6 ++--- python/pkgrecords.cc | 7 +++--- python/policy.cc | 9 ++++---- python/tag.cc | 37 +++++++++++++++++++++++-------- 8 files changed, 125 insertions(+), 70 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 704ad0bd..b0dd2cab 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -372,10 +372,11 @@ PyTypeObject PkgAcquireFileType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_PkgAcquireFile, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/cache.cc b/python/cache.cc index a8da6696..4624dc34 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -241,19 +241,6 @@ static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) return CppOwnedPyObject_NEW(Self,&PackageType,Pkg); } -// we need a special dealloc here to make sure that the CacheFile -// is closed before deallocation the cache (otherwise we have a bad) -// memory leak -void PkgCacheFileDealloc(PyObject *Self) -{ - PyObject *CacheFilePy = GetOwner(Self); - pkgCacheFile *CacheF = GetCpp(CacheFilePy); - CacheF->Close(); - // Do not delete the pointer here, because it has already been deleted by - // closing the cache file. - CppOwnedDealloc(Self); -} - static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *pyCallbackInst = 0; @@ -320,7 +307,7 @@ PyTypeObject PkgCacheType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - PkgCacheFileDealloc, // tp_dealloc + CppOwnedDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -336,10 +323,11 @@ PyTypeObject PkgCacheType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_PkgCache, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -460,7 +448,10 @@ PyTypeObject PkgListType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT , // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags + 0, // tp_doc + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear }; #define MkGet(PyFunc,Ret) static PyObject *PyFunc(PyObject *Self,void*) \ @@ -581,10 +572,10 @@ PyTypeObject PackageType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Package Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -672,10 +663,10 @@ PyTypeObject DescriptionType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "apt_pkg.Description Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -935,10 +926,10 @@ PyTypeObject VersionType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Version Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1098,10 +1089,10 @@ PyTypeObject PackageFileType = { 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "apt_pkg.PackageFile Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1274,10 +1265,10 @@ PyTypeObject DependencyType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Dependency Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1362,7 +1353,10 @@ PyTypeObject RDepListType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags + "DependencyList Object", // tp_doc + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear }; /*}}}*/ diff --git a/python/depcache.cc b/python/depcache.cc index 7cf8e0a2..d0b233b8 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -677,10 +677,11 @@ PyTypeObject PkgDepCacheType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_PkgDepCache, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -866,10 +867,11 @@ PyTypeObject PkgProblemResolverType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), "ProblemResolver Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -984,10 +986,11 @@ PyTypeObject PkgActionGroupType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_PkgActionGroup, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1002,7 +1005,7 @@ PyTypeObject PkgActionGroupType = 0, // tp_dictoffset 0, // tp_init 0, // tp_alloc - PkgActionGroupNew, // tp_new + PkgActionGroupNew, // tp_new }; #ifdef COMPAT_0_7 diff --git a/python/generic.h b/python/generic.h index b7b958f5..a9e6b8bf 100644 --- a/python/generic.h +++ b/python/generic.h @@ -29,6 +29,7 @@ #include #include +#include #include #if PYTHON_API_VERSION < 1013 @@ -99,6 +100,9 @@ inline PyObject *GetOwner(PyObject *Obj) template inline CppPyObject *CppPyObject_NEW(PyTypeObject *Type) { + #ifdef ALLOC_DEBUG + std::cerr << "=== ALLOCATING " << Type->tp_name << " ===\n"; + #endif CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T; return New; @@ -107,6 +111,9 @@ inline CppPyObject *CppPyObject_NEW(PyTypeObject *Type) template inline CppPyObject *CppPyObject_NEW(PyTypeObject *Type,A const &Arg) { + #ifdef ALLOC_DEBUG + std::cerr << "=== ALLOCATING " << Type->tp_name << " ===\n"; + #endif CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T(Arg); return New; @@ -116,6 +123,9 @@ template inline CppOwnedPyObject *CppOwnedPyObject_NEW(PyObject *Owner, PyTypeObject *Type) { + #ifdef ALLOC_DEBUG + std::cerr << "=== ALLOCATING " << Type->tp_name << "+ ===\n"; + #endif CppOwnedPyObject *New = (CppOwnedPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T; New->Owner = Owner; @@ -127,6 +137,9 @@ template inline CppOwnedPyObject *CppOwnedPyObject_NEW(PyObject *Owner, PyTypeObject *Type,A const &Arg) { + #ifdef ALLOC_DEBUG + std::cerr << "=== ALLOCATING " << Type->tp_name << "+ ===\n"; + #endif CppOwnedPyObject *New = (CppOwnedPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T(Arg); New->Owner = Owner; @@ -135,10 +148,26 @@ inline CppOwnedPyObject *CppOwnedPyObject_NEW(PyObject *Owner, return New; } +// Traversal and Clean for owned objects +template +int CppOwnedTraverse(PyObject *self, visitproc visit, void* arg) { + Py_VISIT(((CppOwnedPyObject *)self)->Owner); + return 0; +} + +template +int CppOwnedClear(PyObject *self) { + Py_CLEAR(((CppOwnedPyObject *)self)->Owner); + return 0; +} + // Generic Dealloc type functions template void CppDealloc(PyObject *Obj) { + #ifdef ALLOC_DEBUG + std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << " ===\n"; + #endif GetCpp(Obj).~T(); Obj->ob_type->tp_free(Obj); } @@ -146,10 +175,12 @@ void CppDealloc(PyObject *Obj) template void CppOwnedDealloc(PyObject *iObj) { + #ifdef ALLOC_DEBUG + std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "+ ===\n"; + #endif CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; Obj->Object.~T(); - if (Obj->Owner != 0) - Py_DECREF(Obj->Owner); + CppOwnedClear(iObj); iObj->ob_type->tp_free(iObj); } @@ -158,6 +189,9 @@ void CppOwnedDealloc(PyObject *iObj) template void CppDeallocPtr(PyObject *Obj) { + #ifdef ALLOC_DEBUG + std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << "* ===\n"; + #endif delete GetCpp(Obj); Obj->ob_type->tp_free(Obj); } @@ -165,10 +199,12 @@ void CppDeallocPtr(PyObject *Obj) template void CppOwnedDeallocPtr(PyObject *iObj) { + #ifdef ALLOC_DEBUG + std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "*+ ===\n"; + #endif CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; delete Obj->Object; - if (Obj->Owner != 0) - Py_DECREF(Obj->Owner); + CppOwnedClear(iObj); iObj->ob_type->tp_free(iObj); } diff --git a/python/indexfile.cc b/python/indexfile.cc index ba709872..ef88c2f0 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -114,10 +114,10 @@ PyTypeObject PackageIndexFileType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "pkgIndexFile Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 1e36259d..4a3c80db 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -187,10 +187,11 @@ PyTypeObject PkgRecordsType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), "Records Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/policy.cc b/python/policy.cc index 992a1192..39bbc1a3 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -167,15 +167,16 @@ PyTypeObject PyPolicy_Type = { 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), Policy_doc, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter 0, // tp_iternext - Policy_Methods, // tp_methods + Policy_Methods, // tp_methods 0, // tp_members 0, // tp_getset 0, // tp_base diff --git a/python/tag.cc b/python/tag.cc index 05423e3d..74857fe5 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -34,7 +34,7 @@ using namespace std; /*}}}*/ /* We need to keep a private copy of the data.. */ -struct TagSecData : public CppPyObject +struct TagSecData : public CppOwnedPyObject { char *Data; }; @@ -47,6 +47,18 @@ struct TagFileData : public PyObject FileFd Fd; }; +// Traversal and Clean for owned objects +int TagFileTraverse(PyObject *self, visitproc visit, void* arg) { + Py_VISIT(((TagFileData *)self)->Section); + return 0; +} + +int TagFileClear(PyObject *self) { + Py_CLEAR(((TagFileData *)self)->Section); + return 0; +} + + /*}}}*/ // TagSecFree - Free a Tag Section /*{{{*/ // --------------------------------------------------------------------- @@ -55,7 +67,7 @@ void TagSecFree(PyObject *Obj) { TagSecData *Self = (TagSecData *)Obj; delete [] Self->Data; - CppDealloc(Obj); + CppOwnedDealloc(Obj); } /*}}}*/ // TagFileFree - Free a Tag File /*{{{*/ @@ -63,8 +75,11 @@ void TagSecFree(PyObject *Obj) /* */ void TagFileFree(PyObject *Obj) { + #ifdef ALLOC_DEBUG + std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << "^ ===\n"; + #endif TagFileData *Self = (TagFileData *)Obj; - Py_DECREF((PyObject *)Self->Section); + TagFileClear(Obj); Self->Object.~pkgTagFile(); Self->Fd.~FileFd(); Py_DECREF(Self->File); @@ -298,6 +313,8 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) // Create the section New->Section = (TagSecData*)(&TagSecType)->tp_alloc(&TagSecType, 0); new (&New->Section->Object) pkgTagSection(); + New->Section->Owner = New; + Py_INCREF(New->Section->Owner); New->Section->Data = 0; return HandleErrors(New); @@ -441,10 +458,11 @@ PyTypeObject TagSecType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_TagSec, // tp_doc - 0, // tp_traverse - 0, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -529,10 +547,11 @@ PyTypeObject TagFileType = 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags - Py_TPFLAGS_BASETYPE), + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC), doc_TagFile, // tp_doc - 0, // tp_traverse - 0, // tp_clear + TagFileTraverse, // tp_traverse + TagFileClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter -- cgit v1.2.3 From b426f959e7e515d5f267558b6ae51ed9ae03fb9d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 14:54:31 +0200 Subject: Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to mark a package as automatically installed. --- apt/package.py | 13 +++++++++++++ debian/changelog | 4 +++- python/depcache.cc | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'python/depcache.cc') diff --git a/apt/package.py b/apt/package.py index cb99fe6a..39a73c07 100644 --- a/apt/package.py +++ b/apt/package.py @@ -846,6 +846,10 @@ class Package(object): return self.is_installed and \ self._pcache._depcache.is_garbage(self._pkg) + @property + def is_auto_installed(self): + """Return whether the package is marked as automatically installed.""" + return self._pcache._depcache.is_auto_installed(self._pkg) # sizes @DeprecatedProperty @@ -1135,6 +1139,15 @@ class Package(object): sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " "'%s'\n") % self._pkg.name) + def mark_auto(self, auto=True): + """Mark a package as automatically installed. + + Call this function to mark a package as automatically installed. If the + optional parameter *auto* is set to ``False``, the package will not be + marked as automatically installed anymore. The default is ``True``. + """ + self._pcache._depcache.mark_auto(self._pkg, auto) + def commit(self, fprogress, iprogress): """Commit the changes. diff --git a/debian/changelog b/debian/changelog index 4fb6b0de..f0b3efbe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low properties (Closes: #532338) * apt/cache.py: Correctly handle rootdir on second and later invocations of open() (LP: #320665). + * Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to + mark a package as automatically installed. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -28,7 +30,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 15 Jun 2009 14:45:06 +0200 + -- Julian Andres Klode Mon, 22 Jun 2009 14:38:19 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/depcache.cc b/python/depcache.cc index d0b233b8..e1514300 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -367,6 +367,23 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static PyObject *PkgDepCacheMarkAuto(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp(Self); + + PyObject *PackageObj; + char value = 0; + if (PyArg_ParseTuple(Args,"O!b",&PackageType,&PackageObj, &value) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); + depcache->MarkAuto(Pkg,value); + + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} + + static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) { pkgDepCache *depcache = GetCpp(Self); @@ -541,6 +558,7 @@ static PyMethodDef PkgDepCacheMethods[] = {"mark_keep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, {"mark_delete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, {"mark_install",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, + {"mark_auto",PkgDepCacheMarkAuto,METH_VARARGS,"mark_auto(pkg: apt_pkg.Package, auto: bool)\n\nMark package as automatically installed."}, {"set_reinstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, // state information {"is_upgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, -- cgit v1.2.3 From a4e69e11e544844034c3fbdc6789d5573f802117 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 25 Jun 2009 18:31:00 +0200 Subject: python: Fix some build warnings. --- python/acquire.cc | 4 ++-- python/cache.cc | 9 ++++----- python/depcache.cc | 3 --- python/indexfile.cc | 2 +- python/pkgsrcrecords.cc | 1 - python/progress.cc | 2 -- python/tar.cc | 4 ++++ setup.py | 4 ++-- 8 files changed, 13 insertions(+), 16 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index e13e47d6..a36012bc 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -93,8 +93,8 @@ static PyObject *AcquireItemRepr(PyObject *Self) char S[300]; snprintf(S,sizeof(S),"<%s object: " "Status: %i Complete: %i Local: %i IsTrusted: %i " - "FileSize: %i DestFile:'%s' " - "DescURI: '%s' ID:%i ErrorText: '%s'>", + "FileSize: %lu DestFile:'%s' " + "DescURI: '%s' ID:%lu ErrorText: '%s'>", Self->ob_type->tp_name, Itm->Status, Itm->Complete, Itm->Local, Itm->IsTrusted(), Itm->FileSize, Itm->DestFile.c_str(), Itm->DescURI().c_str(), diff --git a/python/cache.cc b/python/cache.cc index 2de9c76a..0f5e27eb 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -76,9 +76,6 @@ static PyObject *CreateProvides(PyObject *Owner,pkgCache::PrvIterator I) // --------------------------------------------------------------------- static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) { - PyObject *CacheFilePy = GetOwner(Self); - pkgCacheFile *Cache = GetCpp(CacheFilePy); - PyObject *pyFetchProgressInst = 0; PyObject *pySourcesList = 0; if (PyArg_ParseTuple(Args, "OO", &pyFetchProgressInst,&pySourcesList) == 0) @@ -93,6 +90,7 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) return HandleErrors(PyRes); } +#ifdef COMPAT_0_7 static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, " @@ -137,7 +135,7 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) Py_INCREF(Py_None); return HandleErrors(Py_None); } - +#endif static PyMethodDef PkgCacheMethods[] = { @@ -456,10 +454,10 @@ PyTypeObject PkgListType = CppOwnedClear, // tp_clear }; +#define Owner (GetOwner(Self)) #define MkGet(PyFunc,Ret) static PyObject *PyFunc(PyObject *Self,void*) \ { \ pkgCache::PkgIterator &Pkg = GetCpp(Self); \ - PyObject *Owner = GetOwner(Self); \ return Ret; \ } @@ -477,6 +475,7 @@ MkGet(PackageGetAuto,Py_BuildValue("i",(Pkg->Flags & pkgCache::Flag::Auto) != 0) MkGet(PackageGetEssential,Py_BuildValue("i",(Pkg->Flags & pkgCache::Flag::Essential) != 0)); MkGet(PackageGetImportant,Py_BuildValue("i",(Pkg->Flags & pkgCache::Flag::Important) != 0)); #undef MkGet +#undef Owner static PyObject *PackageGetVersionList(PyObject *Self,void*) { diff --git a/python/depcache.cc b/python/depcache.cc index e1514300..9c0c9a6f 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -62,8 +62,6 @@ static PyObject *PkgDepCacheInit(PyObject *Self,PyObject *Args) static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) { - PyObject *result; - pkgDepCache *depcache = GetCpp(Self); PyObject *pyInstallProgressInst = 0; @@ -196,7 +194,6 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) &VersionType, &VersionObj) == 0) return 0; - pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); pkgCache::VerIterator &I = GetCpp(VersionObj); if(I.end()) { return HandleErrors(Py_BuildValue("b",false)); diff --git a/python/indexfile.cc b/python/indexfile.cc index ef88c2f0..73f76ce6 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -62,7 +62,7 @@ static PyObject *PackageIndexFileRepr(PyObject *Self) char S[1024]; snprintf(S,sizeof(S),"", File->GetType()->Label, File->Describe().c_str(), File->Exists(), File->HasPackages(), File->Size(), diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index f75934f9..9707dce2 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -58,7 +58,6 @@ static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) { PkgSrcRecordsStruct &Struct = GetCpp(Self); - char *Name = 0; if (PyArg_ParseTuple(Args,"") == 0) return 0; diff --git a/python/progress.cc b/python/progress.cc index c5035e62..44f27b0c 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -354,7 +354,6 @@ void PyInstallProgress::FinishUpdate() pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) { - void *dummy; pkgPackageManager::OrderResult res; int ret; pid_t child_id; @@ -426,7 +425,6 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) PyErr_Print(); return pkgPackageManager::Failed; } - int child_res; if(!PyArg_Parse(result, "i", &res) ) { std::cerr << "custom waitChild() result could not be parsed?"<< std::endl; return pkgPackageManager::Failed; diff --git a/python/tar.cc b/python/tar.cc index 217554c2..b93ba31a 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -72,8 +72,12 @@ bool ProcessTar::DoItem(Item &Itm,int &Fd) case Item::FIFO: Type = "FIFO"; break; + + default: + return false; } + if (PyObject_CallFunction(Function,"sssiiiiiii",Type,Itm.Name, Itm.LinkTarget,Itm.Mode,Itm.UID,Itm.GID,Itm.Size, Itm.MTime,Itm.Major,Itm.Minor) == 0) diff --git a/setup.py b/setup.py index 2afd0708..85f4c889 100755 --- a/setup.py +++ b/setup.py @@ -12,12 +12,12 @@ from DistUtilsExtra.command import build_extra, build_i18n # The apt_pkg module files = map(lambda source: "python/"+source, - parse_makefile("python/makefile")["APT_PKG_SRC"].split()) + sorted(parse_makefile("python/makefile")["APT_PKG_SRC"].split())) apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module files = map(lambda source: "python/"+source, - parse_makefile("python/makefile")["APT_INST_SRC"].split()) + sorted(parse_makefile("python/makefile")["APT_INST_SRC"].split())) apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation -- cgit v1.2.3 From e80500e7173387acc7a6b6be9d7424a4343ec036 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 25 Jun 2009 18:53:47 +0200 Subject: python: Use PyVarObject_HEAD_INIT() instead of PyObject_HEAD_INIT(). This is related to PEP 3123 and fixes some compiler warnings. --- python/acquire.cc | 17 ++++------------- python/cache.cc | 45 +++++++++------------------------------------ python/cdrom.cc | 5 +---- python/configuration.cc | 15 +++------------ python/depcache.cc | 15 +++------------ python/generic.h | 1 + python/hashstring.cc | 5 +---- python/indexfile.cc | 5 +---- python/indexrecords.cc | 5 +---- python/metaindex.cc | 5 +---- python/pkgmanager.cc | 5 +---- python/pkgrecords.cc | 5 +---- python/pkgsrcrecords.cc | 5 +---- python/policy.cc | 5 +---- python/sourcelist.cc | 5 +---- python/tag.cc | 12 ++++-------- 16 files changed, 34 insertions(+), 121 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index a36012bc..6c6c2ea4 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -105,10 +105,7 @@ static PyObject *AcquireItemRepr(PyObject *Self) PyTypeObject AcquireItemType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireItem", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -267,10 +264,7 @@ static char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n" PyTypeObject PkgAcquireType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Acquire", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -360,11 +354,8 @@ static char *doc_PkgAcquireFile = PyTypeObject PkgAcquireFileType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif - "apt_pkg.AcquireFile", // tp_name + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_pkg.AcquireFile", // tp_name sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods diff --git a/python/cache.cc b/python/cache.cc index 0f5e27eb..a571788f 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -299,10 +299,7 @@ static char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" static PyMappingMethods CacheMap = {0,CacheMapOp,0}; PyTypeObject PkgCacheType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Cache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -349,10 +346,7 @@ PyTypeObject PkgCacheType = // --------------------------------------------------------------------- PyTypeObject PkgCacheFileType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "pkgCacheFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -425,10 +419,7 @@ static PySequenceMethods PkgListSeq = PyTypeObject PkgListType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageList", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -550,10 +541,7 @@ static PyObject *PackageRepr(PyObject *Self) PyTypeObject PackageType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Package", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -641,10 +629,7 @@ static PyObject *DescriptionRepr(PyObject *Self) PyTypeObject DescriptionType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Description", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -904,10 +889,7 @@ static PyGetSetDef VersionGetSet[] = { PyTypeObject VersionType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Version", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -1068,10 +1050,7 @@ static PyGetSetDef PackageFileGetSet[] = { }; PyTypeObject PackageFileType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -1243,10 +1222,7 @@ static PyGetSetDef DependencyGetSet[] = { PyTypeObject DependencyType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Dependency", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -1331,10 +1307,7 @@ static PySequenceMethods RDepListSeq = PyTypeObject RDepListType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DependencyList", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/cdrom.cc b/python/cdrom.cc index e2651670..492afd90 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -85,10 +85,7 @@ static PyObject *PkgCdromNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) PyTypeObject PkgCdromType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Cdrom", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/configuration.cc b/python/configuration.cc index 9ef5967b..07f55957 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -503,10 +503,7 @@ static PySequenceMethods ConfigurationSeq = {0,0,0,0,0,0,0,CnfContains,0,0}; static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; PyTypeObject ConfigurationType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -550,10 +547,7 @@ PyTypeObject ConfigurationType = PyTypeObject ConfigurationPtrType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ConfigurationPtr", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -589,10 +583,7 @@ PyTypeObject ConfigurationPtrType = PyTypeObject ConfigurationSubType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ConfigurationSub", // tp_name sizeof(SubConfiguration), // tp_basicsize 0, // tp_itemsize diff --git a/python/depcache.cc b/python/depcache.cc index 9c0c9a6f..2ce7a595 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -667,10 +667,7 @@ static char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" "The parameter *cache* refers to an apt_pkg.Cache() object."; PyTypeObject PkgDepCacheType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -858,10 +855,7 @@ static PyMethodDef PkgProblemResolverMethods[] = PyTypeObject PkgProblemResolverType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ProblemResolver", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -977,10 +971,7 @@ static char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" PyTypeObject PkgActionGroupType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ActionGroup", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/generic.h b/python/generic.h index 182b1b53..118917cb 100644 --- a/python/generic.h +++ b/python/generic.h @@ -63,6 +63,7 @@ typedef int Py_ssize_t; #define PyBytes_Check PyString_Check #define PyBytes_AsString PyString_AsString #define PyBytes_AsStringAndSize PyString_AsStringAndSize +#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, #endif #endif diff --git a/python/hashstring.cc b/python/hashstring.cc index 23212a4b..6f70ac7e 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -95,10 +95,7 @@ static char *HashString_doc = " HashString('MD5Sum', '6cc1b6e6655e3555ac47e5b5fe26d04e')\n\n" "Valid options for 'type' are: MD5Sum, SHA1, SHA256."; PyTypeObject PyHashString_Type = { - PyObject_HEAD_INIT(&PyType_Type) -#if PY_MAJOR_VERSION < 3 - 0, // ob_size -#endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.HashString", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/indexfile.cc b/python/indexfile.cc index 73f76ce6..5b526b87 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -90,10 +90,7 @@ static PyGetSetDef PackageIndexFileGetSet[] = { PyTypeObject PackageIndexFileType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageIndexFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/indexrecords.cc b/python/indexrecords.cc index fcb2b85d..588cf883 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -81,10 +81,7 @@ static PyMethodDef IndexRecords_Methods[] = { static char *IndexRecords_doc = "IndexRecords()\n\n" "Representation of a release file."; PyTypeObject PyIndexRecords_Type = { - PyObject_HEAD_INIT(&PyType_Type) -#if PY_MAJOR_VERSION < 3 - 0, // ob_size -#endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.IndexRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/metaindex.cc b/python/metaindex.cc index b5d194b4..87b1e59a 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -72,10 +72,7 @@ static PyObject *MetaIndexRepr(PyObject *Self) PyTypeObject MetaIndexType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.MetaIndex", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 668f7cfc..9e9cc32d 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -133,10 +133,7 @@ static PyGetSetDef PkgManagerGetSet[] = { PyTypeObject PkgManagerType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageManager", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 4a3c80db..886bdb58 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -163,10 +163,7 @@ static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) PyTypeObject PkgRecordsType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 9707dce2..187050b7 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -204,10 +204,7 @@ static PyObject *PkgSrcRecordsNew(PyTypeObject *type,PyObject *args,PyObject *kw PyTypeObject PkgSrcRecordsType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.SourceRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/policy.cc b/python/policy.cc index 5150af91..91ed5454 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -143,10 +143,7 @@ static char *Policy_doc = "Policy(cache)\n\n" "may be some cases where a special policy class is needed."; PyTypeObject PyPolicy_Type = { - PyObject_HEAD_INIT(&PyType_Type) -#if PY_MAJOR_VERSION < 3 - 0, // ob_size -#endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Policy", // tp_name sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 2cf5eea9..0820d5bf 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -115,10 +115,7 @@ static PyObject *PkgSourceListNew(PyTypeObject *type,PyObject *args,PyObject *kw PyTypeObject PkgSourceListType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.SourceList", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/tag.cc b/python/tag.cc index 1ad0a465..2b71517d 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -175,6 +175,7 @@ static PyObject *TagSecKeys(PyObject *Self,PyObject *Args) return List; } +#if PY_MAJOR_VERSION < 3 static char *doc_Exists = "Exists(Name) -> integer"; static PyObject *TagSecExists(PyObject *Self,PyObject *Args) { @@ -188,6 +189,7 @@ static PyObject *TagSecExists(PyObject *Self,PyObject *Args) return Py_BuildValue("i",0); return Py_BuildValue("i",1); } +#endif static int TagSecContains(PyObject *Self,PyObject *Arg) { @@ -436,10 +438,7 @@ static char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n" "to the functions provided by the C++ class (e.g. Find)"; PyTypeObject TagSecType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize @@ -525,10 +524,7 @@ static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" // Type for a Tag File PyTypeObject TagFileType = { - PyObject_HEAD_INIT(&PyType_Type) - #if PY_MAJOR_VERSION < 3 - 0, // ob_size - #endif + PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.TagFile", // tp_name sizeof(TagFileData), // tp_basicsize 0, // tp_itemsize -- cgit v1.2.3 From 3c8959ed35b026ae57600c7f0b2ed531a98c7c0b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 11 Jul 2009 21:16:11 +0200 Subject: python/depcache.cc: Introduce DepCache.policy property. This property allows you to access the Policy of the DepCache. --- python/depcache.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/depcache.cc') diff --git a/python/depcache.cc b/python/depcache.cc index 2ce7a595..17e2bc30 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -621,6 +621,18 @@ static PyObject *PkgDepCacheGetDebSize(PyObject *Self,void*) { } #undef depcache +static PyObject *PkgDepCacheGetPolicy(PyObject *Self,void*) { + PyObject *Owner = GetOwner(Self); + pkgDepCache *DepCache = GetCpp(Self); + pkgPolicy *Policy = (pkgPolicy *)&DepCache->GetPolicy(); + CppOwnedPyObject *PyPolicy = + CppOwnedPyObject_NEW(Owner,&PyPolicy_Type,Policy); + // Policy should not be deleted, it is managed by CacheFile. + PyPolicy->NoDelete = true; + return PyPolicy; +} + + static PyGetSetDef PkgDepCacheGetSet[] = { {"broken_count",PkgDepCacheGetBrokenCount}, {"deb_size",PkgDepCacheGetDebSize}, @@ -628,6 +640,7 @@ static PyGetSetDef PkgDepCacheGetSet[] = { {"inst_count",PkgDepCacheGetInstCount}, {"keep_count",PkgDepCacheGetKeepCount}, {"usr_size",PkgDepCacheGetUsrSize}, + {"policy",PkgDepCacheGetPolicy}, #ifdef COMPAT_0_7 {"BrokenCount",PkgDepCacheGetBrokenCount}, {"DebSize",PkgDepCacheGetDebSize}, -- cgit v1.2.3 From 9150e644afe9fa51d61f31054b3a1990034b0e18 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 12 Jul 2009 12:48:22 +0200 Subject: python/depcache.cc: Set NoDelete for DepCaches, instead of using the wrong dealloc function. --- python/depcache.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/depcache.cc b/python/depcache.cc index 17e2bc30..68ca3a3b 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -670,9 +670,11 @@ static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds CppOwnedPyObject *DepCachePyObj; DepCachePyObj = CppOwnedPyObject_NEW(Owner,type,depcache); - HandleErrors(DepCachePyObj); - return DepCachePyObj; + // Do not delete the underlying pointer, it is managed by the cachefile. + DepCachePyObj->NoDelete = true; + + return HandleErrors(DepCachePyObj); } static char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" @@ -685,8 +687,7 @@ PyTypeObject PkgDepCacheType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - // Not ..Ptr, because the pkgDepCache pointer is managed by the CacheFile. - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr -- cgit v1.2.3 From dabc8c6796afdaf0e2918db77117a07eae8b1fd4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Jul 2009 14:25:06 +0200 Subject: python: Rename all PyTypeObject's to conform to PEP 7. This is the first step towards implementing coding guidelines for the C++ code and providing an usable C++ API. --- python/acquire.cc | 18 +++++++------- python/apt_pkgmodule.cc | 62 +++++++++++++++++++++++------------------------ python/apt_pkgmodule.h | 60 +++++++++++++++++++++++----------------------- python/cache.cc | 60 +++++++++++++++++++++++----------------------- python/cdrom.cc | 4 ++-- python/configuration.cc | 16 ++++++------- python/depcache.cc | 64 ++++++++++++++++++++++++------------------------- python/indexfile.cc | 2 +- python/metaindex.cc | 4 ++-- python/pkgmanager.cc | 12 +++++----- python/pkgrecords.cc | 8 +++---- python/pkgsrcrecords.cc | 6 ++--- python/policy.cc | 12 +++++----- python/sourcelist.cc | 14 +++++------ python/tag.cc | 12 +++++----- 15 files changed, 177 insertions(+), 177 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 054956ea..4329e790 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -140,7 +140,7 @@ static void AcquireItemDealloc(PyObject *self) { -PyTypeObject AcquireItemType = +PyTypeObject PyAcquireItem_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireItem", // tp_name @@ -238,7 +238,7 @@ static PyObject *PkgAcquireGetItems(PyObject *Self,void*) I != fetcher->ItemsEnd(); I++) { PyAcquireItemObject *Obj; - Obj = CppOwnedPyObject_NEW(Self,&AcquireItemType,*I); + Obj = CppOwnedPyObject_NEW(Self,&PyAcquireItem_Type,*I); Obj->NoDelete = true; PyList_Append(List,Obj); ((PyAcquireObject *)Self)->items.push_back(Obj); @@ -305,7 +305,7 @@ static char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n" "specify a apt.progress.FetchProgress() object, which will display the\n" "progress of the fetching."; -PyTypeObject PkgAcquireType = +PyTypeObject PyAcquire_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Acquire", // tp_name @@ -354,7 +354,7 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated." " Please see apt_pkg.Acquire() for the replacement.", 1); - return PkgAcquireNew(&PkgAcquireType,Args,0); + return PkgAcquireNew(&PyAcquire_Type,Args,0); } #endif @@ -369,7 +369,7 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject "destdir", "destfile", NULL}; if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, - &PkgAcquireType, &pyfetcher, &uri, &md5, + &PyAcquire_Type, &pyfetcher, &uri, &md5, &size, &descr, &shortDescr, &destDir, &destFile) == 0) return 0; @@ -397,7 +397,7 @@ static char *doc_PkgAcquireFile = "The parameter *owner* refers to an apt_pkg.Acquire() object. You can use\n" "*destdir* OR *destfile* to specify the destination directory/file."; -PyTypeObject PkgAcquireFileType = +PyTypeObject PyAcquireFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireFile", // tp_name @@ -432,7 +432,7 @@ PyTypeObject PkgAcquireFileType = 0, // tp_methods 0, // tp_members 0, // tp_getset - &AcquireItemType, // tp_base + &PyAcquireItem_Type, // tp_base 0, // tp_dict 0, // tp_descr_get 0, // tp_descr_set @@ -459,7 +459,7 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) "destDir", "destFile", NULL}; if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, - &PkgAcquireType, &pyfetcher, &uri, &md5, + &PyAcquire_Type, &pyfetcher, &uri, &md5, &size, &descr, &shortDescr, &destDir, &destFile) == 0) return 0; @@ -472,7 +472,7 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) shortDescr, destDir, destFile); // short-desc - CppPyObject *AcqFileObj = CppPyObject_NEW(&PkgAcquireFileType); + CppPyObject *AcqFileObj = CppPyObject_NEW(&PyAcquireFile_Type); AcqFileObj->Object = af; AcqFileObj->NoDelete = true; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 4c0fd5ed..d236820a 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -36,7 +36,7 @@ static PyObject *newConfiguration(PyObject *self,PyObject *args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " "deprecated. Use apt_pkg.Configuration() instead.", 1); - return CppPyObject_NEW(&ConfigurationType); + return CppPyObject_NEW(&PyConfiguration_Type); } #endif /*}}}*/ @@ -556,9 +556,9 @@ extern "C" void initapt_pkg() #endif { // Finalize our types to add slots, etc. - if (PyType_Ready(&ConfigurationPtrType) == -1) INIT_ERROR; - if (PyType_Ready(&ConfigurationSubType) == -1) INIT_ERROR; - if (PyType_Ready(&PkgCacheFileType) == -1) INIT_ERROR; + if (PyType_Ready(&PyConfigurationPtr_Type) == -1) INIT_ERROR; + if (PyType_Ready(&PyConfigurationSub_Type) == -1) INIT_ERROR; + if (PyType_Ready(&PyCacheFile_Type) == -1) INIT_ERROR; // Initialize the module #if PY_MAJOR_VERSION >= 3 @@ -568,7 +568,7 @@ extern "C" void initapt_pkg() #endif // Global variable linked to the global configuration class - CppPyObject *Config = CppPyObject_NEW(&ConfigurationPtrType); + CppPyObject *Config = CppPyObject_NEW(&PyConfigurationPtr_Type); Config->Object = _config; PyModule_AddObject(Module,"config",Config); #ifdef COMPAT_0_7 @@ -578,43 +578,43 @@ extern "C" void initapt_pkg() // Add our classes. /* ============================ tag.cc ============================ */ - ADDTYPE(Module,"TagSection",&TagSecType); - ADDTYPE(Module,"TagFile",&TagFileType); + ADDTYPE(Module,"TagSection",&PyTagSection_Type); + ADDTYPE(Module,"TagFile",&PyTagFile_Type); /* ============================ acquire.cc ============================ */ - ADDTYPE(Module,"Acquire",&PkgAcquireType); - ADDTYPE(Module,"AcquireFile",&PkgAcquireFileType); - ADDTYPE(Module,"AcquireItem",&AcquireItemType); // NO __new__() + ADDTYPE(Module,"Acquire",&PyAcquire_Type); + ADDTYPE(Module,"AcquireFile",&PyAcquireFile_Type); + ADDTYPE(Module,"AcquireItem",&PyAcquireItem_Type); // NO __new__() /* ============================ cache.cc ============================ */ - ADDTYPE(Module,"Cache",&PkgCacheType); - ADDTYPE(Module,"Dependency",&DependencyType); // NO __new__() - ADDTYPE(Module,"Description",&DescriptionType); // NO __new__() - ADDTYPE(Module,"PackageFile",&PackageFileType); // NO __new__() - ADDTYPE(Module,"PackageList",&PkgListType); // NO __new__(), internal - ADDTYPE(Module,"DependencyList",&RDepListType); // NO __new__(), internal - ADDTYPE(Module,"Package",&PackageType); // NO __new__() - ADDTYPE(Module,"Version",&VersionType); // NO __new__() + ADDTYPE(Module,"Cache",&PyCache_Type); + ADDTYPE(Module,"Dependency",&PyDependency_Type); // NO __new__() + ADDTYPE(Module,"Description",&PyDescription_Type); // NO __new__() + ADDTYPE(Module,"PackageFile",&PyPackageFile_Type); // NO __new__() + ADDTYPE(Module,"PackageList",&PyPackageList_Type); // NO __new__(), internal + ADDTYPE(Module,"DependencyList",&PyDependencyList_Type); // NO __new__(), internal + ADDTYPE(Module,"Package",&PyPackage_Type); // NO __new__() + ADDTYPE(Module,"Version",&PyVersion_Type); // NO __new__() /* ============================ cdrom.cc ============================ */ - ADDTYPE(Module,"Cdrom",&PkgCdromType); + ADDTYPE(Module,"Cdrom",&PyCdrom_Type); /* ========================= configuration.cc ========================= */ - ADDTYPE(Module,"Configuration",&ConfigurationType); - //ADDTYPE(Module,"ConfigurationSub",&ConfigurationSubType); // NO __new__() - //ADDTYPE(Module,"ConfigurationPtr",&ConfigurationPtrType); // NO __new__() + ADDTYPE(Module,"Configuration",&PyConfiguration_Type); + //ADDTYPE(Module,"ConfigurationSub",&PyConfigurationSub_Type); // NO __new__() + //ADDTYPE(Module,"ConfigurationPtr",&PyConfigurationPtr_Type); // NO __new__() /* ========================= depcache.cc ========================= */ - ADDTYPE(Module,"ActionGroup",&PkgActionGroupType); - ADDTYPE(Module,"DepCache",&PkgDepCacheType); - ADDTYPE(Module,"ProblemResolver",&PkgProblemResolverType); + ADDTYPE(Module,"ActionGroup",&PyActionGroup_Type); + ADDTYPE(Module,"DepCache",&PyDepCache_Type); + ADDTYPE(Module,"ProblemResolver",&PyProblemResolver_Type); /* ========================= indexfile.cc ========================= */ - ADDTYPE(Module,"PackageIndexFile",&PackageIndexFileType); // NO __new__() + ADDTYPE(Module,"PackageIndexFile",&PyPackageIndexFile_Type); // NO __new__() /* ========================= metaindex.cc ========================= */ - ADDTYPE(Module,"MetaIndex",&MetaIndexType); // NO __new__() + ADDTYPE(Module,"MetaIndex",&PyMetaIndex_Type); // NO __new__() /* ========================= pkgmanager.cc ========================= */ - ADDTYPE(Module,"PackageManager",&PkgManagerType); + ADDTYPE(Module,"PackageManager",&PyPackageManager_Type); /* ========================= pkgrecords.cc ========================= */ - ADDTYPE(Module,"PackageRecords",&PkgRecordsType); + ADDTYPE(Module,"PackageRecords",&PyPackageRecords_Type); /* ========================= pkgsrcrecords.cc ========================= */ - ADDTYPE(Module,"SourceRecords",&PkgSrcRecordsType); + ADDTYPE(Module,"SourceRecords",&PySourceRecords_Type); /* ========================= sourcelist.cc ========================= */ - ADDTYPE(Module,"SourceList",&PkgSourceListType); + ADDTYPE(Module,"SourceList",&PySourceList_Type); ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); ADDTYPE(Module,"HashString",&PyHashString_Type); ADDTYPE(Module,"Policy",&PyPolicy_Type); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 1a2f1a1a..7b835ca8 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -14,13 +14,13 @@ #include // Configuration Stuff -#define Configuration_Check(op) ((op)->ob_type == &ConfigurationType || \ - (op)->ob_type == &ConfigurationPtrType || \ - (op)->ob_type == &ConfigurationSubType) -extern PyTypeObject ConfigurationType; -extern PyTypeObject ConfigurationPtrType; -extern PyTypeObject ConfigurationSubType; -extern PyTypeObject VersionType; +#define Configuration_Check(op) ((op)->ob_type == &PyConfiguration_Type || \ + (op)->ob_type == &PyConfigurationPtr_Type || \ + (op)->ob_type == &PyConfigurationSub_Type) +extern PyTypeObject PyConfiguration_Type; +extern PyTypeObject PyConfigurationPtr_Type; +extern PyTypeObject PyConfigurationSub_Type; +extern PyTypeObject PyVersion_Type; extern char *doc_LoadConfig; extern char *doc_LoadConfigISC; @@ -32,8 +32,8 @@ PyObject *LoadConfigDir(PyObject *Self,PyObject *Args); PyObject *ParseCommandLine(PyObject *Self,PyObject *Args); // Tag File Stuff -extern PyTypeObject TagSecType; -extern PyTypeObject TagFileType; +extern PyTypeObject PyTagSection_Type; +extern PyTypeObject PyTagFile_Type; extern char *doc_ParseSection; extern char *doc_ParseTagFile; extern char *doc_RewriteSection; @@ -54,58 +54,58 @@ PyObject *StrStrToTime(PyObject *self,PyObject *Args); PyObject *StrCheckDomainList(PyObject *Self,PyObject *Args); // Cache Stuff -extern PyTypeObject PkgCacheType; -extern PyTypeObject PkgCacheFileType; -extern PyTypeObject PkgListType; -extern PyTypeObject DescriptionType; -extern PyTypeObject PackageType; -extern PyTypeObject PackageFileType; -extern PyTypeObject DependencyType; -extern PyTypeObject RDepListType; +extern PyTypeObject PyCache_Type; +extern PyTypeObject PyCacheFile_Type; +extern PyTypeObject PyPackageList_Type; +extern PyTypeObject PyDescription_Type; +extern PyTypeObject PyPackage_Type; +extern PyTypeObject PyPackageFile_Type; +extern PyTypeObject PyDependency_Type; +extern PyTypeObject PyDependencyList_Type; PyObject *TmpGetCache(PyObject *Self,PyObject *Args); // DepCache -extern PyTypeObject PkgDepCacheType; +extern PyTypeObject PyDepCache_Type; PyObject *GetDepCache(PyObject *Self,PyObject *Args); // pkgProblemResolver -extern PyTypeObject PkgProblemResolverType; +extern PyTypeObject PyProblemResolver_Type; PyObject *GetPkgProblemResolver(PyObject *Self, PyObject *Args); PyObject *GetPkgActionGroup(PyObject *Self, PyObject *Args); -extern PyTypeObject PkgActionGroupType; +extern PyTypeObject PyActionGroup_Type; // cdrom -extern PyTypeObject PkgCdromType; +extern PyTypeObject PyCdrom_Type; PyObject *GetCdrom(PyObject *Self,PyObject *Args); // acquire -extern PyTypeObject AcquireItemType; -extern PyTypeObject PkgAcquireType; -extern PyTypeObject PkgAcquireFileType; +extern PyTypeObject PyAcquireItem_Type; +extern PyTypeObject PyAcquire_Type; +extern PyTypeObject PyAcquireFile_Type; extern char *doc_GetPkgAcqFile; PyObject *GetAcquire(PyObject *Self,PyObject *Args); PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject *kwds); // packagemanager -extern PyTypeObject PkgManagerType; +extern PyTypeObject PyPackageManager_Type; PyObject *GetPkgManager(PyObject *Self,PyObject *Args); // PkgRecords Stuff -extern PyTypeObject PkgRecordsType; -extern PyTypeObject PkgSrcRecordsType; +extern PyTypeObject PyPackageRecords_Type; +extern PyTypeObject PySourceRecords_Type; PyObject *GetPkgRecords(PyObject *Self,PyObject *Args); PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args); // pkgSourceList -extern PyTypeObject PkgSourceListType; +extern PyTypeObject PySourceList_Type; PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args); // pkgSourceList -extern PyTypeObject PackageIndexFileType; +extern PyTypeObject PyPackageIndexFile_Type; // metaIndex -extern PyTypeObject MetaIndexType; +extern PyTypeObject PyMetaIndex_Type; // HashString PyObject *PyHashString_FromCpp(HashString *obj); diff --git a/python/cache.cc b/python/cache.cc index 40d7b18a..d3a8a949 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -62,7 +62,7 @@ static PyObject *CreateProvides(PyObject *Owner,pkgCache::PrvIterator I) { PyObject *Obj; PyObject *Ver; - Ver = CppOwnedPyObject_NEW(Owner,&VersionType, + Ver = CppOwnedPyObject_NEW(Owner,&PyVersion_Type, I.OwnerVer()); Obj = Py_BuildValue("ssN",I.ParentPkg().Name(),I.ProvideVersion(), Ver); @@ -150,7 +150,7 @@ static PyMethodDef PkgCacheMethods[] = static PyObject *PkgCacheGetPackages(PyObject *Self, void*) { pkgCache *Cache = GetCpp(Self); - return CppOwnedPyObject_NEW(Self,&PkgListType,Cache->PkgBegin()); + return CppOwnedPyObject_NEW(Self,&PyPackageList_Type,Cache->PkgBegin()); } static PyObject *PkgCacheGetPackageCount(PyObject *Self, void*) { @@ -188,7 +188,7 @@ static PyObject *PkgCacheGetFileList(PyObject *Self, void*) { for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I.end() == false; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self,&PackageFileType,I); + Obj = CppOwnedPyObject_NEW(Self,&PyPackageFile_Type,I); PyList_Append(List,Obj); Py_DECREF(Obj); } @@ -238,7 +238,7 @@ static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) return 0; } - return CppOwnedPyObject_NEW(Self,&PackageType,Pkg); + return CppOwnedPyObject_NEW(Self,&PyPackage_Type,Pkg); } static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) @@ -279,7 +279,7 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) } CppOwnedPyObject *CacheFileObj = - CppOwnedPyObject_NEW(0,&PkgCacheFileType, Cache); + CppOwnedPyObject_NEW(0,&PyCacheFile_Type, Cache); CppOwnedPyObject *CacheObj = CppOwnedPyObject_NEW(CacheFileObj,type, @@ -299,7 +299,7 @@ static char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" "If not specified, the progress is displayed in simple text form."; static PyMappingMethods CacheMap = {0,CacheMapOp,0}; -PyTypeObject PkgCacheType = +PyTypeObject PyCache_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Cache", // tp_name @@ -346,7 +346,7 @@ PyTypeObject PkgCacheType = /*}}}*/ // PkgCacheFile Class /*{{{*/ // --------------------------------------------------------------------- -PyTypeObject PkgCacheFileType = +PyTypeObject PyCacheFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "pkgCacheFile", // tp_name @@ -404,7 +404,7 @@ static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) } } - return CppOwnedPyObject_NEW(GetOwner(iSelf),&PackageType, + return CppOwnedPyObject_NEW(GetOwner(iSelf),&PyPackage_Type, Self.Iter); } @@ -419,7 +419,7 @@ static PySequenceMethods PkgListSeq = 0 // assign slice }; -PyTypeObject PkgListType = +PyTypeObject PyPackageList_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageList", // tp_name @@ -457,7 +457,7 @@ PyTypeObject PkgListType = MkGet(PackageGetName,PyString_FromString(Pkg.Name())); MkGet(PackageGetSection,Safe_FromString(Pkg.Section())); MkGet(PackageGetRevDependsList,CppOwnedPyObject_NEW(Owner, - &RDepListType, Pkg.RevDependsList())); + &PyDependencyList_Type, Pkg.RevDependsList())); MkGet(PackageGetProvidesList,CreateProvides(Owner,Pkg.ProvidesList())); MkGet(PackageGetSelectedState,Py_BuildValue("i",Pkg->SelectedState)); MkGet(PackageGetInstState,Py_BuildValue("i",Pkg->InstState)); @@ -479,7 +479,7 @@ static PyObject *PackageGetVersionList(PyObject *Self,void*) for (pkgCache::VerIterator I = Pkg.VersionList(); I.end() == false; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Owner,&VersionType,I); + Obj = CppOwnedPyObject_NEW(Owner,&PyVersion_Type,I); PyList_Append(List,Obj); Py_DECREF(Obj); } @@ -494,7 +494,7 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*) Py_INCREF(Py_None); return Py_None; } - return CppOwnedPyObject_NEW(Owner,&VersionType, + return CppOwnedPyObject_NEW(Owner,&PyVersion_Type, Pkg.CurrentVer()); } @@ -541,7 +541,7 @@ static PyObject *PackageRepr(PyObject *Self) return PyString_FromString(S); } -PyTypeObject PackageType = +PyTypeObject PyPackage_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Package", // tp_name @@ -599,7 +599,7 @@ static PyObject *DescriptionGetFileList(PyObject *Self,void*) { PyObject *DescFile; PyObject *Obj; - DescFile = CppOwnedPyObject_NEW(Owner,&PackageFileType,I.File()); + DescFile = CppOwnedPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); Obj = Py_BuildValue("Nl",DescFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -629,7 +629,7 @@ static PyObject *DescriptionRepr(PyObject *Self) return PyString_FromString(S); } -PyTypeObject DescriptionType = +PyTypeObject PyDescription_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Description", // tp_name @@ -711,7 +711,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, { PyObject *Obj; if (AsObj == true) - Obj = CppOwnedPyObject_NEW(Owner,&DependencyType, + Obj = CppOwnedPyObject_NEW(Owner,&PyDependency_Type, Start); else { @@ -763,7 +763,7 @@ static PyObject *VersionGetFileList(PyObject *Self, void*) { { PyObject *PkgFile; PyObject *Obj; - PkgFile = CppOwnedPyObject_NEW(Owner,&PackageFileType,I.File()); + PkgFile = CppOwnedPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); Obj = Py_BuildValue("Nl",PkgFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -783,7 +783,7 @@ static PyObject *VersionGetDependsList(PyObject *Self, void*) { } static PyObject *VersionGetParentPkg(PyObject *Self, void*) { PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PackageType, + return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, Version_GetVer(Self).ParentPkg()); } static PyObject *VersionGetProvidesList(PyObject *Self, void*) { @@ -815,7 +815,7 @@ static PyObject *VersionGetTranslatedDescription(PyObject *Self, void*) { pkgCache::VerIterator &Ver = GetCpp(Self); PyObject *Owner = GetOwner(Self); return CppOwnedPyObject_NEW(Owner, - &DescriptionType, + &PyDescription_Type, Ver.TranslatedDescription()); } @@ -889,7 +889,7 @@ static PyGetSetDef VersionGetSet[] = { {} }; -PyTypeObject VersionType = +PyTypeObject PyVersion_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Version", // tp_name @@ -1051,7 +1051,7 @@ static PyGetSetDef PackageFileGetSet[] = { {} }; -PyTypeObject PackageFileType = { +PyTypeObject PyPackageFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize @@ -1113,7 +1113,7 @@ static PyObject *DepSmartTargetPkg(PyObject *Self,PyObject *Args) return Py_None; } - return CppOwnedPyObject_NEW(Owner,&PackageType,P); + return CppOwnedPyObject_NEW(Owner,&PyPackage_Type,P); } static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) @@ -1129,7 +1129,7 @@ static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) for (pkgCache::Version **I = Vers; *I != 0; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Owner,&VersionType, + Obj = CppOwnedPyObject_NEW(Owner,&PyVersion_Type, pkgCache::VerIterator(*Dep.Cache(),*I)); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -1163,7 +1163,7 @@ static PyObject *DependencyGetTargetPkg(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PackageType, + return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, Dep.TargetPkg()); } @@ -1171,7 +1171,7 @@ static PyObject *DependencyGetParentVer(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&VersionType, + return CppOwnedPyObject_NEW(Owner,&PyVersion_Type, Dep.ParentVer()); } @@ -1179,7 +1179,7 @@ static PyObject *DependencyGetParentPkg(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PackageType, + return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, Dep.ParentPkg()); } @@ -1222,7 +1222,7 @@ static PyGetSetDef DependencyGetSet[] = { }; -PyTypeObject DependencyType = +PyTypeObject PyDependency_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Dependency", // tp_name @@ -1293,7 +1293,7 @@ static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) } return CppOwnedPyObject_NEW(GetOwner(iSelf), - &DependencyType,Self.Iter); + &PyDependency_Type,Self.Iter); } static PySequenceMethods RDepListSeq = @@ -1307,7 +1307,7 @@ static PySequenceMethods RDepListSeq = 0 // assign slice }; -PyTypeObject RDepListType = +PyTypeObject PyDependencyList_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DependencyList", // tp_name @@ -1343,6 +1343,6 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. " "Please see apt_pkg.Cache() for the replacement.", 1); - return PkgCacheNew(&PkgCacheType,Args,0); + return PkgCacheNew(&PyCache_Type,Args,0); } #endif diff --git a/python/cdrom.cc b/python/cdrom.cc index b5b87758..84d7179f 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -77,7 +77,7 @@ static PyObject *PkgCdromNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) } -PyTypeObject PkgCdromType = +PyTypeObject PyCdrom_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Cdrom", // tp_name @@ -126,7 +126,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. " "Please see apt_pkg.Cdrom() for the replacement.", 1); - return PkgCdromNew(&PkgCdromType,Args,0); + return PkgCdromNew(&PyCdrom_Type,Args,0); } #endif diff --git a/python/configuration.cc b/python/configuration.cc index 07f55957..c7d7d796 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -49,7 +49,7 @@ void CnfSubFree(PyObject *Obj) /* */ static inline Configuration &GetSelf(PyObject *Obj) { - if (Obj->ob_type == &ConfigurationPtrType) + if (Obj->ob_type == &PyConfigurationPtr_Type) return *GetCpp(Obj); return GetCpp(Obj); } @@ -161,8 +161,8 @@ static PyObject *CnfSubTree(PyObject *Self,PyObject *Args) } // Create a new sub configuration. - SubConfiguration *New = (SubConfiguration*)(&ConfigurationSubType) - ->tp_alloc(&ConfigurationSubType,0); + SubConfiguration *New = (SubConfiguration*)(&PyConfigurationSub_Type) + ->tp_alloc(&PyConfigurationSub_Type,0); new (&New->Object) Configuration(Itm); New->Owner = Self; Py_INCREF(Self); @@ -501,7 +501,7 @@ static PyObject *CnfNew(PyTypeObject *type, PyObject *args, PyObject *kwds) { // Type for a Normal Configuration object static PySequenceMethods ConfigurationSeq = {0,0,0,0,0,0,0,CnfContains,0,0}; static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; -PyTypeObject ConfigurationType = +PyTypeObject PyConfiguration_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Configuration", // tp_name @@ -545,7 +545,7 @@ PyTypeObject ConfigurationType = CnfNew, // tp_new }; -PyTypeObject ConfigurationPtrType = +PyTypeObject PyConfigurationPtr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ConfigurationPtr", // tp_name @@ -578,10 +578,10 @@ PyTypeObject ConfigurationPtrType = CnfMethods, // tp_methods 0, // tp_members 0, // tp_getset - &ConfigurationType, // tp_base + &PyConfiguration_Type, // tp_base }; -PyTypeObject ConfigurationSubType = +PyTypeObject PyConfigurationSub_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ConfigurationSub", // tp_name @@ -614,6 +614,6 @@ PyTypeObject ConfigurationSubType = CnfMethods, // tp_methods 0, // tp_members 0, // tp_getset - &ConfigurationType, // tp_base + &PyConfiguration_Type, // tp_base }; diff --git a/python/depcache.cc b/python/depcache.cc index 68ca3a3b..2d72a82a 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -190,8 +190,8 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) PyObject *PackageObj; PyObject *VersionObj; if (PyArg_ParseTuple(Args,"O!O!", - &PackageType, &PackageObj, - &VersionType, &VersionObj) == 0) + &PyPackage_Type, &PackageObj, + &PyVersion_Type, &VersionObj) == 0) return 0; pkgCache::VerIterator &I = GetCpp(VersionObj); @@ -208,7 +208,7 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; PyObject *CandidateObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -219,7 +219,7 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) Py_INCREF(Py_None); return Py_None; } - CandidateObj = CppOwnedPyObject_NEW(PackageObj,&VersionType,I); + CandidateObj = CppOwnedPyObject_NEW(PackageObj,&PyVersion_Type,I); return CandidateObj; } @@ -300,7 +300,7 @@ static PyObject *PkgDepCacheMarkKeep(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -316,7 +316,7 @@ static PyObject *PkgDepCacheSetReInstall(PyObject *Self,PyObject *Args) PyObject *PackageObj; char value = 0; - if (PyArg_ParseTuple(Args,"O!b",&PackageType,&PackageObj, &value) == 0) + if (PyArg_ParseTuple(Args,"O!b",&PyPackage_Type,&PackageObj, &value) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -333,7 +333,7 @@ static PyObject *PkgDepCacheMarkDelete(PyObject *Self,PyObject *Args) PyObject *PackageObj; char purge = 0; - if (PyArg_ParseTuple(Args,"O!|b",&PackageType,&PackageObj, &purge) == 0) + if (PyArg_ParseTuple(Args,"O!|b",&PyPackage_Type,&PackageObj, &purge) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -351,7 +351,7 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) PyObject *PackageObj; char autoInst=1; char fromUser=1; - if (PyArg_ParseTuple(Args,"O!|bb",&PackageType,&PackageObj, + if (PyArg_ParseTuple(Args,"O!|bb",&PyPackage_Type,&PackageObj, &autoInst, &fromUser) == 0) return 0; @@ -370,7 +370,7 @@ static PyObject *PkgDepCacheMarkAuto(PyObject *Self,PyObject *Args) PyObject *PackageObj; char value = 0; - if (PyArg_ParseTuple(Args,"O!b",&PackageType,&PackageObj, &value) == 0) + if (PyArg_ParseTuple(Args,"O!b",&PyPackage_Type,&PackageObj, &value) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -386,7 +386,7 @@ static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -400,7 +400,7 @@ static PyObject *PkgDepCacheIsGarbage(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -414,7 +414,7 @@ static PyObject *PkgDepCacheIsAutoInstalled(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -428,7 +428,7 @@ static PyObject *PkgDepCacheIsNowBroken(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -442,7 +442,7 @@ static PyObject *PkgDepCacheIsInstBroken(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -457,7 +457,7 @@ static PyObject *PkgDepCacheMarkedInstall(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -472,7 +472,7 @@ static PyObject *PkgDepCacheMarkedUpgrade(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -486,7 +486,7 @@ static PyObject *PkgDepCacheMarkedDelete(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -500,7 +500,7 @@ static PyObject *PkgDepCacheMarkedKeep(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -514,7 +514,7 @@ static PyObject *PkgDepCacheMarkedDowngrade(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -528,7 +528,7 @@ static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) pkgDepCache *depcache = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); @@ -656,7 +656,7 @@ static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds { PyObject *Owner; static char *kwlist[] = {"cache", 0}; - if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgCacheType, + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyCache_Type, &Owner) == 0) return 0; @@ -680,7 +680,7 @@ static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds static char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n" "A DepCache() holds extra information on the state of the packages.\n\n" "The parameter *cache* refers to an apt_pkg.Cache() object."; -PyTypeObject PkgDepCacheType = +PyTypeObject PyDepCache_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DepCache", // tp_name @@ -730,7 +730,7 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated" ". Please see apt_pkg.DepCache() for the replacement.",1); - return PkgDepCacheNew(&PkgDepCacheType,Args,0); + return PkgDepCacheNew(&PyDepCache_Type,Args,0); } #endif @@ -745,7 +745,7 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec { PyObject *Owner; static char *kwlist[] = {"depcache",0}; - if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType, + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyDepCache_Type, &Owner) == 0) return 0; @@ -765,7 +765,7 @@ PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is" " deprecated. Please see apt_pkg.ProblemResolver() for the " "replacement.", 1); - return PkgProblemResolverNew(&PkgProblemResolverType,Args,0); + return PkgProblemResolverNew(&PyProblemResolver_Type,Args,0); } #endif @@ -803,7 +803,7 @@ static PyObject *PkgProblemResolverProtect(PyObject *Self,PyObject *Args) { pkgProblemResolver *fixer = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); fixer->Protect(Pkg); @@ -815,7 +815,7 @@ static PyObject *PkgProblemResolverRemove(PyObject *Self,PyObject *Args) { pkgProblemResolver *fixer = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); fixer->Remove(Pkg); @@ -827,7 +827,7 @@ static PyObject *PkgProblemResolverClear(PyObject *Self,PyObject *Args) { pkgProblemResolver *fixer = GetCpp(Self); PyObject *PackageObj; - if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + if (PyArg_ParseTuple(Args,"O!",&PyPackage_Type,&PackageObj) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); fixer->Clear(Pkg); @@ -867,7 +867,7 @@ static PyMethodDef PkgProblemResolverMethods[] = {} }; -PyTypeObject PkgProblemResolverType = +PyTypeObject PyProblemResolver_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ProblemResolver", // tp_name @@ -953,7 +953,7 @@ static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *k { PyObject *Owner; static char *kwlist[] = {"depcache", 0}; - if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType, + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyDepCache_Type, &Owner) == 0) return 0; @@ -983,7 +983,7 @@ static char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" "automatically released from the cache."; -PyTypeObject PkgActionGroupType = +PyTypeObject PyActionGroup_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ActionGroup", // tp_name @@ -1034,7 +1034,7 @@ PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is " "deprecated. Please see apt_pkg.ActionGroup() for the " "replacement.", 1); - return PkgActionGroupNew(&PkgActionGroupType,Args,0); + return PkgActionGroupNew(&PyActionGroup_Type,Args,0); } #endif diff --git a/python/indexfile.cc b/python/indexfile.cc index f2180cd7..7bf646d0 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -88,7 +88,7 @@ static PyGetSetDef PackageIndexFileGetSet[] = { {} }; -PyTypeObject PackageIndexFileType = +PyTypeObject PyPackageIndexFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageIndexFile", // tp_name diff --git a/python/metaindex.cc b/python/metaindex.cc index 195394d6..d67c0ada 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -38,7 +38,7 @@ static PyObject *MetaIndexGetIndexFiles(PyObject *Self,void*) { I != indexFiles->end(); I++) { CppOwnedPyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, &PackageIndexFileType,*I); + Obj = CppOwnedPyObject_NEW(Self, &PyPackageIndexFile_Type,*I); // Do not delete pkgIndexFile*, they are managed by metaIndex. Obj->NoDelete = true; PyList_Append(List,Obj); @@ -73,7 +73,7 @@ static PyObject *MetaIndexRepr(PyObject *Self) return PyString_FromString(S); } -PyTypeObject MetaIndexType = +PyTypeObject PyMetaIndex_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.MetaIndex", // tp_name diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 9e9cc32d..f4f84a2b 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -24,7 +24,7 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; char *kwlist[] = {"depcache",0}; - if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgDepCacheType, + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyDepCache_Type, &Owner) == 0) return 0; @@ -42,7 +42,7 @@ PyObject *GetPkgManager(PyObject *Self,PyObject *Args) PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is " "deprecated. Please see apt_pkg.PackageManager() for the " "replacement.", 1); - return PkgManagerNew(&PkgManagerType,Args,0); + return PkgManagerNew(&PyPackageManager_Type,Args,0); } #endif @@ -53,9 +53,9 @@ static PyObject *PkgManagerGetArchives(PyObject *Self,PyObject *Args) PyObject *fetcher, *list, *recs; if (PyArg_ParseTuple(Args, "O!O!O!", - &PkgAcquireType,&fetcher, - &PkgSourceListType, &list, - &PkgRecordsType, &recs) == 0) + &PyAcquire_Type,&fetcher, + &PySourceList_Type, &list, + &PyPackageRecords_Type, &recs) == 0) return 0; pkgAcquire *s_fetcher = GetCpp(fetcher); @@ -131,7 +131,7 @@ static PyGetSetDef PkgManagerGetSet[] = { {} }; -PyTypeObject PkgManagerType = +PyTypeObject PyPackageManager_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageManager", // tp_name diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 886bdb58..d34ba0d2 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -27,7 +27,7 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) PyObject *PkgFObj; long int Index; - if (PyArg_ParseTuple(Args,"(O!l)",&PackageFileType,&PkgFObj,&Index) == 0) + if (PyArg_ParseTuple(Args,"(O!l)",&PyPackageFile_Type,&PkgFObj,&Index) == 0) return 0; // Get the index and check to make sure it is reasonable @@ -153,7 +153,7 @@ static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; char *kwlist[] = {"cache",0}; - if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgCacheType, + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyCache_Type, &Owner) == 0) return 0; @@ -161,7 +161,7 @@ static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) GetCpp(Owner))); } -PyTypeObject PkgRecordsType = +PyTypeObject PyPackageRecords_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageRecords", // tp_name @@ -215,6 +215,6 @@ PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is " "deprecated. Please see apt_pkg.Records() for the " "replacement.", 1); - return PkgRecordsNew(&PkgRecordsType,Args,0); + return PkgRecordsNew(&PyPackageRecords_Type,Args,0); } #endif diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 99711585..fbc9a293 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -124,7 +124,7 @@ static PyObject *PkgSrcRecordsGetIndex(PyObject *Self,void*) { return 0; const pkgIndexFile &tmp = Struct.Last->Index(); CppOwnedPyObject *PyObj; - PyObj = CppOwnedPyObject_NEW(Self,&PackageIndexFileType, + PyObj = CppOwnedPyObject_NEW(Self,&PyPackageIndexFile_Type, (pkgIndexFile*)&tmp); // Do not delete the pkgIndexFile*, it is managed by PkgSrcRecords::Parser. PyObj->NoDelete=true; @@ -255,7 +255,7 @@ static PyObject *PkgSrcRecordsNew(PyTypeObject *type,PyObject *args,PyObject *kw return HandleErrors(CppPyObject_NEW(type)); } -PyTypeObject PkgSrcRecordsType = +PyTypeObject PySourceRecords_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.SourceRecords", // tp_name @@ -310,6 +310,6 @@ PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"") == 0) return 0; - return HandleErrors(CppPyObject_NEW(&PkgSrcRecordsType)); + return HandleErrors(CppPyObject_NEW(&PySourceRecords_Type)); } #endif diff --git a/python/policy.cc b/python/policy.cc index d086c4fc..faf53b38 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -29,7 +29,7 @@ static PyObject *Policy_NEW(PyTypeObject *type,PyObject *Args, char *kwlist[] = {"cache", NULL}; if (PyArg_ParseTupleAndKeywords(Args, kwds, "O", kwlist, &cache) == 0) return 0; - if (!PyObject_TypeCheck(cache, &PkgCacheType)) { + if (!PyObject_TypeCheck(cache, &PyCache_Type)) { PyErr_SetString(PyExc_TypeError,"`cache` must be a apt_pkg.Cache()."); return 0; } @@ -43,7 +43,7 @@ static char *Policy_GetPriority_doc = "get_priority(package: apt_pkg.Package)" PyObject *Policy_GetPriority(PyObject *self, PyObject *arg) { pkgPolicy *policy = GetCpp(self); - if (PyObject_TypeCheck(arg, &PackageType)) { + if (PyObject_TypeCheck(arg, &PyPackage_Type)) { pkgCache::PkgIterator pkg = GetCpp(arg); return Py_BuildValue("i", policy->GetPriority(pkg)); } else { @@ -57,11 +57,11 @@ static char *Policy_GetCandidateVer_doc = "get_match(package: apt_pkg.Package)" "Get the best package for the job."; PyObject *Policy_GetCandidateVer(PyObject *self, PyObject *arg) { - if (PyObject_TypeCheck(arg, &PackageType)) { + if (PyObject_TypeCheck(arg, &PyPackage_Type)) { pkgPolicy *policy = GetCpp(self); pkgCache::PkgIterator pkg = GetCpp(arg); pkgCache::VerIterator ver = policy->GetCandidateVer(pkg); - return CppOwnedPyObject_NEW(arg,&VersionType, + return CppOwnedPyObject_NEW(arg,&PyVersion_Type, ver); } else { PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); @@ -74,14 +74,14 @@ static char *Policy_GetMatch_doc = "get_match(package: apt_pkg.Package) -> " "Return a matching version for the given package."; static PyObject *Policy_GetMatch(PyObject *self, PyObject *arg) { - if (PyObject_TypeCheck(arg, &PackageType) == 0) { + if (PyObject_TypeCheck(arg, &PyPackage_Type) == 0) { PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); return 0; } pkgPolicy *policy = GetCpp(self); pkgCache::PkgIterator pkg = GetCpp(arg); pkgCache::VerIterator ver = policy->GetMatch(pkg); - return CppOwnedPyObject_NEW(arg,&VersionType,ver); + return CppOwnedPyObject_NEW(arg,&PyVersion_Type,ver); } static char *Policy_ReadPinFile_doc = "read_pinfile(filename: str) -> bool\n\n" diff --git a/python/sourcelist.cc b/python/sourcelist.cc index beb249dc..e86f7fd3 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -28,20 +28,20 @@ static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) PyObject *pyPkgFileIter; CppOwnedPyObject *pyPkgIndexFile; - if (PyArg_ParseTuple(Args, "O!", &PackageFileType,&pyPkgFileIter) == 0) + if (PyArg_ParseTuple(Args, "O!", &PyPackageFile_Type,&pyPkgFileIter) == 0) return 0; pkgCache::PkgFileIterator &i = GetCpp(pyPkgFileIter); pkgIndexFile *index; if(list->FindIndex(i, index)) { - pyPkgIndexFile = CppOwnedPyObject_NEW(pyPkgFileIter,&PackageIndexFileType,index); + pyPkgIndexFile = CppOwnedPyObject_NEW(pyPkgFileIter,&PyPackageIndexFile_Type,index); // Do not delete the pkgIndexFile*, it is managed by pkgSourceList. pyPkgIndexFile->NoDelete = true; return pyPkgIndexFile; } - //&PackageIndexFileType,&pyPkgIndexFile) + //&PyPackageIndexFile_Type,&pyPkgIndexFile) Py_INCREF(Py_None); return Py_None; @@ -63,7 +63,7 @@ static PyObject *PkgSourceListGetIndexes(PyObject *Self,PyObject *Args) PyObject *pyFetcher; char all = 0; - if (PyArg_ParseTuple(Args, "O!|b",&PkgAcquireType,&pyFetcher, &all) == 0) + if (PyArg_ParseTuple(Args, "O!|b",&PyAcquire_Type,&pyFetcher, &all) == 0) return 0; pkgAcquire *fetcher = GetCpp(pyFetcher); @@ -93,7 +93,7 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*) I != list->end(); I++) { CppOwnedPyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, &MetaIndexType,*I); + Obj = CppOwnedPyObject_NEW(Self, &PyMetaIndex_Type,*I); // Never delete metaIndex*, they are managed by the pkgSourceList. Obj->NoDelete = true; PyList_Append(List,Obj); @@ -118,7 +118,7 @@ static PyObject *PkgSourceListNew(PyTypeObject *type,PyObject *args,PyObject *kw return CppPyObject_NEW(type,new pkgSourceList()); } -PyTypeObject PkgSourceListType = +PyTypeObject PySourceList_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.SourceList", // tp_name @@ -168,6 +168,6 @@ PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is " "deprecated. Please see apt_pkg.SourceList() for the " "replacement.", 1); - return PkgSourceListNew(&PkgSourceListType,Args,0); + return PkgSourceListNew(&PySourceList_Type,Args,0); } #endif diff --git a/python/tag.cc b/python/tag.cc index 2b71517d..573e8ce2 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -290,7 +290,7 @@ PyObject *ParseSection(PyObject *self,PyObject *Args) PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is " "deprecated. Please see apt_pkg.TagSection() for the " "replacement.", 1); - return TagSecNew(&TagSecType,Args,0); + return TagSecNew(&PyTagSection_Type,Args,0); } #endif /*}}}*/ @@ -315,7 +315,7 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) new (&New->Object) pkgTagFile(&New->Fd); // Create the section - New->Section = (TagSecData*)(&TagSecType)->tp_alloc(&TagSecType, 0); + New->Section = (TagSecData*)(&PyTagSection_Type)->tp_alloc(&PyTagSection_Type, 0); new (&New->Section->Object) pkgTagSection(); New->Section->Owner = New; Py_INCREF(New->Section->Owner); @@ -329,7 +329,7 @@ PyObject *ParseTagFile(PyObject *self,PyObject *Args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is " "deprecated. Please see apt_pkg.TagFile() for the " "replacement.", 1); - return TagFileNew(&TagFileType,Args,0); + return TagFileNew(&PyTagFile_Type,Args,0); } #endif /*}}}*/ @@ -357,7 +357,7 @@ PyObject *RewriteSection(PyObject *self,PyObject *Args) PyObject *Section; PyObject *Order; PyObject *Rewrite; - if (PyArg_ParseTuple(Args,"O!O!O!",&TagSecType,&Section, + if (PyArg_ParseTuple(Args,"O!O!O!",&PyTagSection_Type,&Section, &PyList_Type,&Order,&PyList_Type,&Rewrite) == 0) return 0; @@ -436,7 +436,7 @@ static char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n" "header sections, like those in debian/control or Packages files.\n\n" "TagSection() behave like read-only dictionaries and also provide access\n" "to the functions provided by the C++ class (e.g. Find)"; -PyTypeObject TagSecType = +PyTypeObject PyTagSection_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.TagSection", // tp_name @@ -522,7 +522,7 @@ static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" "a file descriptor (an integer)"; // Type for a Tag File -PyTypeObject TagFileType = +PyTypeObject PyTagFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.TagFile", // tp_name -- cgit v1.2.3 From 85165f89d3df8ad1c66bd9c842795885c407069e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Jul 2009 17:47:45 +0200 Subject: python: No zero-size arrays for char *kwlist[]. --- python/acquire.cc | 2 +- python/cache.cc | 2 +- python/cdrom.cc | 2 +- python/configuration.cc | 2 +- python/depcache.cc | 6 +++--- python/tag.cc | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'python/depcache.cc') diff --git a/python/acquire.cc b/python/acquire.cc index 4329e790..8b6de173 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -281,7 +281,7 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) pkgAcquire *fetcher; PyObject *pyFetchProgressInst = NULL; - static char *kwlist[] = {"progress", 0}; + char *kwlist[] = {"progress", 0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"|O",kwlist,&pyFetchProgressInst) == 0) return 0; diff --git a/python/cache.cc b/python/cache.cc index d3a8a949..c160cf69 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -244,7 +244,7 @@ static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *pyCallbackInst = 0; - static char *kwlist[] = {"progress", 0}; + char *kwlist[] = {"progress", 0}; if (PyArg_ParseTupleAndKeywords (Args, kwds, "|O", kwlist, &pyCallbackInst) == 0) return 0; diff --git a/python/cdrom.cc b/python/cdrom.cc index 84d7179f..50d1b4b1 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -66,7 +66,7 @@ static PyObject *PkgCdromNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { pkgCdrom *cdrom = new pkgCdrom(); - static char *kwlist[] = {}; + char *kwlist[] = {NULL}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"",kwlist) == 0) return 0; diff --git a/python/configuration.cc b/python/configuration.cc index c7d7d796..ba075133 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -492,7 +492,7 @@ static PyMethodDef CnfMethods[] = }; static PyObject *CnfNew(PyTypeObject *type, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {}; + char *kwlist[] = {NULL}; if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) return 0; return CppPyObject_NEW(type); diff --git a/python/depcache.cc b/python/depcache.cc index 2d72a82a..e78b9f4e 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -655,7 +655,7 @@ static PyGetSetDef PkgDepCacheGetSet[] = { static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; - static char *kwlist[] = {"cache", 0}; + char *kwlist[] = {"cache", 0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyCache_Type, &Owner) == 0) return 0; @@ -744,7 +744,7 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args) static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; - static char *kwlist[] = {"depcache",0}; + char *kwlist[] = {"depcache",0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyDepCache_Type, &Owner) == 0) return 0; @@ -952,7 +952,7 @@ static PyMethodDef PkgActionGroupMethods[] = static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *Owner; - static char *kwlist[] = {"depcache", 0}; + char *kwlist[] = {"depcache", 0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PyDepCache_Type, &Owner) == 0) return 0; diff --git a/python/tag.cc b/python/tag.cc index 573e8ce2..b393effe 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -260,7 +260,7 @@ static PyObject *TagFileJump(PyObject *Self,PyObject *Args) // --------------------------------------------------------------------- static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { char *Data; - static char *kwlist[] = {"text", 0}; + char *kwlist[] = {"text", 0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"s",kwlist,&Data) == 0) return 0; @@ -301,7 +301,7 @@ PyObject *ParseSection(PyObject *self,PyObject *Args) static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *File; - static char *kwlist[] = {"file", 0}; + char *kwlist[] = {"file", 0}; if (PyArg_ParseTupleAndKeywords(Args,kwds,"O",kwlist,&File) == 0) return 0; int fileno = PyObject_AsFileDescriptor(File); -- cgit v1.2.3