diff --git a/mbox2web b/mbox2web index 0b5f2ec..ab91e7b 100755 --- a/mbox2web +++ b/mbox2web @@ -88,7 +88,7 @@ def render_body(msg): context = { "body": msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1") } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_multipart_mixed(msg): parts = msg.get_payload() if type(parts) == str: @@ -101,7 +101,7 @@ def render_body(msg): context = { "parts": partshtml } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_multipart_digest(msg): partshtml = [] for part in msg.get_payload(): @@ -110,7 +110,7 @@ def render_body(msg): context = { "parts": partshtml } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_message_rfc822(msg): partshtml = [] for part in msg.get_payload(): @@ -119,7 +119,7 @@ def render_body(msg): context = { "parts": partshtml } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_text_html(msg): htmlpart = HTMLPart() htmlpart.feed(msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1")) @@ -127,7 +127,7 @@ def render_body(msg): context = { "body": jinja2.Markup(htmlpart.as_string()) } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_text_enriched(msg): payload = msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1") tepart = TextEnrichedPart(payload) @@ -135,7 +135,7 @@ def render_body(msg): context = { "body": jinja2.Markup(tepart.as_string()) } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_message_partial(msg): # Default header for get_param is Content-Type whole_msg_id = msg.get_param("id") @@ -156,14 +156,14 @@ def render_body(msg): whole_msg_embedded_id = whole_msg_id archive(whole_msg) del partial_message_cache[whole_msg_id] - bodyhtml = "
This is part %d of %d of %s
" % ( + return "This is part %d of %d of %s
" % ( int(msg.get_param("number")), int(msg.get_param("total")), encode_message_id(whole_msg_id), html.escape(whole_msg_id)) def render_application_octet_stream(msg): - bodyhtml = save_part(msg, "attachment") + return save_part(msg, "attachment") def render_multipart_signed(msg): content, signature = msg.get_payload() @@ -187,7 +187,7 @@ def render_body(msg): "gpgresult": gpgresult, "gpgstatus": gpgstatus, } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_application_pgp(msg): with tempfile.NamedTemporaryFile(buffering=0) as content_fh: @@ -210,7 +210,7 @@ def render_body(msg): "gpgresult": gpgresult, "gpgstatus": gpgstatus, } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_multipart_alternative(msg): partshtml = [] @@ -223,24 +223,24 @@ def render_body(msg): "types": partstypes, "parts": partshtml, } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_application_x_unknown_content_type_scpfile(msg): bodytmpl = jenv.get_template("body_application_x-unknown-content-type-scpfile.html") context = { "body": msg.get_payload(decode=True).decode(msg.get_charset() or "iso-8859-1") } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_application_pgp_signature(msg): # A PGP signature outside of a multipart/signed - useless bodytmpl = jenv.get_template("body_application_pgp-signature.html") context = { } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_application_x_gzip(msg): - bodyhtml = save_part(msg, "attachment") + return save_part(msg, "attachment") def render_message_news(msg): partshtml = [] @@ -251,10 +251,10 @@ def render_body(msg): "msg": msg, "parts": partshtml, } - bodyhtml = bodytmpl.render(context) + return bodytmpl.render(context) def render_image_gif(msg): - bodyhtml = save_part(msg, "inline") + return save_part(msg, "inline") renderers = { "text/plain": render_text_plain,