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])
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 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 ]
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 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]
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())))
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 (command.script_parts and 'not found' in command.stderr and bool(get_close_matches(command.script_parts[0], get_all_executables())))
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
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())))
def match(command): return (not command.script_parts[0] in get_all_executables() and len(_get_executables(command.script_parts[0])) != 0)
def match(command): return not command.script_parts[0] in get_all_executables( ) and _get_executable(command.script_parts[0])
def match(command, settings): return 'not found' in command.stderr and \ bool(get_close_matches(command.script.split(' ')[0], get_all_executables()))
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:])
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()
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
def match(command): return 'not found' in command.stderr and \ bool(get_close_matches(command.script.split(' ')[0], get_all_executables()))
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())))
def _get_executable(script_part): for executable in get_all_executables(): if script_part.startswith(executable): return executable
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)
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]
def match(command): return "not found" in command.stderr and bool( get_close_matches(command.script.split(" ")[0], get_all_executables()) )