From 5053f07fd818011cb51fef3c73262ac950d05c9d Mon Sep 17 00:00:00 2001 From: raochsinai Date: Tue, 12 Feb 2019 15:16:59 +0800 Subject: [PATCH] Expand ~ for 'CHEAT_USER_DIR', 'CHEAT_DEFAULT_DIR' and 'DEFAULT_CHEAT_DIR'. --- cheat/configuration.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cheat/configuration.py b/cheat/configuration.py index bd97297..b85cd24 100644 --- a/cheat/configuration.py +++ b/cheat/configuration.py @@ -49,15 +49,14 @@ class Configuration: ]).strip().lower() # self.cheat_user_dir - self.cheat_user_dir = self._select([ - os.environ.get('CHEAT_USER_DIR'), - os.environ.get('CHEAT_DEFAULT_DIR'), - os.environ.get('DEFAULT_CHEAT_DIR'), - # TODO: XDG home? - os.path.expanduser( - os.path.expandvars(os.path.join('~', '.cheat')) - ), - ]) + self.cheat_user_dir = self._select( + map(os.path.expanduser, + filter(None, + [os.environ.get('CHEAT_USER_DIR'), + os.environ.get('CHEAT_DEFAULT_DIR'), + os.environ.get('DEFAULT_CHEAT_DIR'), + # TODO: XDG home? + os.path.join('~', '.cheat')]))) # self.cheat_editor self.cheat_editor = self._select([