<s> import os <EOL> import re <EOL> from thefuck . utils import get_closest , replace_command <EOL> from thefuck . specific . brew import get_brew_path_prefix , brew_available <EOL> BREW_CMD_PATH = '<STR_LIT>' <EOL> TAP_PATH = '<STR_LIT>' <EOL> TAP_CMD_PATH = '<STR_LIT>' <EOL> enabled_by_default = brew_available <EOL> def _get_brew_commands ( brew_path_prefix ) : <EOL> """<STR_LIT>""" <EOL> brew_cmd_path = brew_path_prefix + BREW_CMD_PATH <EOL> return [ name [ : - <NUM_LIT:3> ] for name in os . listdir ( brew_cmd_path ) <EOL> if name . endswith ( '<STR_LIT>' ) ] <EOL> def _get_brew_tap_specific_commands ( brew_path_prefix ) : <EOL> """<STR_LIT>""" <EOL> commands = [ ] <EOL> brew_taps_path = brew_path_prefix + TAP_PATH <EOL> for user in _get_directory_names_only ( brew_taps_path ) : <EOL> taps = _get_directory_names_only ( brew_taps_path + '<STR_LIT>' % user ) <EOL> taps = ( tap for tap in taps if tap . startswith ( '<STR_LIT>' ) ) <EOL> for tap in taps : <EOL> tap_cmd_path = brew_taps_path + TAP_CMD_PATH % ( user , tap ) <EOL> if os . path . isdir ( tap_cmd_path ) : <EOL> commands += ( name . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> for name in os . listdir ( tap_cmd_path ) <EOL> if _is_brew_tap_cmd_naming ( name ) ) <EOL> return commands <EOL> def _is_brew_tap_cmd_naming ( name ) : <EOL> return name . startswith ( '<STR_LIT>' ) and name . endswith ( '<STR_LIT>' ) <EOL> def _get_directory_names_only ( path ) : <EOL> return [ d for d in os . listdir ( path ) <EOL> if os . path . isdir ( os . path . join ( path , d ) ) ] <EOL> def _brew_commands ( ) : <EOL> brew_path_prefix = get_brew_path_prefix ( ) <EOL> if brew_path_prefix : <EOL> try : <EOL> return _get_brew_commands ( brew_path_prefix ) + _get_brew_tap_specific_commands ( brew_path_prefix ) <EOL> except OSError : <EOL> pass <EOL> return [ '<STR_LIT:info>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:list>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def match ( command ) : <EOL> is_proper_command = ( '<STR_LIT>' in command . script and <EOL> '<STR_LIT>' in command . stderr ) <EOL> if is_proper_command : <EOL> broken_cmd = re . findall ( r'<STR_LIT>' , <EOL> command . stderr ) [ <NUM_LIT:0> ] <EOL> return bool ( get_closest ( broken_cmd , _brew_commands ( ) ) ) <EOL> return False <EOL> def get_new_command ( command ) : <EOL> broken_cmd = re . findall ( r'<STR_LIT>' , <EOL> command . stderr ) [ <NUM_LIT:0> ] <EOL> return replace_command ( command , broken_cmd , _brew_commands ( ) ) </s>
