X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fmessage.py;h=49a58d1fb2cfd8e10e6c6db6850151f0dc0fe48f;hb=02f1c3b2120033af5b45b109d35ba73775219abf;hp=7bc7798c3cc7091ffd47ede9efe2f426bae17dd7;hpb=12ebf879476ba60389c9310327b8a271f1f7eb5e;p=obsolete%2Fnotmuch-old diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index 7bc7798c..49a58d1f 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -19,7 +19,7 @@ Copyright 2010 Sebastian Spaeth ' """ -from ctypes import c_char_p, c_void_p, c_long, c_uint, c_int +from ctypes import c_char_p, c_long, c_uint, c_int from datetime import date from notmuch.globals import (nmlib, STATUS, NotmuchError, Enum, _str, NotmuchTagsP, NotmuchMessagesP, NotmuchMessageP, NotmuchFilenamesP) @@ -27,7 +27,6 @@ from notmuch.tag import Tags from notmuch.filename import Filenames import sys import email -import types try: import simplejson as json except ImportError: @@ -428,7 +427,7 @@ class Message(object): header = Message._get_header(self._msg, header) if header == None: raise NotmuchError(STATUS.NULL_POINTER) - return header.decode('UTF-8') + return header.decode('UTF-8', 'ignore') def get_filename(self): """Returns the file path of the message file @@ -759,11 +758,11 @@ class Message(object): not work yet, as the modified tags have not been committed yet to the database. - :returns: a :class:`STATUS`. In short, you want to see + :returns: a :class:`STATUS` value. In short, you want to see notmuch.STATUS.SUCCESS here. See there for details.""" if self._msg is None: raise NotmuchError(STATUS.NOT_INITIALIZED) - status = Message._tags_to_maildir_flags(self._msg) + return Message._tags_to_maildir_flags(self._msg) def maildir_flags_to_tags(self): """Synchronize file Maildir flags to notmuch tags @@ -790,19 +789,21 @@ class Message(object): notmuch.STATUS.SUCCESS here. See there for details.""" if self._msg is None: raise NotmuchError(STATUS.NOT_INITIALIZED) - status = Message._tags_to_maildir_flags(self._msg) + return Message._tags_to_maildir_flags(self._msg) def __repr__(self): """Represent a Message() object by str()""" return self.__str__() def __str__(self): - """A message() is represented by a 1-line summary""" - msg = {} - msg['from'] = self.get_header('from') - msg['tags'] = self.get_tags() - msg['date'] = date.fromtimestamp(self.get_date()) - return "%(from)s (%(date)s) (%(tags)s)" % (msg) + return unicode(self).encode('utf-8') + + def __unicode__(self): + format = "%s (%s) (%s)" + return format % (self.get_header('from'), + self.get_tags(), + date.fromtimestamp(self.get_date()), + ) def get_message_parts(self): """Output like notmuch show"""