<s> import sublime <EOL> class ThreadProgress ( ) : <EOL> def __init__ ( self , thread , message = "<STR_LIT>" , on_done = None , on_fail = None , anim_fx = None ) : <EOL> self . thread = thread <EOL> self . message = message <EOL> self . on_done = on_done <EOL> self . on_fail = on_fail <EOL> if anim_fx is not None : <EOL> self . anim_fx = anim_fx <EOL> sublime . set_timeout ( lambda : self . run ( <NUM_LIT:0> ) , <NUM_LIT:100> ) <EOL> def anim_fx ( self , i , message , thread ) : <EOL> return { "<STR_LIT:i>" : ( i + <NUM_LIT:1> ) % <NUM_LIT:3> , "<STR_LIT:message>" : "<STR_LIT>" % ( self . message , "<STR_LIT:.>" * ( i + <NUM_LIT:1> ) ) , "<STR_LIT>" : <NUM_LIT> } <EOL> def run ( self , i ) : <EOL> if not self . thread . is_alive ( ) : <EOL> if hasattr ( self . thread , "<STR_LIT:result>" ) and not self . thread . result : <EOL> if hasattr ( self . thread , "<STR_LIT>" ) : <EOL> sublime . status_message ( self . thread . result_message ) <EOL> else : <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> if self . on_fail is not None : <EOL> self . on_fail ( self . thread ) <EOL> return <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> if self . on_done is not None : <EOL> self . on_done ( self . thread ) <EOL> return <EOL> info = self . anim_fx ( i , self . message , self . thread ) <EOL> tmsg = "<STR_LIT>" <EOL> if hasattr ( self . thread , "<STR_LIT>" ) : <EOL> tmsg = self . thread . msg <EOL> sublime . status_message ( info [ "<STR_LIT:message>" ] + tmsg ) <EOL> sublime . set_timeout ( lambda : self . run ( info [ "<STR_LIT:i>" ] ) , info [ "<STR_LIT>" ] ) </s>
