Simplified cheat_directories, removing bad import

This commit is contained in:
Jeffrey Lund 2013-08-20 15:58:39 -07:00
parent 1e26280da7
commit de2471b93a
1 changed files with 3 additions and 13 deletions

16
cheat
View File

@ -4,19 +4,9 @@ import sys
# assembles a list of directories containing cheatsheets # assembles a list of directories containing cheatsheets
def cheat_directories(): def cheat_directories():
default_directories = [os.path.expanduser('~/.cheat')] paths = [os.path.expanduser('~/.cheat')]
try: paths.extend(os.environ.get('CHEATPATH', '').split(os.pathsep))
import cheatsheets return [path for path in paths if os.path.isdir(path)]
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:
return default
# assembles a dictionary of cheatsheets found in the above directories # assembles a dictionary of cheatsheets found in the above directories
def cheat_files(cheat_directories): def cheat_files(cheat_directories):