Example #1
0
def test_get_all_executables_exclude_paths(path, pathsep, excluded, settings):
    settings.init()
    settings.excluded_search_path_prefixes = [excluded]
    with patch('thefuck.utils.Path') as Path_mock:
        get_all_executables()
        path_list = path.split(pathsep)
        assert call(path_list[-1]) not in Path_mock.mock_calls
        assert all(call(p) in Path_mock.mock_calls for p in path_list[:-1])
Example #2
0
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]
Example #3
0
def get_new_command(command):
    old_command = command.script.split(' ')[0]
    new_cmds = get_close_matches(old_command,
                                 get_all_executables(),
                                 cutoff=0.1)
    return [
        ' '.join([new_command] + command.script.split(' ')[1:])
        for new_command in new_cmds
    ]
Example #4
0
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
    ]
Example #5
0
def get_new_command(command):
    old_command = command.script_parts[0]

    # One from history:
    already_used = get_closest(old_command,
                               _get_used_executables(command),
                               fallback_to_first=False)
    if already_used:
        new_cmds = [already_used]
    else:
        new_cmds = []

    # Other from all executables:
    new_cmds += [
        cmd for cmd in get_close_matches(old_command, get_all_executables())
        if cmd not in new_cmds
    ]

    return [command.script.replace(old_command, cmd, 1) for cmd in new_cmds]
def get_new_command(command):
    old_command = command.script_parts[0]

    # One from history:
    already_used = get_closest(
        old_command, _get_used_executables(command),
        fallback_to_first=False)
    if already_used:
        new_cmds = [already_used]
    else:
        new_cmds = []

    # Other from all executables:
    new_cmds += [cmd for cmd in get_close_matches(old_command,
                                                  get_all_executables())
                 if cmd not in new_cmds]

    return [' '.join([new_command] + command.script_parts[1:])
            for new_command in new_cmds]
Example #7
0
def match(command):
    return (command.script_parts and 'not found' in command.stderr and bool(
        get_close_matches(command.script_parts[0], get_all_executables())))
Example #8
0
def test_get_all_executables():
    all_callables = get_all_executables()
    assert 'vim' in all_callables
    assert 'fsck' in all_callables
    assert 'f**k' not in all_callables
Example #9
0
def match(command):
    return (command.script_parts
            and 'not found' in command.stderr
            and bool(get_close_matches(command.script_parts[0],
                                       get_all_executables())))
Example #10
0
def test_get_all_callables():
    all_callables = get_all_executables()
    assert 'vim' in all_callables
    assert 'fsck' in all_callables
    assert 'f**k' not in all_callables
Example #11
0
def test_get_all_executables():
    all_callables = get_all_executables()
    assert "vim" in all_callables
    assert "fsck" in all_callables
    assert "f**k" not in all_callables
def match(command):
    return (not which(command.script_parts[0])
            and ('not found' in command.output
                 or 'is not recognized as' in command.output) and bool(
                     get_close_matches(command.script_parts[0],
                                       get_all_executables())))
Example #13
0
def match(command):
    return (not command.script_parts[0] in get_all_executables()
            and len(_get_executables(command.script_parts[0])) != 0)
Example #14
0
def match(command):
    return not command.script_parts[0] in get_all_executables(
    ) and _get_executable(command.script_parts[0])
Example #15
0
def match(command, settings):
    return 'not found' in command.stderr and \
           bool(get_close_matches(command.script.split(' ')[0],
                                  get_all_executables()))
Example #16
0
def get_new_command(command, settings):
    old_command = command.script.split(' ')[0]
    new_command = get_closest(old_command, get_all_executables())
    return ' '.join([new_command] + command.script.split(' ')[1:])
Example #17
0
def match(command):
    first_part = command.script_parts[0]
    if "-" not in first_part or first_part in get_all_executables():
        return False
    cmd, _ = first_part.split("-", 1)
    return cmd in get_all_executables()
Example #18
0
def _get_executables(script_part):
    executable_list = []
    for executable in get_all_executables():
        if script_part.startswith(executable):
            executable_list.append(executable)
    return executable_list
Example #19
0
def match(command):
    return 'not found' in command.stderr and \
           bool(get_close_matches(command.script.split(' ')[0],
                                  get_all_executables()))
Example #20
0
def match(command):
    return (not which(command.script_parts[0])
            and 'not found' in command.output and bool(
                get_close_matches(command.script_parts[0],
                                  get_all_executables())))
def match(command):
    return (not command.script_parts[0] in get_all_executables()
            and _get_executable(command.script_parts[0]))
def match(command):
    return (not which(command.script_parts[0])
            and 'not found' in command.output
            and bool(get_close_matches(command.script_parts[0],
                                       get_all_executables())))
Example #23
0
def _get_executable(script_part):
    for executable in get_all_executables():
        if script_part.startswith(executable):
            return executable
Example #24
0
def test_get_all_executables_pathsep(path, pathsep):
    with patch("thefuck.utils.Path") as Path_mock:
        get_all_executables()
        Path_mock.assert_has_calls([call(p) for p in path.split(pathsep)],
                                   True)
Example #25
0
def get_new_command(command):
    old_command = command.script.split(" ")[0]
    new_cmds = get_close_matches(old_command, get_all_executables(), cutoff=0.1)
    return [" ".join([new_command] + command.script.split(" ")[1:]) for new_command in new_cmds]
Example #26
0
def test_get_all_executables():
    all_callables = get_all_executables()
    assert "vim" in all_callables
    assert "fsck" in all_callables
    assert "f**k" not in all_callables
Example #27
0
def match(command):
    return "not found" in command.stderr and bool(
        get_close_matches(command.script.split(" ")[0], get_all_executables())
    )