aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/notmuch/message.py
diff options
context:
space:
mode:
authorSebastian Spaeth <Sebastian@SSpaeth.de>2011-06-02 08:56:03 +0200
committerSebastian Spaeth <Sebastian@SSpaeth.de>2011-06-02 09:03:18 +0200
commitb31247c354b54a3cbeb1c7f9df830e16f7c921d9 (patch)
treea7293c6e59274348809cc43e6bd855967e333306 /bindings/python/notmuch/message.py
parente2afcd2594add5186234124dd38b4b2aeabca5bd (diff)
bindings/python: Implement Message().get_filenames()
Message().get_filenames() will return a generator that allows to iterator over the recorded filenames for a certain Message. Do ntoe that as all generators, these are one-time use only. You will have to reget them to perform various actions. So this works:: len(Message().get_filenames()) list(Message().get_filenames()) for n in Message().get_filenames(): print n But this won't:: names = Message().get_filenames() len(names) #uses up the iterator list(names) #outch, already used up... Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'bindings/python/notmuch/message.py')
-rw-r--r--bindings/python/notmuch/message.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py
index ac85cbb..340c0b8 100644
--- a/bindings/python/notmuch/message.py
+++ b/bindings/python/notmuch/message.py
@@ -23,6 +23,7 @@ from ctypes import c_char_p, c_void_p, c_long, c_uint
from datetime import date
from notmuch.globals import nmlib, STATUS, NotmuchError, Enum
from notmuch.tag import Tags
+from notmuch.filename import Filenames
import sys
import email
import types
@@ -244,6 +245,10 @@ class Message(object):
_get_filename = nmlib.notmuch_message_get_filename
_get_filename.restype = c_char_p
+ """return all filenames for a message"""
+ _get_filenames = nmlib.notmuch_message_get_filenames
+ _get_filenames.restype = c_void_p
+
"""notmuch_message_get_flag"""
_get_flag = nmlib.notmuch_message_get_flag
_get_flag.restype = c_uint
@@ -400,6 +405,19 @@ class Message(object):
raise NotmuchError(STATUS.NOT_INITIALIZED)
return Message._get_filename(self._msg)
+ def get_filenames(self):
+ """Get all filenames for the email corresponding to 'message'
+
+ Returns a Filenames() generator with all absolute filepaths for
+ messages recorded to have the same Message-ID. These files must
+ not necessarily have identical content."""
+ if self._msg is None:
+ raise NotmuchError(STATUS.NOT_INITIALIZED)
+
+ files_p = Message._get_filenames(self._msg)
+
+ return Filenames(files_p, self).as_generator()
+
def get_flag(self, flag):
"""Checks whether a specific flag is set for this message