From 49f028101342d0b531da9833693f773f19297341 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Wed, 28 Mar 2012 22:49:46 +0100 Subject: use parse_mailcap_nametemplate in extract_body .. helper that calls inline mime handler. This is just to ensure we don't duplicate too much code --- alot/db/utils.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'alot') diff --git a/alot/db/utils.py b/alot/db/utils.py index 0d28783f..4007606c 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -14,6 +14,7 @@ import alot.helper as helper from alot.settings import settings from alot.helper import string_sanitize from alot.helper import string_decode +from alot.helper import parse_mailcap_nametemplate def extract_headers(mail, headers=None): @@ -82,17 +83,10 @@ def extract_body(mail, types=None): if entry: # open tempfile, respect mailcaps nametemplate nametemplate = entry.get('nametemplate', '%s') - nt_list = nametemplate.split('%s') - template_prefix = '' - template_suffix = '' - if len(nt_list) == 2: - template_suffix = nt_list[1] - template_prefix = nt_list[0] - else: - template_suffix = nametemplate + prefix, suffix = parse_mailcap_nametemplate(nametemplate) tmpfile = tempfile.NamedTemporaryFile(delete=False, - prefix=template_prefix, - suffix=template_suffix) + prefix=prefix, + suffix=suffix) # write payload to tmpfile tmpfile.write(raw_payload) tmpfile.close() -- cgit v1.2.3