summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/package.py21
-rw-r--r--debian/changelog1
2 files changed, 19 insertions, 3 deletions
diff --git a/apt/package.py b/apt/package.py
index 5d122968..d1a72744 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -72,17 +72,32 @@ class BaseDependency(object):
"""
class __dstr(str):
- """Helper to make > match >> and < match <<"""
+ """Compare helper for compatibility with old third-party code.
+
+ Old third-party code might still compare the relation with the
+ previously used relations (<<,<=,==,!=,>=,>>,) instead of the curently
+ used ones (<,<=,=,!=,>=,>,). This compare helper lets < match to <<,
+ > match to >> and = match to ==.
+ """
def __eq__(self, other):
- return str.__eq__(self, other) or str.__eq__(2 * self, other)
+ if str.__eq__(self, other):
+ return True
+ elif str.__eq__(self, '<'):
+ return str.__eq__('<<', other)
+ elif str.__eq__(self, '>'):
+ return str.__eq__('>>', other)
+ elif str.__eq__(self, '='):
+ return str.__eq__('==', other)
+ else:
+ return False
def __ne__(self, other):
return not self.__eq__(other)
def __init__(self, name, rel, ver, pre, rawtype=None):
self.name = name
- self.relation = len(rel) == 1 and self.__dstr(rel) or rel
+ self.relation = self.__dstr(rel)
self.version = ver
self.pre_depend = pre
self.rawtype = rawtype
diff --git a/debian/changelog b/debian/changelog
index d48122b0..32c29681 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ python-apt (0.9.2) UNRELEASED; urgency=low
* apt/package.py:
- Fixed PEP8 issues
- Fixed pyflakes issue: Removed unused import 'warnings'
+ - Improved readability and documentation of BaseDependency.__dstr().
-- Michael Vogt <michael.vogt@ubuntu.com> Sat, 23 Nov 2013 08:49:51 +0100