diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-02-06 11:26:08 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-02-06 11:31:27 +0100 |
commit | 0a5a9bd056cc6946ed6c75a43dd7a77c404de3d1 (patch) | |
tree | d437d77600f43cb0e7fb6a2116577b4767a14a3d | |
parent | f6a67c33c360b10cd1c7d876c741846028e35f47 (diff) |
db/thread: drop useless getter functions
-rw-r--r-- | alot/buffers/thread.py | 4 | ||||
-rw-r--r-- | alot/db/thread.py | 43 | ||||
-rw-r--r-- | alot/widgets/search.py | 5 |
3 files changed, 24 insertions, 28 deletions
diff --git a/alot/buffers/thread.py b/alot/buffers/thread.py index 16b9dae9..41766852 100644 --- a/alot/buffers/thread.py +++ b/alot/buffers/thread.py @@ -27,7 +27,7 @@ class ThreadBuffer(Buffer): :type thread: :class:`~alot.db.Thread` """ self.thread = thread - self.message_count = thread.get_total_messages() + self.message_count = thread.total_messages self._indent_width = settings.get('thread_indent_replies') self.rebuild() @@ -90,7 +90,7 @@ class ThreadBuffer(Buffer): self._nested_tree = NestedTree(A, interpret_covered=True) self.body = TreeBox(self._nested_tree) - self.message_count = self.thread.get_total_messages() + self.message_count = self.thread.total_messages def get_selected_mid(self): """Return Message ID of focussed message.""" diff --git a/alot/db/thread.py b/alot/db/thread.py index 1dd78622..9284d076 100644 --- a/alot/db/thread.py +++ b/alot/db/thread.py @@ -15,6 +15,21 @@ class Thread: directly provide contained messages as :class:`~alot.db.message.Message`. """ + """ + date header of oldest message in this thread as + :class:`~datetime.datetime` + """ + oldest_date = None + + """ + date header of newest message in this thread as + :class:`~datetime.datetime` + """ + newest_date = None + + """number of contained messages""" + total_messages = None + def __init__(self, dbman, thread): """ :param dbman: db manager that is used for further lookups @@ -35,7 +50,7 @@ class Thread: if not thread: thread = self._dbman._get_notmuch_thread(self._id) - self._total_messages = thread.get_total_messages() + self.total_messages = thread.get_total_messages() self._notmuch_authors_string = thread.get_authors() subject_type = settings.get('thread_subject') @@ -53,14 +68,14 @@ class Thread: ts = thread.get_oldest_date() try: - self._oldest_date = datetime.fromtimestamp(ts) + self.oldest_date = datetime.fromtimestamp(ts) except ValueError: # year is out of range - self._oldest_date = None + self.oldest_date = None try: timestamp = thread.get_newest_date() - self._newest_date = datetime.fromtimestamp(timestamp) + self.newest_date = datetime.fromtimestamp(timestamp) except ValueError: # year is out of range - self._newest_date = None + self.newest_date = None self._tags = {t for t in thread.get_tags()} self._messages = {} # this maps messages to its children @@ -262,24 +277,6 @@ class Thread: return msg_hash[m] return None - def get_newest_date(self): - """ - returns date header of newest message in this thread as - :class:`~datetime.datetime` - """ - return self._newest_date - - def get_oldest_date(self): - """ - returns date header of oldest message in this thread as - :class:`~datetime.datetime` - """ - return self._oldest_date - - def get_total_messages(self): - """returns number of contained messages""" - return self._total_messages - def matches(self, query): """ Check if this thread matches the given notmuch query. diff --git a/alot/widgets/search.py b/alot/widgets/search.py index 116dddc3..51048394 100644 --- a/alot/widgets/search.py +++ b/alot/widgets/search.py @@ -163,15 +163,14 @@ def build_text_part(name, thread, struct): def prepare_date_string(thread): - newest = None - newest = thread.get_newest_date() + newest = thread.newest_date if newest is not None: datestring = settings.represent_datetime(newest) return datestring def prepare_mailcount_string(thread): - return "(%d)" % thread.get_total_messages() + return "(%d)" % thread.total_messages def prepare_authors_string(thread): |