summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-30 14:47:59 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-30 14:47:59 +0200
commit00ebd1e79986dad66829edaf8dc906a4c9d1ab6c (patch)
treea3de0f4d1427ac705a8410b4c7f90fbe0e9a5786 /apt
parent4e66ff1d8fea8631af4656d824b7d6f94f9486c4 (diff)
downloadpython-apt-00ebd1e79986dad66829edaf8dc906a4c9d1ab6c.tar.gz
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
Diffstat (limited to 'apt')
-rw-r--r--apt/package.py16
1 files changed, 13 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 '<Package: name:%r id:%r>' % (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.