From 00ebd1e79986dad66829edaf8dc906a4c9d1ab6c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 14:47:59 +0200 Subject: apt/package.py: Allow to set the candidate of a package (Closes: #523997) + Support assignments to the 'candidate' property of Package objects. + Initial patch by Sebastian Heinlein --- apt/package.py | 16 +++++++++++++--- debian/changelog | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apt/package.py b/apt/package.py index ec88a456..f5bdc47d 100644 --- a/apt/package.py +++ b/apt/package.py @@ -486,15 +486,25 @@ class Package(object): def __repr__(self): return '' % (self._pkg.Name, self._pkg.ID) - @property def candidate(self): """Return the candidate version of the package. - - :since: 0.7.9""" + + This property is writeable to allow you to set the candidate version + of the package. Just assign a Version() object, and it will be set as + the candidate version. + """ cand = self._pcache._depcache.GetCandidateVer(self._pkg) if cand is not None: return Version(self, cand) + def __set_candidate(self, version): + """Set the candidate version of the package.""" + self._pcache.cachePreChange() + self._pcache._depcache.SetCandidateVer(self._pkg, version._cand) + self._pcache.cachePostChange() + + candidate = property(candidate, __set_candidate) + @property def installed(self): """Return the currently installed version of the package. diff --git a/debian/changelog b/debian/changelog index 73e9eab7..fcc7fd9b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,10 @@ python-apt (0.7.11.2) unstable; urgency=low open(), by calling InitSystem again. (LP: #320665). - Provide broken_count, delete_count, install_count, keep_count properties (Closes: #532338) + * apt/package.py: + - Allow to set the candidate of a package (Closes: #523997) + + Support assignments to the 'candidate' property of Package objects. + + Initial patch by Sebastian Heinlein [ Stefano Zacchiroli ] * debian/python-apt.doc-base: register the documentation with the -- cgit v1.2.3