diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/widgets/globals.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py index e4b9fada..f602add0 100644 --- a/alot/widgets/globals.py +++ b/alot/widgets/globals.py @@ -7,7 +7,6 @@ This contains alot-specific :class:`urwid.Widget` used in more than one mode. """ from __future__ import absolute_import -import functools import re import operator import urwid @@ -272,7 +271,6 @@ class HeadersList(urwid.WidgetWrap): return headerlines -@functools.total_ordering class TagWidget(urwid.AttrMap): """ text widget that renders a tagstring. @@ -318,11 +316,8 @@ class TagWidget(urwid.AttrMap): def set_unfocussed(self): self.set_attr_map(self.attmaps['normal']) - def __lt__(self, other): - """Groups tags of 1 character first, then alphabetically. - - This groups tags unicode characters at the begnining. - """ + def __cmp(self, other, comparitor): + """Shared comparison method.""" if not isinstance(other, TagWidget): return NotImplemented @@ -330,8 +325,24 @@ class TagWidget(urwid.AttrMap): oth_len = len(other.translated) if (self_len == 1) is not (oth_len == 1): - return self_len < oth_len - return self.translated.lower() < other.translated.lower() + return comparitor(self_len, oth_len) + return comparitor(self.translated.lower(), other.translated.lower()) + + def __lt__(self, other): + """Groups tags of 1 character first, then alphabetically. + + This groups tags unicode characters at the begnining. + """ + return self.__cmp(other, operator.lt) + + def __gt__(self, other): + return self.__cmp(other, operator.gt) + + def __ge__(self, other): + return self.__cmp(other, operator.ge) + + def __le__(self, other): + return self.__cmp(other, operator.le) def __eq__(self, other): if not isinstance(other, TagWidget): |