<s> from difflib import get_close_matches <EOL> from thefuck . utils import get_all_executables , get_valid_history_without_current , get_closest <EOL> from thefuck . specific . sudo import sudo_support <EOL> @ sudo_support <EOL> def match ( command ) : <EOL> return ( command . script_parts <EOL> and '<STR_LIT>' in command . stderr <EOL> and bool ( get_close_matches ( command . script_parts [ <NUM_LIT:0> ] , <EOL> get_all_executables ( ) ) ) ) <EOL> def _get_used_executables ( command ) : <EOL> for script in get_valid_history_without_current ( command ) : <EOL> yield script . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] <EOL> @ sudo_support <EOL> def get_new_command ( command ) : <EOL> old_command = command . script_parts [ <NUM_LIT:0> ] <EOL> already_used = get_closest ( <EOL> old_command , _get_used_executables ( command ) , <EOL> fallback_to_first = False ) <EOL> if already_used : <EOL> new_cmds = [ already_used ] <EOL> else : <EOL> new_cmds = [ ] <EOL> new_cmds += [ cmd for cmd in get_close_matches ( old_command , <EOL> get_all_executables ( ) ) <EOL> if cmd not in new_cmds ] <EOL> return [ '<STR_LIT:U+0020>' . join ( [ new_command ] + command . script_parts [ <NUM_LIT:1> : ] ) <EOL> for new_command in new_cmds ] <EOL> priority = <NUM_LIT> </s>
