Mercurial > hg > bts-webui
changeset 34:828bacf27203 draft
Added email parsing capabilities for the bug log
author | marga |
---|---|
date | Wed, 22 Aug 2007 23:34:56 +0000 |
parents | 44d4f7dca0fd |
children | 06095c3d1e27 |
files | bts_webui/amancay/views.py |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bts_webui/amancay/views.py +++ b/bts_webui/amancay/views.py @@ -61,6 +61,7 @@ # The bug page uses regular expresions to parse the log import re # The bug page uses rfc822 to parse emails, dates, etc. +import email import email.Utils import email.Header @@ -105,7 +106,20 @@ date_value[0])) # Get the body - message["body"] = item["body"] + message["body"] = "" + content = item["header"] + "\n" + item["body"] + content = email.message_from_string(content) + if (content.is_multipart()): + for part in content.walk(): + if (part.get_content_maintype() == "multipart"): + continue + if (part["content-disposition"] == "inline"): + message["body"] += part.get_payload(decode=1) + "\n" + else: + message["body"] += "[attach: %s]" % part.get_filename() + else: + message["body"] = content.get_payload(decode=1) + bug_messages.append(message) return render_to_response('bug.html',