From 18e9800bb962072e79e99f8fb1a29692919596ee Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Oct 2009 19:06:49 +0100 Subject: * python/progress.cc: - if the mediaChange() does not return anything or is not implemented send "false" to libapt --- python/progress.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/progress.cc b/python/progress.cc index b3e06b87..82967687 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -104,11 +104,10 @@ bool PyFetchProgress::MediaChange(string Media, string Drive) RunSimpleCallback("mediaChange", arglist, &result); bool res = true; - if(!PyArg_Parse(result, "b", &res)) - std::cerr << "result could not be parsed" << std::endl; - - // FIXME: find out what it should return usually - //std::cerr << "res is: " << res << std::endl; + if(!PyArg_Parse(result, "b", &res)) { + // no return value or None, assume false + return false; + } PyCbObj_BEGIN_ALLOW_THREADS return res; -- cgit v1.2.3 From 06bc637621014289a812d48a5c479dfe699527f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Jan 2010 12:12:50 +0100 Subject: * python/cache.cc: - add UntranslatedDepType attribute to DependencyType - add DepTypeEnum that returns a value from {DepDepends, DepPreDepends, ...} * python/apt_pkgmodule.cc: - add DepDpkgBreaks, DepEnhances constants * doc/source/apt_pkg/{cache.rst, index.rst}: - update documentation as well --- debian/changelog | 8 ++++++++ doc/source/apt_pkg/cache.rst | 9 +++++++++ doc/source/apt_pkg/index.rst | 3 +++ python/apt_pkgmodule.cc | 2 ++ python/cache.cc | 27 ++++++++++++++++----------- 5 files changed, 38 insertions(+), 11 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index ba5dd918..d6d19bbf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,14 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low - add "enhances" property * data/templates/Ubuntu.info.in: - add lucid + * python/cache.cc: + - add UntranslatedDepType attribute to DependencyType + - add DepTypeEnum that returns a value from + {DepDepends, DepPreDepends, ...} + * python/apt_pkgmodule.cc: + - add DepDpkgBreaks, DepEnhances constants + * doc/source/apt_pkg/{cache.rst, index.rst}: + - update documentation as well -- Michael Vogt Wed, 02 Dec 2009 16:50:55 +0100 diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index 334b7869..1be81b42 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -596,8 +596,17 @@ Example: .. attribute:: DepType + The type of the dependency, as translated string, eg. "Depends". + + .. attribute:: UntranslatedDepType + The type of the dependency, as string, eg. "Depends". + .. attribute:: DepTypeEnum + + The type of the dependency, as integer that matches a value + of `Dependency types`_ + .. attribute:: ID The ID of the package, as integer. diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index 6e7b772e..aba7d82e 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -336,12 +336,15 @@ Dependency types ^^^^^^^^^^^^^^^^ .. data:: DepConflicts .. data:: DepDepends +.. data:: DepDpkgBreaks +.. data:: DepEnhances .. data:: DepObsoletes .. data:: DepPreDepends .. data:: DepRecommends .. data:: DepReplaces .. data:: DepSuggests + .. _InstStates: Installed states diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 86732781..bfa1227e 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -504,6 +504,8 @@ extern "C" void initapt_pkg() AddInt(Dict,"DepConflicts",pkgCache::Dep::Conflicts); AddInt(Dict,"DepReplaces",pkgCache::Dep::Replaces); AddInt(Dict,"DepObsoletes",pkgCache::Dep::Obsoletes); + AddInt(Dict,"DepDpkgBreaks",pkgCache::Dep::DpkgBreaks); + AddInt(Dict,"DepEnhances",pkgCache::Dep::Enhances); AddInt(Dict,"PriImportant",pkgCache::State::Important); AddInt(Dict,"PriRequired",pkgCache::State::Required); diff --git a/python/cache.cc b/python/cache.cc index a88490bd..023cf041 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -27,6 +27,17 @@ class pkgSourceList; +// must be in sync with pkgCache::DepType in libapt +// it sucks to have it here duplicated, but we get it +// translated from libapt and that is certainly not what +// we want in a programing interface +const char *UntranslatedDepTypes[] = +{ + "", "Depends","PreDepends","Suggests", + "Recommends","Conflicts","Replaces", + "Obsoletes", "Breaks", "Enhances" +}; + /*}}}*/ struct PkgListStruct { @@ -495,17 +506,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, // Switch/create a new dict entry if (LastDepType != Start->Type || LastDep != 0) { - // must be in sync with pkgCache::DepType in libapt - // it sucks to have it here duplicated, but we get it - // translated from libapt and that is certainly not what - // we want in a programing interface - const char *Types[] = - { - "", "Depends","PreDepends","Suggests", - "Recommends","Conflicts","Replaces", - "Obsoletes", "Breaks", "Enhances" - }; - PyObject *Dep = PyString_FromString(Types[Start->Type]); + PyObject *Dep = PyString_FromString(UntranslatedDepTypes[Start->Type]); LastDepType = Start->Type; LastDep = PyDict_GetItem(Dict,Dep); if (LastDep == 0) @@ -823,6 +824,10 @@ static PyObject *DependencyAttr(PyObject *Self,char *Name) return PyString_FromString(Dep.CompType()); else if (strcmp("DepType",Name) == 0) return PyString_FromString(Dep.DepType()); + else if (strcmp("UntranslatedDepType",Name) == 0) + return PyString_FromString(UntranslatedDepTypes[Dep->Type]); + else if (strcmp("DepTypeEnum",Name) == 0) + return Py_BuildValue("i", Dep->Type); else if (strcmp("ID",Name) == 0) return Py_BuildValue("i",Dep->ID); -- cgit v1.2.3