python: pep8 compliance for message.py

This commit is contained in:
pazz 2011-07-12 20:46:59 +01:00 committed by Sebastian Spaeth
parent 9562c7d1fb
commit 61f0184707

View file

@ -31,7 +31,8 @@ try:
import simplejson as json
except ImportError:
import json
#------------------------------------------------------------------------------
class Messages(object):
"""Represents a list of notmuch messages
@ -133,7 +134,7 @@ class Messages(object):
raise NotmuchError(STATUS.NOT_INITIALIZED)
# collect all tags (returns NULL on error)
tags_p = Messages._collect_tags (self._msgs)
tags_p = Messages._collect_tags(self._msgs)
#reset _msgs as we iterated over it and can do so only once
self._msgs = None
@ -153,7 +154,7 @@ class Messages(object):
self._msgs = None
raise StopIteration
msg = Message(Messages._get (self._msgs), self)
msg = Message(Messages._get(self._msgs), self)
nmlib.notmuch_messages_move_to_next(self._msgs)
return msg
@ -167,7 +168,7 @@ class Messages(object):
def __del__(self):
"""Close and free the notmuch Messages"""
if self._msgs is not None:
nmlib.notmuch_messages_destroy (self._msgs)
nmlib.notmuch_messages_destroy(self._msgs)
def print_messages(self, format, indent=0, entire_thread=False):
"""Outputs messages as needed for 'notmuch show' to sys.stdout
@ -222,7 +223,7 @@ class Messages(object):
sys.stdout.write(set_end)
sys.stdout.write(set_end)
#------------------------------------------------------------------------------
class Message(object):
"""Represents a single Email message
@ -296,7 +297,6 @@ class Message(object):
#keep reference to parent, so we keep it alive
self._parent = parent
def get_message_id(self):
"""Returns the message ID
@ -324,10 +324,11 @@ class Message(object):
if self._msg is None:
raise NotmuchError(STATUS.NOT_INITIALIZED)
return Message._get_thread_id (self._msg);
return Message._get_thread_id(self._msg)
def get_replies(self):
"""Gets all direct replies to this message as :class:`Messages` iterator
"""Gets all direct replies to this message as :class:`Messages`
iterator
.. note:: This call only makes sense if 'message' was
ultimately obtained from a :class:`Thread` object, (such as
@ -346,12 +347,12 @@ class Message(object):
if self._msg is None:
raise NotmuchError(STATUS.NOT_INITIALIZED)
msgs_p = Message._get_replies(self._msg);
msgs_p = Message._get_replies(self._msg)
if msgs_p is None:
return None
return Messages(msgs_p,self)
return Messages(msgs_p, self)
def get_date(self):
"""Returns time_t of the message date
@ -391,7 +392,7 @@ class Message(object):
raise NotmuchError(STATUS.NOT_INITIALIZED)
#Returns NULL if any error occurs.
header = Message._get_header (self._msg, header)
header = Message._get_header(self._msg, header)
if header == None:
raise NotmuchError(STATUS.NULL_POINTER)
return header
@ -504,7 +505,7 @@ class Message(object):
if self._msg is None:
raise NotmuchError(STATUS.NOT_INITIALIZED)
status = nmlib.notmuch_message_add_tag (self._msg, tag)
status = nmlib.notmuch_message_add_tag(self._msg, tag)
# bail out on failure
if status != STATUS.SUCCESS:
@ -557,8 +558,6 @@ class Message(object):
self.tags_to_maildir_flags()
return STATUS.SUCCESS
def remove_all_tags(self, sync_maildir_flags=False):
"""Removes all tags from the given message.
@ -684,7 +683,6 @@ class Message(object):
raise NotmuchError(status)
def is_match(self):
"""(Not implemented)"""
return self.get_flag(Message.FLAG.MATCH)
@ -753,7 +751,6 @@ class Message(object):
msg['date'] = date.fromtimestamp(self.get_date())
return "%(from)s (%(date)s) (%(tags)s)" % (msg)
def get_message_parts(self):
"""Output like notmuch show"""
fp = open(self.get_filename())
@ -858,11 +855,11 @@ class Message(object):
parts = format["body"]
parts.sort(key=lambda x: x['id'])
for p in parts:
if not p.has_key("filename"):
if not "filename" in p:
output += "\n\fpart{ "
output += "ID: %d, Content-type: %s\n" % (p["id"],
p["content-type"])
if p.has_key("content"):
if "content" in p:
output += "\n%s\n" % p["content"]
else:
output += "Non-text part: %s\n" % p["content-type"]
@ -903,4 +900,4 @@ class Message(object):
def __del__(self):
"""Close and free the notmuch Message"""
if self._msg is not None:
nmlib.notmuch_message_destroy (self._msg)
nmlib.notmuch_message_destroy(self._msg)