diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-03-28 22:40:05 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-03-28 22:41:20 +0100 |
commit | 0edb61fbfae6ecd22fe80a59a937901b9701eb70 (patch) | |
tree | 9e21489f3e82f5b964eff49b511eaf0a75a417ea /alot | |
parent | 4948cb74688599f205f97ca48549f09c1f027125 (diff) |
add helper.parse_mailcap_nametemplate
that splits a nametemplate string as given in the mailcap
sensibly into prefix and suffix
Diffstat (limited to 'alot')
-rw-r--r-- | alot/helper.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/alot/helper.py b/alot/helper.py index 91aae324..85e527c3 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -17,6 +17,7 @@ from twisted.internet.protocol import ProcessProtocol from twisted.internet.defer import Deferred import StringIO import logging +import tempfile def safely_get(clb, E, on_error=''): @@ -396,3 +397,17 @@ def humanize_size(size): if size / factor < 1024: return format_string % (float(size) / factor) return format_string % (size / factor) + + +def parse_mailcap_nametemplate(tmplate='%s'): + """this returns a prefix and suffix to be used + in the tempfile module for a given mailcap nametemplate string""" + nt_list = tmplate.split('%s') + template_prefix = '' + template_suffix = '' + if len(nt_list) == 2: + template_suffix = nt_list[1] + template_prefix = nt_list[0] + else: + template_suffix = tmplate + return (template_prefix, template_suffix) |