diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-30 20:31:47 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-30 20:31:47 +0200 |
| commit | 67c86eb63c861e9048c8b712654d65dd86d77330 (patch) | |
| tree | 33aa2bcb1481734920132478d52f6475cc6dc3e2 /apt/package.py | |
| parent | 0a53a962ea50141dacd09e0e9f6228233c12e1f1 (diff) | |
| parent | 1d67c8142d295004c894473df5457b8ce9ed6197 (diff) | |
| download | python-apt-67c86eb63c861e9048c8b712654d65dd86d77330.tar.gz | |
Merge 0.7.11.1-0.7.12.0 from unstable.
Diffstat (limited to 'apt/package.py')
| -rw-r--r-- | apt/package.py | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/apt/package.py b/apt/package.py index 1307ca3e..f8e1354b 100644 --- a/apt/package.py +++ b/apt/package.py @@ -33,6 +33,11 @@ except ImportError: # (for Python < 2.6) pylint: disable-msg=C0103 Sequence = Mapping = object +try: + from collections import Sequence +except ImportError: + Sequence = object + import apt_pkg import apt.progress.text from apt_pkg import gettext as _ @@ -40,7 +45,7 @@ from apt.deprecation import (function_deprecated_by, AttributeDeprecatedBy, deprecated_args) __all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record', - 'Version') + 'Version', 'VersionList') def _file_is_same(path, size, md5): @@ -200,22 +205,47 @@ class Version(object): self.package = package self._cand = cand - def __eq__(self, other): + def _cmp(self, other): try: - return self._cand.id == other._cand.id + return apt_pkg.Version_compare(self._cand.ver_str, other.version) except AttributeError: - return apt_pkg.version_compare(self.version, other) == 0 - except Exception: - return False + return apt_pkg.Version_compare(self._cand.ver_str, other) + + def __eq__(self, other): + try: + return self._cmp(other) == 0 + except TypeError: + return NotImplemented + + def __ge__(self, other): + try: + return self._cmp(other) >= 0 + except TypeError: + return NotImplemented def __gt__(self, other): - return apt_pkg.version_compare(self.version, other.version) > 0 + try: + return self._cmp(other) > 0 + except TypeError: + return NotImplemented + + def __le__(self, other): + try: + return self._cmp(other) <= 0 + except TypeError: + return NotImplemented def __lt__(self, other): - return apt_pkg.version_compare(self.version, other.version) < 0 + try: + return self._cmp(other) < 0 + except TypeError: + return NotImplemented def __ne__(self, other): - return not self.__eq__(other) + try: + return self._cmp(other) != 0 + except TypeError: + return NotImplemented def __hash__(self): return self._cand.hash @@ -610,8 +640,6 @@ class Package(object): 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. - - .. versionadded:: 0.7.9 """ cand = self._pcache._depcache.get_candidate_ver(self._pkg) if cand is not None: |
