# HG changeset patch # User marga # Date 1187825696 0 # Node ID 828bacf2720369c7a82e6b193f8f62b99a887d8c # Parent 44d4f7dca0fd0979d506e5afe427722fb597923e Added email parsing capabilities for the bug log diff --git a/bts_webui/amancay/views.py b/bts_webui/amancay/views.py --- 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',