mirror of
https://github.com/wting/autojump
synced 2026-03-02 03:49:26 +00:00
remove unused imports, minor formatting cleanup
This commit is contained in:
17
bin/autojump
17
bin/autojump
@@ -22,13 +22,11 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from difflib import SequenceMatcher
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
from math import sqrt
|
||||
from operator import attrgetter
|
||||
from operator import itemgetter
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
|
||||
@@ -61,7 +59,6 @@ from utils import last
|
||||
from utils import print_entry
|
||||
from utils import print_tab_menu
|
||||
from utils import sanitize
|
||||
from utils import second
|
||||
from utils import surround_quotes
|
||||
from utils import take
|
||||
|
||||
@@ -142,7 +139,7 @@ def add_path(data, path, increment=10):
|
||||
return data, Entry(path, 0)
|
||||
|
||||
if path in data:
|
||||
data[path] = sqrt((data[path]**2) + (increment**2))
|
||||
data[path] = sqrt((data[path] ** 2) + (increment ** 2))
|
||||
else:
|
||||
data[path] = increment
|
||||
|
||||
@@ -152,7 +149,7 @@ def add_path(data, path, increment=10):
|
||||
def decrease_path(data, path, increment=15):
|
||||
"""Decrease weight of existing path."""
|
||||
path = decode(path).rstrip(os.sep)
|
||||
data[path] = max(0, data[path]-increment)
|
||||
data[path] = max(0, data[path] - increment)
|
||||
return data, Entry(path, data[path])
|
||||
|
||||
|
||||
@@ -212,7 +209,10 @@ def match_anywhere(needles, haystack, ignore_case=False):
|
||||
"""
|
||||
regex_needle = '.*' + '.*'.join(needles) + '.*'
|
||||
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
|
||||
found = lambda haystack: re.search(regex_needle, haystack.path, flags=regex_flags)
|
||||
found = lambda haystack: re.search(
|
||||
regex_needle,
|
||||
haystack.path,
|
||||
flags=regex_flags)
|
||||
return ifilter(found, haystack)
|
||||
|
||||
|
||||
@@ -289,8 +289,7 @@ def match_fuzzy(needles, haystack, ignore_case=False):
|
||||
match_percent = lambda entry: SequenceMatcher(
|
||||
a=needle,
|
||||
b=end_dir(entry.path)).ratio()
|
||||
meets_threshold = lambda entry: match_percent(entry) \
|
||||
>= FUZZY_MATCH_THRESHOLD
|
||||
meets_threshold = lambda entry: match_percent(entry) >= FUZZY_MATCH_THRESHOLD
|
||||
return ifilter(meets_threshold, haystack)
|
||||
|
||||
|
||||
@@ -344,7 +343,7 @@ def main(args):
|
||||
old_data = load(config)
|
||||
new_data = dictify(purge_missing_paths(entriefy(old_data)))
|
||||
save(config, new_data)
|
||||
print("Purged %d entries." % (len(old_data)-len(new_data)))
|
||||
print("Purged %d entries." % (len(old_data) - len(new_data)))
|
||||
elif args.stat:
|
||||
print_stats(load(config), config['data_path'])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user