mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 12:58:33 +00:00
#205 Fix import in cd_correction
This commit is contained in:
parent
dc53f58b2a
commit
6590da623f
@ -4,16 +4,18 @@ __author__ = "mmussomele"
|
|||||||
"""Attempts to spellcheck and correct failed cd commands"""
|
"""Attempts to spellcheck and correct failed cd commands"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import cd_mkdir
|
|
||||||
from difflib import get_close_matches
|
from difflib import get_close_matches
|
||||||
from thefuck.utils import sudo_support
|
from thefuck.utils import sudo_support
|
||||||
|
from thefuck.rules import cd_mkdir
|
||||||
|
|
||||||
MAX_ALLOWED_DIFF = 0.6
|
MAX_ALLOWED_DIFF = 0.6
|
||||||
|
|
||||||
|
|
||||||
def _get_sub_dirs(parent):
|
def _get_sub_dirs(parent):
|
||||||
"""Returns a list of the child directories of the given parent directory"""
|
"""Returns a list of the child directories of the given parent directory"""
|
||||||
return [child for child in os.listdir(parent) if os.path.isdir(os.path.join(parent, child))]
|
return [child for child in os.listdir(parent) if os.path.isdir(os.path.join(parent, child))]
|
||||||
|
|
||||||
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
"""Match function copied from cd_mkdir.py"""
|
"""Match function copied from cd_mkdir.py"""
|
||||||
@ -21,6 +23,7 @@ def match(command, settings):
|
|||||||
and ('no such file or directory' in command.stderr.lower()
|
and ('no such file or directory' in command.stderr.lower()
|
||||||
or 'cd: can\'t cd to' in command.stderr.lower()))
|
or 'cd: can\'t cd to' in command.stderr.lower()))
|
||||||
|
|
||||||
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
"""
|
"""
|
||||||
@ -46,4 +49,5 @@ def get_new_command(command, settings):
|
|||||||
return cd_mkdir.get_new_command(command, settings)
|
return cd_mkdir.get_new_command(command, settings)
|
||||||
return "cd {0}".format(cwd)
|
return "cd {0}".format(cwd)
|
||||||
|
|
||||||
|
|
||||||
enabled_by_default = True
|
enabled_by_default = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user