diff options
author | pazz <patricktotzke@gmail.com> | 2011-06-14 15:40:41 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-06-18 13:25:46 +0100 |
commit | e48523bcbbf6fd431bc3a7343ea32b65af8a4f29 (patch) | |
tree | 74c319c175c31b6db3c40f40a1c70b2bf818a291 /alot/settings.py | |
parent | 316423a063f262d15a41c5a8d167f760eb411085 (diff) |
use mailcap info for text/html dumps
Diffstat (limited to 'alot/settings.py')
-rw-r--r-- | alot/settings.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/alot/settings.py b/alot/settings.py index 75977a05..3cc196e3 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -18,7 +18,7 @@ Copyright (C) 2011 Patrick Totzke <patricktotzke@gmail.com> """ import imp import os -import logging +import mailcap from ConfigParser import SafeConfigParser @@ -193,15 +193,16 @@ class CustomConfigParser(SafeConfigParser): config = CustomConfigParser(DEFAULTS) +mailcaps = mailcap.getcaps() def setup(configfilename): config.read(os.path.expanduser(configfilename)) - if config.has_option('general','hooksfile'): - hf = os.path.expanduser(config.get('general','hooksfile')) + if config.has_option('general', 'hooksfile'): + hf = os.path.expanduser(config.get('general', 'hooksfile')) if hf is not None: try: - config.hooks = imp.load_source('hooks',hf) + config.hooks = imp.load_source('hooks', hf) except: pass @@ -223,9 +224,19 @@ def get_palette(): def get_hook(hookname): h = None if config.hooks: - logging.info("hooks there") if config.hooks.__dict__: - logging.info("hooks is module") if hookname in config.hooks.__dict__: h = config.hooks.__dict__[hookname] return h + + +def get_mime_handler(mime_type, key, interactive=True): + if interactive: + mc_tuple = mailcap.findmatch(mailcaps, + mime_type, + key=key) + else: + mc_tuple = mailcap.findmatch(mailcaps, + mime_type, + key='copiousoutput') + return mc_tuple[1][key] |