diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-12-14 16:51:50 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-12-19 12:33:24 -0800 |
commit | e797d1ab3b11c789a3fdabb9f8c040eccb19deee (patch) | |
tree | 56df29d46fcf48284e761b76fc6ce8d4b0d67b2f /alot/db | |
parent | 516574b6c50572a202e0151203608ca029acfe9c (diff) |
Drop little used helper
The safely_get helper is just a wrapper around try/except, and is used
twice in the whole code base, in the same function. It really doesn't
even end up saving code because to get around line wrapping a lambda is
assigned (which is not the greatest style wise), it ends up saving one
line of code when it's called, and the function itself is 16 lines long.
Diffstat (limited to 'alot/db')
-rw-r--r-- | alot/db/message.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/alot/db/message.py b/alot/db/message.py index 0a129992..de535d37 100644 --- a/alot/db/message.py +++ b/alot/db/message.py @@ -36,13 +36,15 @@ class Message(object): self._id = msg.get_message_id() self._thread_id = msg.get_thread_id() self._thread = thread - casts_date = lambda: datetime.fromtimestamp(msg.get_date()) - self._datetime = helper.safely_get(casts_date, - ValueError, None) + try: + self._datetime = datetime.fromtimestamp(msg.get_date()) + except ValueError: + self._datetime = None self._filename = msg.get_filename() - author = helper.safely_get(lambda: msg.get_header('From'), - NullPointerError) - self._from = decode_header(author) + try: + self._from = decode_header(msg.get_header('From')) + except NullPointerError: + self._from = '' self._email = None # will be read upon first use self._attachments = None # will be read upon first use self._tags = set(msg.get_tags()) |