diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-04-19 18:34:39 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-04-19 18:34:39 +0200 |
commit | 5e240f760d61dca12bfc8f4bc903af9fa33cb402 (patch) | |
tree | 16e7f0de11004fdfa4c4774dbc5e7ac06fa27290 | |
parent | ffb02915a33b722e8ce078ed062799320b706e42 (diff) |
buffers/search: simplify code
-rw-r--r-- | alot/buffers/search.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/alot/buffers/search.py b/alot/buffers/search.py index d1b3e556..ef05c667 100644 --- a/alot/buffers/search.py +++ b/alot/buffers/search.py @@ -10,17 +10,13 @@ from ..settings.const import settings from ..widgets.search import ThreadlineWidget class PipeWalker(urwid.ListWalker): - """urwid.ListWalker that reads next items from a pipe and wraps them in - `containerclass` widgets for displaying - - Attributes that should be considered publicly readable: - :attr lines: the lines obtained from the pipe - :type lines: list(`containerclass`) """ - def __init__(self, pipe, containerclass, **kwargs): + urwid.ListWalker that reads next items from a pipe and wraps them in + ThreadlineWidget widgets for displaying + """ + def __init__(self, pipe, dbman): self.pipe = pipe - self.kwargs = kwargs - self.containerclass = containerclass + self._dbman = dbman self.lines = [] self.focus = 0 self.empty = False @@ -67,7 +63,7 @@ class PipeWalker(urwid.ListWalker): # the next line blocks until it can read from the pipe or # EOFError is raised. No races here. next_obj = self.pipe.recv() - next_widget = self.containerclass(next_obj, **self.kwargs) + next_widget = ThreadlineWidget(next_obj, self._dbman) self.lines.append(next_widget) except EOFError: logging.debug('EMPTY PIPE') @@ -122,8 +118,6 @@ class SearchBuffer(Buffer): def rebuild(self): self.kill_filler_process() - order = self.sort_order - exclude_tags = settings.get_notmuch_setting('search', 'exclude_tags') if exclude_tags: exclude_tags = [t for t in exclude_tags.split(';') if t] @@ -132,7 +126,7 @@ class SearchBuffer(Buffer): self.result_count = self.dbman.count_messages(self.querystring) self.thread_count = self.dbman.count_threads(self.querystring) self.pipe, self.proc = self.dbman.get_threads(self.querystring, - order, + self.sort_order, exclude_tags) except NotmuchError: self.ui.notify('malformed query string: %s' % self.querystring, @@ -141,8 +135,7 @@ class SearchBuffer(Buffer): self.body = self.listbox return - self.threadlist = PipeWalker(self.pipe, ThreadlineWidget, - dbman=self.dbman) + self.threadlist = PipeWalker(self.pipe, self.dbman) self.listbox = urwid.ListBox(self.threadlist) self.body = self.listbox |