mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
whitespace fixes
This commit is contained in:
parent
6e0e3741a5
commit
5f9ac19afd
@ -263,10 +263,14 @@ def match_consecutive(needles, haystack, ignore_case=False):
|
|||||||
(path="/moo/foo/baz", weight=10),
|
(path="/moo/foo/baz", weight=10),
|
||||||
(path="/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_no_sep = '[^' + sep + ']*'
|
||||||
regex_one_sep = regex_no_sep + sep + regex_no_sep
|
|
||||||
regex_no_sep_end = 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
|
# can't use compiled regex because of flags
|
||||||
regex_needle = regex_one_sep.join(needles) + regex_no_sep_end
|
regex_needle = regex_one_sep.join(needles) + regex_no_sep_end
|
||||||
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
|
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
|
||||||
|
20
install.py
20
install.py
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -44,7 +43,9 @@ def modify_autojump_sh(etc_dir, dryrun=False):
|
|||||||
|
|
||||||
def modify_autojump_lua(clink_dir, bin_dir, dryrun=False):
|
def modify_autojump_lua(clink_dir, bin_dir, dryrun=False):
|
||||||
"""Prepend custom AUTOJUMP_BIN_DIR definition to autojump.lua"""
|
"""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')
|
clink_file = os.path.join(clink_dir, 'autojump.lua')
|
||||||
with open(clink_file, 'r') as f:
|
with open(clink_file, 'r') as f:
|
||||||
original = f.read()
|
original = f.read()
|
||||||
@ -52,11 +53,15 @@ def modify_autojump_lua(clink_dir, bin_dir, dryrun=False):
|
|||||||
f.write(custom_install + original)
|
f.write(custom_install + original)
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments(): # noqa
|
||||||
if platform.system() == 'Windows':
|
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:
|
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_prefix = ''
|
||||||
default_user_zshshare = 'functions'
|
default_user_zshshare = 'functions'
|
||||||
default_system_destdir = '/'
|
default_system_destdir = '/'
|
||||||
@ -105,7 +110,8 @@ def parse_arguments():
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
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'),
|
print("Unsupported shell: %s" % os.getenv('SHELL'),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -202,7 +208,9 @@ def main(args):
|
|||||||
if args.custom_install:
|
if args.custom_install:
|
||||||
modify_autojump_sh(etc_dir, args.dryrun)
|
modify_autojump_sh(etc_dir, args.dryrun)
|
||||||
|
|
||||||
|
|
||||||
print_post_installation_message(etc_dir, bin_dir)
|
print_post_installation_message(etc_dir, bin_dir)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main(parse_arguments()))
|
sys.exit(main(parse_arguments()))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
filename = *.py,autojump
|
filename = *.py,autojump
|
||||||
ignore = E126
|
ignore = E126,E128
|
||||||
max-line-length = 79
|
max-line-length = 79
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
|
@ -146,10 +146,12 @@ def remove_user_data(dryrun=False):
|
|||||||
|
|
||||||
def remove_user_installation(dryrun=False):
|
def remove_user_installation(dryrun=False):
|
||||||
if platform.system() == 'Windows':
|
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')
|
clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink')
|
||||||
else:
|
else:
|
||||||
default_destdir = os.path.join(os.path.expanduser("~"), '.autojump')
|
default_destdir = os.path.join(os.path.expanduser("~"), '.autojump')
|
||||||
|
|
||||||
if os.path.exists(default_destdir):
|
if os.path.exists(default_destdir):
|
||||||
print("\nFound user installation...")
|
print("\nFound user installation...")
|
||||||
rmdir(default_destdir, dryrun)
|
rmdir(default_destdir, dryrun)
|
||||||
|
Loading…
Reference in New Issue
Block a user