mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
use is_python2()
This commit is contained in:
parent
195312acad
commit
46aaeb193b
35
bin/autojump
35
bin/autojump
@ -315,16 +315,23 @@ def parse_arg(config):
|
|||||||
config['args'] = args
|
config['args'] = args
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def decode(text, encoding=None, errors="strict"):
|
#
|
||||||
|
# Utilities
|
||||||
|
#
|
||||||
|
|
||||||
|
def is_python2():
|
||||||
|
return sys.version_info[0] == 2
|
||||||
|
|
||||||
|
def decode(text, encoding=None, errors='strict'):
|
||||||
"""
|
"""
|
||||||
Decoding step for Python 2 which does not default to unicode.
|
Decoding step for Python 2 which does not default to unicode.
|
||||||
"""
|
"""
|
||||||
if sys.version_info[0] > 2:
|
if is_python2():
|
||||||
return text
|
if not encoding:
|
||||||
else:
|
|
||||||
if encoding is None:
|
|
||||||
encoding = sys.getfilesystemencoding()
|
encoding = sys.getfilesystemencoding()
|
||||||
return text.decode(encoding, errors)
|
return text.decode(encoding, errors)
|
||||||
|
else:
|
||||||
|
return text
|
||||||
|
|
||||||
def output_quotes(config, text):
|
def output_quotes(config, text):
|
||||||
quotes = ""
|
quotes = ""
|
||||||
@ -338,21 +345,25 @@ def output(text, encoding=None):
|
|||||||
Wrapper for the print function, using the filesystem encoding by default
|
Wrapper for the print function, using the filesystem encoding by default
|
||||||
to minimize encoding mismatch problems in directory names.
|
to minimize encoding mismatch problems in directory names.
|
||||||
"""
|
"""
|
||||||
if sys.version_info[0] > 2:
|
if is_python2():
|
||||||
print(text)
|
if not encoding:
|
||||||
else:
|
|
||||||
if encoding is None:
|
|
||||||
encoding = sys.getfilesystemencoding()
|
encoding = sys.getfilesystemencoding()
|
||||||
print(unicode(text).encode(encoding))
|
print(unicode(text).encode(encoding))
|
||||||
|
else:
|
||||||
|
print(text)
|
||||||
|
|
||||||
def unico(text):
|
def unico(text):
|
||||||
"""
|
"""
|
||||||
If Python 2, convert to a unicode object.
|
If Python 2, convert to a unicode object.
|
||||||
"""
|
"""
|
||||||
if sys.version_info[0] > 2:
|
if is_python2():
|
||||||
return text
|
|
||||||
else:
|
|
||||||
return unicode(text)
|
return unicode(text)
|
||||||
|
else:
|
||||||
|
return text
|
||||||
|
|
||||||
|
#
|
||||||
|
# Main Logic
|
||||||
|
#
|
||||||
|
|
||||||
def match(path, pattern, only_end=False, ignore_case=False):
|
def match(path, pattern, only_end=False, ignore_case=False):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user