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 language: python
python: python:
- 2.6
- 2.7 - 2.7
install: install:

View File

@ -3,10 +3,6 @@
### Release v22.0.0: ### Release v22.0.0:
#### Deprecation
- Python 2.6 EOL'ed Oct 2013, support dropped. Now requires Python 2.7+.
#### Backwards Incompatible #### Backwards Incompatible
- install.sh -> install.py - 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 __future__ import print_function
from argparse import ArgumentParser
from difflib import SequenceMatcher from difflib import SequenceMatcher
from itertools import chain from itertools import chain
from math import sqrt from math import sqrt
@ -39,6 +38,8 @@ else:
from itertools import ifilter from itertools import ifilter
from itertools import imap from itertools import imap
from autojump_argparse import ArgumentParser
from autojump_data import dictify from autojump_data import dictify
from autojump_data import entriefy from autojump_data import entriefy
from autojump_data import Entry from autojump_data import Entry
@ -206,7 +207,6 @@ def handle_tab_completion(needle, entries):
TAB_SEPARATOR) TAB_SEPARATOR)
def match_anywhere(needles, haystack, ignore_case=False): def match_anywhere(needles, haystack, ignore_case=False):
""" """
Matches needles anywhere in the path as long as they're in the same (but 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) print("\ndata:\t %s" % data_path)
def main(args): def main(args): # noqa
config = set_defaults() config = set_defaults()
# all arguments are mutually exclusive # 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): def decode(string):
"""Converts byte string to Unicode string.""" """Converts byte string to Unicode string."""
if is_python2(): 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 return string
def encode(string): def encode(string):
"""Converts Unicode string to byte string.""" """Converts Unicode string to byte string."""
if is_python2(): 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 return string
@ -192,8 +194,9 @@ def surround_quotes(string):
Bash has problems dealing with certain paths so we're surrounding all Bash has problems dealing with certain paths so we're surrounding all
path outputs with quotes. path outputs with quotes.
""" """
if in_bash(): if in_bash() and string:
return '"{}"'.format(string) # Python 2.6 requres field numbers
return '"{0}"'.format(string)
return string return string

View File

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

View File

@ -1,6 +1,5 @@
[flake8] [flake8]
filename = *.py,autojump filename = *.py,autojump
exclude = argparse.py,autojump_ipython.py
ignore = E126 ignore = E126
max-line-length = 79 max-line-length = 79
max-complexity = 10 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 from IPython.core.magic import register_line_magic
ip = get_ipython() ip = get_ipython() # noqa
@register_line_magic @register_line_magic

View File

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