<s> import sys <EOL> from httpie . compat import is_windows <EOL> from httpie . config import DEFAULT_CONFIG_DIR , Config <EOL> from httpie . utils import repr_dict_nice <EOL> class Environment ( object ) : <EOL> """<STR_LIT>""" <EOL> is_windows = is_windows <EOL> config_dir = DEFAULT_CONFIG_DIR <EOL> stdin = sys . stdin <EOL> stdin_isatty = stdin . isatty ( ) <EOL> stdin_encoding = None <EOL> stdout = sys . stdout <EOL> stdout_isatty = stdout . isatty ( ) <EOL> stdout_encoding = None <EOL> stderr = sys . stderr <EOL> stderr_isatty = stderr . isatty ( ) <EOL> colors = <NUM_LIT> <EOL> if not is_windows : <EOL> import curses <EOL> try : <EOL> curses . setupterm ( ) <EOL> try : <EOL> colors = curses . tigetnum ( '<STR_LIT>' ) <EOL> except TypeError : <EOL> colors = curses . tigetnum ( b'<STR_LIT>' ) <EOL> except curses . error : <EOL> pass <EOL> del curses <EOL> else : <EOL> import colorama . initialise <EOL> stdout = colorama . initialise . wrap_stream ( <EOL> stdout , convert = None , strip = None , <EOL> autoreset = True , wrap = True <EOL> ) <EOL> stderr = colorama . initialise . wrap_stream ( <EOL> stderr , convert = None , strip = None , <EOL> autoreset = True , wrap = True <EOL> ) <EOL> del colorama <EOL> def __init__ ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> assert all ( hasattr ( type ( self ) , attr ) for attr in kwargs . keys ( ) ) <EOL> self . __dict__ . update ( ** kwargs ) <EOL> if self . stdin_encoding is None : <EOL> self . stdin_encoding = getattr ( <EOL> self . stdin , '<STR_LIT>' , None ) or '<STR_LIT:utf8>' <EOL> if self . stdout_encoding is None : <EOL> actual_stdout = self . stdout <EOL> if is_windows : <EOL> from colorama import AnsiToWin32 <EOL> if isinstance ( self . stdout , AnsiToWin32 ) : <EOL> actual_stdout = self . stdout . wrapped <EOL> self . stdout_encoding = getattr ( <EOL> actual_stdout , '<STR_LIT>' , None ) or '<STR_LIT:utf8>' <EOL> @ property <EOL> def config ( self ) : <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _config = Config ( directory = self . config_dir ) <EOL> if self . _config . is_new ( ) : <EOL> self . _config . save ( ) <EOL> else : <EOL> self . _config . load ( ) <EOL> return self . _config <EOL> def __str__ ( self ) : <EOL> defaults = dict ( type ( self ) . __dict__ ) <EOL> actual = dict ( defaults ) <EOL> actual . update ( self . __dict__ ) <EOL> actual [ '<STR_LIT>' ] = self . config <EOL> return repr_dict_nice ( dict ( <EOL> ( key , value ) <EOL> for key , value in actual . items ( ) <EOL> if not key . startswith ( '<STR_LIT:_>' ) ) <EOL> ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' . format ( type ( self ) . __name__ , str ( self ) ) </s>
