diff --git a/eris/__main__.py b/eris/__main__.py index 72b3303..48bb5da 100755 --- a/eris/__main__.py +++ b/eris/__main__.py @@ -91,7 +91,7 @@ class Entry: self.path = path self.summary = summary self.highlighted = highlighted - self.widgets = results + self.results = results if set_results: # FIX: this is missed for entries appended later for result in results: @@ -104,25 +104,24 @@ class Entry: return self.path == other.path def __len__(self): - return len(self.widgets) + return len(self.results) def __getitem__(self, index): - return self.widgets[index] + return self.results[index] def appearance_min(self): - appearance = self.appearance_cache - if appearance is None or self.last_width != self.summary._max_width: + if self.appearance_cache is None \ + or self.last_width != self.summary._max_width: self.last_width = self.summary._max_width if self.highlighted is not None: - self.widget[self.highlighted].is_highlighted = True - new_appearance = self.widget.appearance_min() + self.results[self.highlighted].is_highlighted = True + row_appearance = self.widget.appearance_min() path = tools.path_colored(self.path) - padding = " " * (self.last_width - len(self.widget) + 1) - new_appearance[0] = new_appearance[0] + padding + path - self.appearance_cache = appearance = new_appearance + padding = " " * (self.last_width - len(self.results) + 1) + self.appearance_cache = [row_appearance[0] + padding + path] if self.highlighted is not None: - self.widget[self.highlighted].is_highlighted = False - return appearance + self.results[self.highlighted].is_highlighted = False + return self.appearance_cache def as_html(self): html_parts = [] diff --git a/eris/fill3.py b/eris/fill3.py index 2c78b03..6ae42c2 100644 --- a/eris/fill3.py +++ b/eris/fill3.py @@ -5,7 +5,6 @@ # Licensed under the Artistic License 2.0. import asyncio -import collections import contextlib import itertools import os @@ -77,11 +76,10 @@ def appearance_as_html(appearance): "\n
" + "") -class Row(collections.UserList): +class Row: def __init__(self, widgets, widths_func=even_widths): - collections.UserList.__init__(self, widgets) - self.widgets = self.data + self.widgets = widgets self.widths_func = widths_func def appearance(self, dimensions): diff --git a/eris/tools.py b/eris/tools.py index 68113e9..d3e8ae1 100755 --- a/eris/tools.py +++ b/eris/tools.py @@ -545,11 +545,13 @@ class Result: self.path = path self.tool = tool self.compression = None - self.pickle_path = os.path.join(CACHE_PATH, path + "-" + tool.__name__) self.scroll_position = (0, 0) self.status = Status.pending self.is_highlighted = False + def pickle_path(self): + return os.path.join(CACHE_PATH, self.path + "-" + self.tool.__name__) + @property @lru_cache_with_eviction(maxsize=50) def result(self): @@ -558,15 +560,15 @@ class Result: return unknown_label try: with compression_open_func(self.compression)( - self.pickle_path, "rb") as pickle_file: + self.pickle_path(), "rb") as pickle_file: return pickle.load(pickle_file) except FileNotFoundError: return unknown_label @result.setter def result(self, value): - os.makedirs(os.path.dirname(self.pickle_path), exist_ok=True) - dump_pickle_safe(value, self.pickle_path, + os.makedirs(os.path.dirname(self.pickle_path()), exist_ok=True) + dump_pickle_safe(value, self.pickle_path(), open=compression_open_func(self.compression)) Result.result.fget.evict(self) @@ -610,11 +612,11 @@ class Result: STATUS_TO_TERMSTR[self.status]]) def get_pages_dir(self): - return self.pickle_path + ".pages" + return self.pickle_path() + ".pages" def delete(self): with contextlib.suppress(FileNotFoundError): - os.remove(self.pickle_path) + os.remove(self.pickle_path()) with contextlib.suppress(FileNotFoundError): shutil.rmtree(self.get_pages_dir()) Result.result.fget.evict(self)
".join(lines) + "