From 22557647bdbc003b5ca70e39720cca78c77d9b39 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 18 Aug 2017 17:22:23 -0700 Subject: widgets/globals: Implement __hash__ for TagWidget Which is required in python3 when implementing the __eq__ method. The implementation caches the hash method, since it's being called each time the focus is changed in the search view. This doesn't really seem correct to me, but I'm not sure it's wrong. --- alot/widgets/globals.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'alot/widgets/globals.py') diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py index 6756149d..e4b9fada 100644 --- a/alot/widgets/globals.py +++ b/alot/widgets/globals.py @@ -292,6 +292,7 @@ class TagWidget(urwid.AttrMap): self.translated = representation['translated'] self.hidden = self.translated == '' self.txt = urwid.Text(self.translated, wrap='clip') + self.__hash = hash('{}_{}'.format(self.translated, self.txt)) normal_att = representation['normal'] focus_att = representation['focussed'] self.attmaps = {'normal': normal_att, 'focus': focus_att} @@ -343,3 +344,6 @@ class TagWidget(urwid.AttrMap): if not isinstance(other, TagWidget): return NotImplemented return self.translated.lower() != other.translated.lower() + + def __hash__(self): + return self.__hash -- cgit v1.2.3