<s> import sys <EOL> from acrylamid import compat <EOL> from acrylamid . compat import text_type as str , string_types <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> import colorama <EOL> colorama . init ( ) <EOL> @ compat . implements_to_string <EOL> class ANSIString ( object ) : <EOL> style = <NUM_LIT:0> <EOL> color = <NUM_LIT:30> <EOL> def __init__ ( self , obj , style = None , color = None ) : <EOL> if isinstance ( obj , ANSIString ) : <EOL> if style is None : <EOL> style = obj . style <EOL> if color is None : <EOL> color = obj . color <EOL> obj = obj . obj <EOL> elif not isinstance ( obj , string_types ) : <EOL> obj = str ( obj ) <EOL> self . obj = obj <EOL> if style : <EOL> self . style = style <EOL> if color : <EOL> self . color = color <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . style , self . color ) + self . obj + '<STR_LIT>' <EOL> def __add__ ( self , other ) : <EOL> return str . __add__ ( str ( self ) , other ) <EOL> def __radd__ ( self , other ) : <EOL> return other + str ( self ) <EOL> def encode ( self , encoding ) : <EOL> return str ( self ) . encode ( encoding ) <EOL> normal , bold , underline = [ lambda obj , x = x : ANSIString ( obj , style = x ) <EOL> for x in ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:4> ) ] <EOL> black , red , green , yellow , blue , magenta , cyan , white = [ lambda obj , y = y : ANSIString ( obj , color = y ) <EOL> for y in range ( <NUM_LIT:30> , <NUM_LIT> ) ] </s>
