diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/envelope.py | 8 | ||||
-rw-r--r-- | alot/message.py | 15 |
2 files changed, 17 insertions, 6 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index e800278b..1d1d68f3 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -13,6 +13,7 @@ from alot import helper from alot.message import decode_to_unicode from alot.message import decode_header from alot.message import encode_header +from alot.message import extract_headers from alot.commands.globals import EditCommand from alot.commands.globals import BufferCloseCommand from alot.commands.globals import EnvelopeOpenCommand @@ -183,12 +184,7 @@ class EnvelopeEditCommand(Command): ui.current_buffer.set_email(self.mail) # decode header - headertext = u'' - for key in self.edit_headers: - value = u'' - if key in self.mail: - value = decode_header(self.mail.get(key, '')) - headertext += '%s: %s\n' % (key, value) + headertext = extract_headers(self.mail, self.edit_headers) if self.mail.is_multipart(): for part in self.mail.walk(): diff --git a/alot/message.py b/alot/message.py index e00d62df..90b53ad9 100644 --- a/alot/message.py +++ b/alot/message.py @@ -128,6 +128,9 @@ class Message(object): """returns realname and address pair of this messages author""" return email.Utils.parseaddr(self._from) + def get_headers_string(self, headers): + return extract_headers(self.get_mail(), headers) + def add_tags(self, tags): """adds tags to message @@ -175,6 +178,18 @@ class Message(object): return res +def extract_headers(mail, headers=None): + headertext = u'' + if headers == None: + headers = mail.keys() + for key in headers: + value = u'' + if key in mail: + value = decode_header(mail.get(key, '')) + headertext += '%s: %s\n' % (key, value) + return headertext + + def extract_body(mail): body_parts = [] for part in mail.walk(): |