mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
Before: 4 E101 indentation contains mixed spaces and tabs 20 E122 continuation line missing indentation or outdented 1 E124 closing bracket does not match visual indentation 12 E127 continuation line over-indented for visual indent 22 E128 continuation line under-indented for visual indent 2 E211 whitespace before '(' 12 E302 expected 2 blank lines, found 1 1 E303 too many blank lines (3) 4 E402 module level import not at top of file 123 E501 line too long (81 > 79 characters) 2 E731 do not assign a lambda expression, use a def 3 W191 indentation contains tabs 20 W291 trailing whitespace 3 W293 blank line contains whitespace 2 W391 blank line at end of file 69 W503 line break before binary operator After: 20 E122 continuation line missing indentation or outdented 12 E127 continuation line over-indented for visual indent 22 E128 continuation line under-indented for visual indent 123 E501 line too long (81 > 79 characters) 2 E731 do not assign a lambda expression, use a def 1 W291 trailing whitespace 68 W503 line break before binary operator
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from difflib import get_close_matches
|
|
from thefuck.shells import get_history, thefuck_alias
|
|
from thefuck.utils import get_closest, memoize, get_all_executables
|
|
|
|
|
|
def _not_corrected(history, tf_alias):
|
|
"""Returns all lines from history except that comes before `fuck`."""
|
|
previous = None
|
|
for line in history:
|
|
if previous is not None and line != tf_alias:
|
|
yield previous
|
|
previous = line
|
|
if history:
|
|
yield history[-1]
|
|
|
|
|
|
@memoize
|
|
def _history_of_exists_without_current(command):
|
|
history = get_history()
|
|
tf_alias = thefuck_alias()
|
|
executables = get_all_executables()
|
|
return [line for line in _not_corrected(history, tf_alias)
|
|
if not line.startswith(tf_alias) and not line == command.script
|
|
and line.split(' ')[0] in executables]
|
|
|
|
|
|
def match(command, settings):
|
|
return len(get_close_matches(command.script,
|
|
_history_of_exists_without_current(command)))
|
|
|
|
|
|
def get_new_command(command, settings):
|
|
return get_closest(command.script,
|
|
_history_of_exists_without_current(command))
|
|
|
|
|
|
priority = 9999
|