1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

Add Python 2.6 support back.

Closes #242.
This commit is contained in:
William Ting 2014-01-07 09:27:05 -06:00
parent 4bb6dfe1ca
commit 3f460fb3e9
11 changed files with 2385 additions and 19 deletions

View File

@ -1,6 +1,7 @@
language: python
python:
- 2.6
- 2.7
install:

View File

@ -3,10 +3,6 @@
### Release v22.0.0:
#### Deprecation
- Python 2.6 EOL'ed Oct 2013, support dropped. Now requires Python 2.7+.
#### Backwards Incompatible
- install.sh -> install.py

1
autojump_argparse.py Symbolic link
View File

@ -0,0 +1 @@
bin/autojump_argparse.py

View File

@ -21,7 +21,6 @@
from __future__ import print_function
from argparse import ArgumentParser
from difflib import SequenceMatcher
from itertools import chain
from math import sqrt
@ -39,6 +38,8 @@ else:
from itertools import ifilter
from itertools import imap
from autojump_argparse import ArgumentParser
from autojump_data import dictify
from autojump_data import entriefy
from autojump_data import Entry
@ -206,7 +207,6 @@ def handle_tab_completion(needle, entries):
TAB_SEPARATOR)
def match_anywhere(needles, haystack, ignore_case=False):
"""
Matches needles anywhere in the path as long as they're in the same (but
@ -334,7 +334,7 @@ def print_stats(data, data_path):
print("\ndata:\t %s" % data_path)
def main(args):
def main(args): # noqa
config = set_defaults()
# all arguments are mutually exclusive

2363
bin/autojump_argparse.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -31,14 +31,16 @@ def create_dir(path):
def decode(string):
"""Converts byte string to Unicode string."""
if is_python2():
return string.decode('utf-8', errors='replace')
# Python 2.6 does not support kwargs
return string.decode('utf-8', 'replace')
return string
def encode(string):
"""Converts Unicode string to byte string."""
if is_python2():
return string.encode('utf-8', errors='replace')
# Python 2.6 does not support kwargs
return string.encode('utf-8', 'replace')
return string
@ -192,8 +194,9 @@ def surround_quotes(string):
Bash has problems dealing with certain paths so we're surrounding all
path outputs with quotes.
"""
if in_bash():
return '"{}"'.format(string)
if in_bash() and string:
# Python 2.6 requres field numbers
return '"{0}"'.format(string)
return string

View File

@ -3,12 +3,12 @@
from __future__ import print_function
from argparse import ArgumentParser
import os
import platform
import shutil
import sys
from autojump_argparse import ArgumentParser
SUPPORTED_SHELLS = ('bash', 'zsh', 'fish')
@ -74,8 +74,8 @@ def parse_arguments():
args = parser.parse_args()
if not args.force:
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
print("Python v2.7+ or v3.0+ required.", file=sys.stderr)
if sys.version_info[0] == 2 and sys.version_info[1] < 6:
print("Python v2.6+ or v3.0+ required.", file=sys.stderr)
sys.exit(1)
if get_shell() not in SUPPORTED_SHELLS:
@ -131,9 +131,9 @@ def print_post_installation_message(etc_dir):
def main(args):
if args.dryrun:
print("\nInstalling autojump to %s (DRYRUN)..." % args.destdir)
print("Installing autojump to %s (DRYRUN)..." % args.destdir)
else:
print("\nInstalling autojump to %s ..." % args.destdir)
print("Installing autojump to %s ..." % args.destdir)
bin_dir = os.path.join(args.destdir, args.prefix, 'bin')
etc_dir = os.path.join(args.destdir, 'etc/profile.d')
@ -148,6 +148,7 @@ def main(args):
mkdir(zshshare_dir, args.dryrun)
cp('./bin/autojump', bin_dir, args.dryrun)
cp('./bin/autojump_argparse.py', bin_dir, args.dryrun)
cp('./bin/autojump_data.py', bin_dir, args.dryrun)
cp('./bin/autojump_utils.py', bin_dir, args.dryrun)
cp('./bin/autojump.sh', etc_dir, args.dryrun)

View File

@ -1,6 +1,5 @@
[flake8]
filename = *.py,autojump
exclude = argparse.py,autojump_ipython.py
ignore = E126
max-line-length = 79
max-complexity = 10

1
tests/autojump_argparse.py Symbolic link
View File

@ -0,0 +1 @@
../bin/autojump_argparse.py

View File

@ -18,7 +18,7 @@ from subprocess import PIPE
from IPython.core.magic import register_line_magic
ip = get_ipython()
ip = get_ipython() # noqa
@register_line_magic

View File

@ -3,12 +3,13 @@
from __future__ import print_function
from argparse import ArgumentParser
import os
import platform
import shutil
import sys
from autojump_argparse import ArgumentParser
def is_empty_dir(path):
"""