<s> import io <EOL> import os <EOL> import shlex <EOL> import six <EOL> from . . utils import memoize <EOL> from . . conf import settings <EOL> class Generic ( object ) : <EOL> def get_aliases ( self ) : <EOL> return { } <EOL> def _expand_aliases ( self , command_script ) : <EOL> aliases = self . get_aliases ( ) <EOL> binary = command_script . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] <EOL> if binary in aliases : <EOL> return command_script . replace ( binary , aliases [ binary ] , <NUM_LIT:1> ) <EOL> else : <EOL> return command_script <EOL> def from_shell ( self , command_script ) : <EOL> """<STR_LIT>""" <EOL> return self . _expand_aliases ( command_script ) <EOL> def to_shell ( self , command_script ) : <EOL> """<STR_LIT>""" <EOL> return command_script <EOL> def app_alias ( self , fuck ) : <EOL> return "<STR_LIT>" "<STR_LIT>" . format ( fuck ) <EOL> def _get_history_file_name ( self ) : <EOL> return '<STR_LIT>' <EOL> def _get_history_line ( self , command_script ) : <EOL> return '<STR_LIT>' <EOL> @ memoize <EOL> def get_history ( self ) : <EOL> return list ( self . _get_history_lines ( ) ) <EOL> def _get_history_lines ( self ) : <EOL> """<STR_LIT>""" <EOL> history_file_name = self . _get_history_file_name ( ) <EOL> if os . path . isfile ( history_file_name ) : <EOL> with io . open ( history_file_name , '<STR_LIT:r>' , <EOL> encoding = '<STR_LIT:utf-8>' , errors = '<STR_LIT:ignore>' ) as history_file : <EOL> lines = history_file . readlines ( ) <EOL> if settings . history_limit : <EOL> lines = lines [ - settings . history_limit : ] <EOL> for line in lines : <EOL> prepared = self . _script_from_history ( line ) . strip ( ) <EOL> if prepared : <EOL> yield prepared <EOL> def and_ ( self , * commands ) : <EOL> return u'<STR_LIT>' . join ( commands ) <EOL> def how_to_configure ( self ) : <EOL> return <EOL> def split_command ( self , command ) : <EOL> """<STR_LIT>""" <EOL> if six . PY2 : <EOL> return [ s . decode ( '<STR_LIT:utf8>' ) for s in shlex . split ( command . encode ( '<STR_LIT:utf8>' ) ) ] <EOL> return shlex . split ( command ) <EOL> def quote ( self , s ) : <EOL> """<STR_LIT>""" <EOL> if six . PY2 : <EOL> from pipes import quote <EOL> else : <EOL> from shlex import quote <EOL> return quote ( s ) <EOL> def _script_from_history ( self , line ) : <EOL> return line <EOL> def put_to_history ( self , command ) : <EOL> """<STR_LIT>""" </s>
