From 570d05349ea04f28ceebfe706c30f3f043b4de79 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 19 Aug 2013 09:02:53 +0100 Subject: [PATCH] No breakage when cheatsheets package isn't found This means cheat can be installed in only the home directory again. --- cheat | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cheat b/cheat index 553ae65..3791fd1 100755 --- a/cheat +++ b/cheat @@ -1,10 +1,16 @@ #!/usr/bin/env python import os import sys -import cheatsheets def cheat_directories(): - default = [ default_dir for default_dir in [os.path.expanduser('~/.cheat'), cheatsheets.cheat_dir] if os.path.isdir(default_dir) ] + default_directories = [os.path.expanduser('~/.cheat')] + try: + import cheatsheets + default_directories.append(cheatsheets.cheat_dir) + except ImportError: + pass + + default = [ default_dir for default_dir in default_directories if os.path.isdir(default_dir) ] if 'CHEATPATH' in os.environ and os.environ['CHEATPATH']: return [ path for path in os.environ['CHEATPATH'].split(os.pathsep) if os.path.isdir(path) ] + default else: