@ -45,8 +45,6 @@ from autojump_data import entriefy
from autojump_data import Entry
from autojump_data import load
from autojump_data import save
from autojump_utils import decode
from autojump_utils import encode_local
from autojump_utils import first
from autojump_utils import get_tab_entry_info
from autojump_utils import get_pwd
@ -54,9 +52,11 @@ from autojump_utils import has_uppercase
from autojump_utils import is_osx
from autojump_utils import last
from autojump_utils import print_entry
from autojump_utils import print_local
from autojump_utils import print_tab_menu
from autojump_utils import sanitize
from autojump_utils import take
from autojump_utils import unico
VERSION = '22.0.0-alpha'
FUZZY_MATCH_THRESHOLD = 0.6
@ -131,7 +131,7 @@ def add_path(data, path, weight=10):
with resulting duplicate entries in the database than a single canonical
path.
"""
path = decode (path).rstrip(os.sep)
path = unico (path).rstrip(os.sep)
if path == os.path.expanduser('~'):
return data, Entry(path, 0)
@ -142,7 +142,7 @@ def add_path(data, path, weight=10):
def decrease_path(data, path, weight=15):
"""Decrease or zero out a path."""
path = decode (path).rstrip(os.sep)
path = unico (path).rstrip(os.sep)
data[path] = max(0, data.get(path, 0) - weight)
return data, Entry(path, data[path])
@ -189,11 +189,10 @@ def handle_tab_completion(needle, entries):
tab_needle, tab_index, tab_path = get_tab_entry_info(needle, TAB_SEPARATOR)
if tab_path:
print(encode _local(tab_path))
print_local(tab_path)
elif tab_index:
get_ith_path = lambda i, iterable: last(take(i, iterable)).path
print(encode_local(
get_ith_path(tab_index, find_matches(entries, tab_needle))))
print_local(get_ith_path(tab_index, find_matches(entries, tab_needle)))
elif tab_needle:
# found partial tab completion entry
print_tab_menu(
@ -326,7 +325,8 @@ def print_stats(data, data_path):
print("%d:\t number of entries" % len(data))
try:
print("%.2f:\t current directory weight" % data.get(os.getcwdu(), 0))
print_local(
"%.2f:\t current directory weight" % data.get(os.getcwdu(), 0))
except OSError:
# current directory no longer exists
pass
@ -362,7 +362,7 @@ def main(args): # noqa
elif not args.directory:
# default return value so calling shell functions have an argument
# to `cd` to
print(encode _local('.'))
print_local('.')
else:
entries = entriefy(load(config))
needles = sanitize(args.directory)
@ -370,13 +370,13 @@ def main(args): # noqa
get_tab_entry_info(first(needles), TAB_SEPARATOR)
if tab_path:
print(encode _local(tab_path))
print_local(tab_path)
elif tab_index:
get_ith_path = lambda i, iterable: last(take(i, iterable)).path
print(encode _local(
get_ith_path(tab_index, find_matches(entries, tab_needle) )))
print_local(
get_ith_path(tab_index, find_matches(entries, tab_needle)))
else:
print(encode _local(first(find_matches(entries, needles)).path))
print_local(first(find_matches(entries, needles)).path)
return 0