1
0
mirror of https://github.com/wting/autojump synced 2026-03-02 03:49:26 +00:00

linter cleanup

This commit is contained in:
William Ting
2013-12-28 11:34:13 -06:00
parent 16d6e0cbcc
commit a8057ed1db
4 changed files with 33 additions and 24 deletions

View File

@@ -2,21 +2,21 @@
# -*- coding: utf-8 -*-
"""
Copyright © 2008-2012 Joel Schaerer
Copyright © 2012-2013 William Ting
Copyright © 2012-2014 William Ting
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
from __future__ import print_function
@@ -93,9 +93,12 @@ def set_defaults():
def parse_arguments():
"""Evaluate arguments and run appropriate logic, returning an error code."""
"""
Evaluate arguments and run appropriate logic, returning an error code.
"""
parser = ArgumentParser(
description='Automatically jump to directory passed as an argument.',
description='Automatically jump to directory passed as an \
argument.',
epilog="Please see autojump(1) man pages for full documentation.")
parser.add_argument(
'directory', metavar='DIRECTORY', nargs='*', default='',
@@ -131,8 +134,9 @@ def add_path(data, path, increment=10):
"""
Add a new path or increment an existing one.
os.path.realpath() is not used because users prefer to have short, symlinked
paths with duplicate entries in the database than a single canonical path.
os.path.realpath() is not used because users prefer to have short,
symlinked paths with duplicate entries in the database than a single
canonical path.
"""
path = decode(path).rstrip(os.sep)
if path == os.path.expanduser('~'):
@@ -182,7 +186,6 @@ def find_matches(entries, needles):
exists,
chain(
match_consecutive(needles, data, ignore_case),
match_quicksilver(needles, data, ignore_case),
match_fuzzy(needles, data, ignore_case),
match_anywhere(needles, data, ignore_case),
# default return value so calling shell functions have an
@@ -289,14 +292,11 @@ 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)
def match_quicksilver(needles, haystack, ignore_case=False):
return []
def purge_missing_paths(entries):
"""Remove non-existent paths from a list of entries."""
exists = lambda entry: os.path.exists(entry.path)
@@ -348,6 +348,8 @@ def main(args):
print_stats(load(config), config['data_path'])
else:
if not args.directory:
# default return value so calling shell functions have an
# argument to `cd` to
print(encode_local('.'))
return 0