X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fmessage.py;h=340c0b8b742be49dcd1123e7e22f66be8ad29cd3;hp=613cc4abc2be7f89c1501cbabaf008288e50204e;hb=6ae4e7d88be66ab7b24d96b7091ed56aa7e97ccc;hpb=3b558de7811a765c3295a58bd53e2156eca0e32e diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index 613cc4ab..340c0b8b 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 @@ -748,7 +766,7 @@ class Message(object): output += "\n\fbody{" parts = format["body"] - parts.sort(key=lambda(p): p["id"]) + parts.sort(key=lambda x: x['id']) for p in parts: if not p.has_key("filename"): output += "\n\fpart{ "