From bf4f1c80ca0fa3a1270b1208688efedcdd696b67 Mon Sep 17 00:00:00 2001 From: Romanos Skiadas Date: Tue, 19 Jul 2016 14:37:18 +0300 Subject: [PATCH] Style fixes Don't use * imports, fix indentations, other small fixes --- bin/cheat | 4 ++-- cheat/sheet.py | 11 +++++------ cheat/sheets.py | 13 +++++++------ cheat/utils.py | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/cheat b/bin/cheat index 8583a3c..3939a83 100755 --- a/bin/cheat +++ b/bin/cheat @@ -31,8 +31,8 @@ Options: """ # require the dependencies -from cheat import * -from cheat.utils import * +from cheat import sheets, sheet +from cheat.utils import colorize from docopt import docopt diff --git a/cheat/sheet.py b/cheat/sheet.py index f2f4e6d..7f62405 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -1,10 +1,9 @@ -from cheat import sheets -from cheat import utils -from cheat.utils import * import os import shutil import subprocess +from cheat import sheets +from cheat.utils import die, editor def copy(current_sheet_path, new_sheet_path): """ Copies a sheet to a new path """ @@ -16,7 +15,7 @@ def copy(current_sheet_path, new_sheet_path): # fail gracefully if the cheatsheet cannot be copied. This can happen if # DEFAULT_CHEAT_DIR does not exist except IOError: - die ('Could not copy cheatsheet for editing.') + die('Could not copy cheatsheet for editing.') def create_or_edit(sheet): @@ -84,5 +83,5 @@ def read(sheet): if not exists(sheet): die('No cheatsheet found for ' + sheet) - with open (path(sheet)) as cheatfile: - return cheatfile.read() + with open(path(sheet)) as cheatfile: + return cheatfile.read() diff --git a/cheat/sheets.py b/cheat/sheets.py index 26e6ce2..4e09143 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -1,7 +1,8 @@ -from cheat import cheatsheets -from cheat.utils import * import os +from cheat import cheatsheets +from cheat.utils import die + def default_path(): """ Returns the default cheatsheet path """ @@ -22,7 +23,7 @@ def default_path(): if not os.access(default_sheets_dir, os.R_OK): die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not readable.') if not os.access(default_sheets_dir, os.W_OK): - die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writeable.') + die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writable.') # return the default dir return default_sheets_dir @@ -81,10 +82,10 @@ def search(term): for cheatsheet in sorted(get().items()): match = '' for line in open(cheatsheet[1]): - if term in line: - match += ' ' + line + if term in line: + match += ' ' + line - if not match == '': + if match != '': result += cheatsheet[0] + ":\n" + match + "\n" return result diff --git a/cheat/utils.py b/cheat/utils.py index 28ba2eb..5e5d358 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -38,8 +38,8 @@ def editor(): elif os.environ['EDITOR'] == "": die( - 'Your EDITOR environment variable is set to an empty string. It must ' - 'be set to your editor\'s path.' + 'Your EDITOR environment variable is set to an empty string. It must ' + 'be set to your editor\'s path.' ) else: @@ -51,7 +51,7 @@ def prompt_yes_or_no(question): # Support Python 2 and 3 input # Default to Python 2's input() get_input = raw_input - + # If this is Python 3, use input() if sys.version_info[:2] >= (3, 0): get_input = input