summaryrefslogtreecommitdiff
path: root/alot/db/message.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-05-08 17:13:02 +0200
committerAnton Khirnov <anton@khirnov.net>2020-05-09 15:27:23 +0200
commit4c02a40d5dcec1fba988aa626da2dd0d9a058abd (patch)
tree67e43adad81d079560c016ce99b2708bcd6749aa /alot/db/message.py
parent9a8621234211fd13f59374304fe57f6cf7bfd98e (diff)
Switch to the notmuch2 bindings.
They are supposed to replace the original notmuch python bindings, providing a safer and more pythonic interface.
Diffstat (limited to 'alot/db/message.py')
-rw-r--r--alot/db/message.py23
1 files changed, 7 insertions, 16 deletions
diff --git a/alot/db/message.py b/alot/db/message.py
index 09b1c030..02d5565b 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -360,37 +360,28 @@ class Message:
:type depth int
"""
self._dbman = dbman
- self.id = msg.get_message_id()
+ self.id = msg.messageid
self.thread = thread
self.depth = depth
try:
- self.date = datetime.fromtimestamp(msg.get_date())
+ self.date = datetime.fromtimestamp(msg.date)
except ValueError:
self.date = None
- filenames = []
- for f in msg.get_filenames():
- # FIXME these should be returned as bytes, but the notmuch bindings
- # decode them
- # this should be resolved by switching to the newer notmuch2
- # bindings
- # for now, just re-encode them in utf-8
- filenames.append(f.encode('utf-8'))
- if len(filenames) == 0:
+ self.filenames = list(msg.filenamesb())
+ if len(self.filenames) == 0:
raise ValueError('No filenames for a message returned')
- self.filenames = filenames
session_keys = []
- for name, value in msg.get_properties("session-key", exact=True):
- if name == "session-key":
- session_keys.append(value)
+ for name, value in msg.properties.getall('session-key', exact = True):
+ session_keys.append(value)
self._email = self._load_email(session_keys)
self.headers = _MessageHeaders(self._email)
self.body = _MimeTree(self._email, session_keys)
- self._tags = set(msg.get_tags())
+ self._tags = set(msg.tags)
sender = self._email.get('From')
if sender is None: