From 5f9ac19afd531d4041bed7b7ac82063b26850e89 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sat, 18 Jan 2014 09:08:36 -0600 Subject: [PATCH] whitespace fixes --- bin/autojump | 8 ++++++-- install.py | 20 ++++++++++++++------ setup.cfg | 2 +- uninstall.py | 4 +++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/bin/autojump b/bin/autojump index 562620d..079ba90 100755 --- a/bin/autojump +++ b/bin/autojump @@ -263,10 +263,14 @@ def match_consecutive(needles, haystack, ignore_case=False): (path="/moo/foo/baz", weight=10), (path="/foo/baz", weight=10)] """ - sep = os.sep.replace('\\','\\\\') + if is_windows(): + # The normal \\ separator needs to be escaped again for use in regex. + sep = '\\\\' + else: + sep = os.sep regex_no_sep = '[^' + sep + ']*' - regex_one_sep = regex_no_sep + sep + regex_no_sep regex_no_sep_end = regex_no_sep + '$' + regex_one_sep = regex_no_sep + sep + regex_no_sep # can't use compiled regex because of flags regex_needle = regex_one_sep.join(needles) + regex_no_sep_end regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE diff --git a/install.py b/install.py index 31db07a..bbda5bd 100755 --- a/install.py +++ b/install.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - from __future__ import print_function import os @@ -44,7 +43,9 @@ def modify_autojump_sh(etc_dir, dryrun=False): def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): """Prepend custom AUTOJUMP_BIN_DIR definition to autojump.lua""" - custom_install = "local AUTOJUMP_BIN_DIR = \"%s\"\n" % bin_dir.replace("\\", "\\\\") + custom_install = "local AUTOJUMP_BIN_DIR = \"%s\"\n" % bin_dir.replace( + "\\", + "\\\\") clink_file = os.path.join(clink_dir, 'autojump.lua') with open(clink_file, 'r') as f: original = f.read() @@ -52,11 +53,15 @@ def modify_autojump_lua(clink_dir, bin_dir, dryrun=False): f.write(custom_install + original) -def parse_arguments(): +def parse_arguments(): # noqa if platform.system() == 'Windows': - default_user_destdir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'autojump') + default_user_destdir = os.path.join( + os.getenv('LOCALAPPDATA', ''), + 'autojump') else: - default_user_destdir = os.path.join(os.path.expanduser("~"), '.autojump') + default_user_destdir = os.path.join( + os.path.expanduser("~"), + '.autojump') default_user_prefix = '' default_user_zshshare = 'functions' default_system_destdir = '/' @@ -105,7 +110,8 @@ def parse_arguments(): file=sys.stderr) sys.exit(1) - if platform.system() != 'Windows' and get_shell() not in SUPPORTED_SHELLS: + if platform.system() != 'Windows' \ + and get_shell() not in SUPPORTED_SHELLS: print("Unsupported shell: %s" % os.getenv('SHELL'), file=sys.stderr) sys.exit(1) @@ -202,7 +208,9 @@ def main(args): if args.custom_install: modify_autojump_sh(etc_dir, args.dryrun) + print_post_installation_message(etc_dir, bin_dir) + if __name__ == "__main__": sys.exit(main(parse_arguments())) diff --git a/setup.cfg b/setup.cfg index 95a794e..f917c4a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] filename = *.py,autojump -ignore = E126 +ignore = E126,E128 max-line-length = 79 max-complexity = 10 diff --git a/uninstall.py b/uninstall.py index 456a5ce..3e41fc6 100755 --- a/uninstall.py +++ b/uninstall.py @@ -146,10 +146,12 @@ def remove_user_data(dryrun=False): def remove_user_installation(dryrun=False): if platform.system() == 'Windows': - default_destdir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'autojump') + default_destdir = os.path.join(os.getenv('LOCALAPPDATA', ''), + 'autojump') clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') else: default_destdir = os.path.join(os.path.expanduser("~"), '.autojump') + if os.path.exists(default_destdir): print("\nFound user installation...") rmdir(default_destdir, dryrun)