summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-01-15 15:07:58 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-01-15 15:07:58 +0100
commitb260eee89b518829f379f9555b8a61804ef86bc6 (patch)
treeb835d40ac35c7e2bd4633e72faa4a18df5ed5ae8
parentc86aad8bf2070784a95dda2cd0fb8f7aaff6860f (diff)
parent2530221de1657aeac3fa2b93c6b17712a08c6399 (diff)
downloadpython-apt-b260eee89b518829f379f9555b8a61804ef86bc6.tar.gz
* apt/cache.py:
- improved docstring for the cache - 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
-rw-r--r--apt/cache.py9
-rw-r--r--apt/package.py5
-rw-r--r--debian/changelog19
-rw-r--r--doc/source/apt_pkg/cache.rst9
-rw-r--r--doc/source/apt_pkg/index.rst5
-rw-r--r--python/apt_pkgmodule.cc2
-rw-r--r--python/cache.cc27
-rw-r--r--tests/test_enhances.py17
8 files changed, 80 insertions, 13 deletions
diff --git a/apt/cache.py b/apt/cache.py
index fa6c404c..ae6f2fcc 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -43,7 +43,14 @@ class Cache(object):
"""Dictionary-like package cache.
This class has all the packages that are available in it's
- dictionary
+ dictionary.
+
+ Keyword arguments:
+ progress -- a OpProgress object
+ rootdir -- a alternative root directory. if that is given
+ the system sources.list and system lists/ files are
+ not read, only files relative to the given rootdir
+ memonly -- build the cache in memory only
"""
def __init__(self, progress=None, rootdir=None, memonly=False):
diff --git a/apt/package.py b/apt/package.py
index 8d3be1b0..f33871c6 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -379,6 +379,11 @@ class Version(object):
return depends_list
@property
+ def enhances(self):
+ """Return the list of enhances for the package version."""
+ return self.get_dependencies("Enhances")
+
+ @property
def dependencies(self):
"""Return the dependencies of the package version."""
return self.get_dependencies("PreDepends", "Depends")
diff --git a/debian/changelog b/debian/changelog
index 21ac9377..632711fe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,22 @@
+python-apt (0.7.13.4ubuntu2) lucid; urgency=low
+
+ [ Michael Vogt ]
+ * apt/cache.py:
+ - improved docstring for the cache
+ - 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 <michael.vogt@ubuntu.com> Fri, 15 Jan 2010 15:06:10 +0100
+
python-apt (0.7.13.4ubuntu1) lucid; urgency=low
[ Michael Vogt ]
diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst
index 334b7869..ca9f8b49 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 :ref:`Dependency types <DependencyTypes>`.
+
.. 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..4256d971 100644
--- a/doc/source/apt_pkg/index.rst
+++ b/doc/source/apt_pkg/index.rst
@@ -329,19 +329,22 @@ Package States
.. data:: CurStateNotInstalled
.. data:: CurStateUnPacked
-
+.. _DependencyTypes:
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);
diff --git a/tests/test_enhances.py b/tests/test_enhances.py
new file mode 100644
index 00000000..3eced9f9
--- /dev/null
+++ b/tests/test_enhances.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import apt
+
+cache = apt.Cache()
+
+for pkg in cache:
+ if pkg.installed and pkg.installed.enhances:
+ s = "%s enhances:" % pkg.name
+ for or_list in pkg.installed.enhances:
+ for enhances in or_list.or_dependencies:
+ s += " %s" % enhances.name
+ if (cache.has_key(enhances.name) and
+ not cache[enhances.name].isInstalled):
+ s += "(*missing*) "
+ s += ","
+ print s[:-1]