<s> import os <EOL> import sys <EOL> import time <EOL> import threading <EOL> import unicodedata <EOL> class SpinCursor ( threading . Thread ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , msg = '<STR_LIT>' , maxspin = <NUM_LIT:0> , minspin = <NUM_LIT:10> , speed = <NUM_LIT:5> ) : <EOL> self . count = <NUM_LIT:0> <EOL> self . out = sys . stdout <EOL> self . flag = False <EOL> self . max = maxspin <EOL> self . min = minspin <EOL> self . msg = msg <EOL> self . string = '<STR_LIT>' <EOL> self . waittime = <NUM_LIT:1.0> / float ( speed * <NUM_LIT:4> ) <EOL> if os . name == '<STR_LIT>' : <EOL> self . spinchars = ( unicodedata . lookup ( '<STR_LIT>' ) , u'<STR_LIT>' , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> else : <EOL> self . spinchars = ( u'<STR_LIT:->' , u'<STR_LIT>' , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> threading . Thread . __init__ ( self , None , None , "<STR_LIT>" ) <EOL> def spin ( self ) : <EOL> """<STR_LIT>""" <EOL> for x in self . spinchars : <EOL> self . string = self . msg + "<STR_LIT>" + x + "<STR_LIT:\r>" <EOL> self . out . write ( self . string . encode ( '<STR_LIT:utf-8>' ) ) <EOL> self . out . flush ( ) <EOL> time . sleep ( self . waittime ) <EOL> def run ( self ) : <EOL> while ( not self . flag ) and ( ( self . count < self . min ) or ( self . count < self . max ) ) : <EOL> self . spin ( ) <EOL> self . count += <NUM_LIT:1> <EOL> self . out . write ( "<STR_LIT:U+0020>" * ( len ( self . string ) + <NUM_LIT:1> ) ) <EOL> def stop ( self ) : <EOL> self . flag = True <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = dict ( zip ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> range ( <NUM_LIT:1> , <NUM_LIT:9> ) ) <EOL> ) <EOL> del ATTRIBUTES [ '<STR_LIT>' ] <EOL> HIGHLIGHTS = dict ( zip ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> range ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> ) <EOL> ATTRIBUTES . update ( HIGHLIGHTS ) <EOL> COLORS = dict ( zip ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> [ "<STR_LIT>" % x for x in range ( <NUM_LIT:30> , <NUM_LIT> ) ] ) <EOL> ) <EOL> ATTRIBUTES . update ( COLORS ) <EOL> DARKCOLORS = dict ( zip ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> [ "<STR_LIT>" % x for x in range ( <NUM_LIT:30> , <NUM_LIT> ) ] ) <EOL> ) <EOL> ATTRIBUTES . update ( DARKCOLORS ) <EOL> RESET = '<STR_LIT>' <EOL> class ColoredText : <EOL> def __init__ ( self , text , attrs = None ) : <EOL> self . text = text <EOL> attrs = [ x . strip ( ) for x in attrs . strip ( ) . split ( '<STR_LIT:|>' ) ] <EOL> self . attrs = [ x for x in attrs if x in ATTRIBUTES ] <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> ctext = None <EOL> if os . getenv ( '<STR_LIT>' ) is None : <EOL> fmt_str = '<STR_LIT>' <EOL> if self . attrs : <EOL> for attr in self . attrs : <EOL> ctext = fmt_str % ( ATTRIBUTES [ attr ] , self . text ) <EOL> ctext += RESET <EOL> return ctext or self . text <EOL> __repr__ = __str__ <EOL> grey = gray = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> red = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> green = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> yellow = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> blue = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> magenta = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> cyan = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> white = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> dark = lambda s : str ( ColoredText ( s , "<STR_LIT>" ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> spin = SpinCursor ( msg = "<STR_LIT>" , minspin = <NUM_LIT:5> , speed = <NUM_LIT:5> ) <EOL> spin . start ( ) <EOL> spin . join ( ) <EOL> print <EOL> print ( '<STR_LIT>' % os . getenv ( '<STR_LIT>' ) ) <EOL> print ( '<STR_LIT>' ) <EOL> for c in COLORS . keys ( ) : <EOL> print ( ColoredText ( "<STR_LIT>" . format ( c . capitalize ( ) ) , c ) ) <EOL> print ( '<STR_LIT:->' * <NUM_LIT> ) <EOL> for c in DARKCOLORS . keys ( ) : <EOL> print ( ColoredText ( "<STR_LIT>" . format ( c . capitalize ( ) ) , c ) ) <EOL> print ( '<STR_LIT:->' * <NUM_LIT> ) <EOL> print ( '<STR_LIT>' ) <EOL> for c in HIGHLIGHTS . keys ( ) : <EOL> print ( ColoredText ( "<STR_LIT>" . format ( c . capitalize ( ) ) , c ) ) <EOL> print ( '<STR_LIT:->' * <NUM_LIT> ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> print ( '<STR_LIT:->' * <NUM_LIT> ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( ColoredText ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> print ( ColoredText ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) </s>
