diff options
| author | Michael Schaller <michael@5challer.de> | 2014-01-11 13:07:46 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2014-01-25 16:48:48 +0100 |
| commit | e50f19ba24ff8999d6d18da3fd06cdb44dfccced (patch) | |
| tree | 33ab74475e17917e1f579946858e2c2b4630fc8a /apt | |
| parent | 3e33aaa11c0062b6bf97601e3221a9858a533ad2 (diff) | |
| download | python-apt-e50f19ba24ff8999d6d18da3fd06cdb44dfccced.tar.gz | |
apt/package.py: Improved readability and documentation of BaseDependency.__dstr().
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/package.py | 21 |
1 files changed, 18 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 |
