From cab6227070f6fce77838ef1ebed0a723684b7087 Mon Sep 17 00:00:00 2001 From: John Helmert III Date: Thu, 14 Nov 2019 17:05:08 -0600 Subject: [PATCH] Minor formatting fix in Terminal._load_mailcaps() --- tuir/terminal.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tuir/terminal.py b/tuir/terminal.py index 723bb59..410ad59 100644 --- a/tuir/terminal.py +++ b/tuir/terminal.py @@ -71,29 +71,37 @@ class Terminal(object): def _load_mailcaps(self): mailcap_file = self.config.MAILCAP + if not os.path.exists(mailcap_file): return mailcap.getcaps() + mailcaps_env = 'MAILCAPS' caps = dict() + # Prepends application-specific mailcap file to MAILCAPS env # This allows mailcap.getcaps to read it before other mailcap files # Previous value of MAILCAPS is restored after usage prev_mailcaps = os.getenv(mailcaps_env) + if prev_mailcaps is None: # start with default system caps files; will be overwritten by local file caps = mailcap.getcaps() new_mailcaps = mailcap_file else: new_mailcaps = os.pathsep.join((mailcap_file, prev_mailcaps)) + os.environ[mailcaps_env] = new_mailcaps + # merge local mailcaps file with default caps # settings in local file will override defaults for k, v in mailcap.getcaps().items(): caps[k] = v + if prev_mailcaps is None: del os.environ[mailcaps_env] else: os.environ[mailcaps_env] = prev_mailcaps + return caps @property