<s> import sys <EOL> from robotide . lib . robot . model import SuiteVisitor <EOL> from robotide . lib . robot . utils import plural_or_not , secs_to_timestr <EOL> from . highlighting import HighlightingStream <EOL> class DottedOutput ( object ) : <EOL> def __init__ ( self , width = <NUM_LIT> , colors = '<STR_LIT>' , stdout = None , stderr = None ) : <EOL> self . _width = width <EOL> self . _stdout = HighlightingStream ( stdout or sys . __stdout__ , colors ) <EOL> self . _stderr = HighlightingStream ( stderr or sys . __stderr__ , colors ) <EOL> def start_suite ( self , suite ) : <EOL> if not suite . parent : <EOL> self . _stdout . write ( "<STR_LIT>" <EOL> % ( suite . name , suite . test_count ) ) <EOL> self . _stdout . write ( '<STR_LIT:=>' * self . _width + '<STR_LIT:\n>' ) <EOL> def end_test ( self , test ) : <EOL> if test . passed : <EOL> self . _stdout . write ( '<STR_LIT:.>' ) <EOL> elif '<STR_LIT>' in test . tags : <EOL> self . _stdout . write ( '<STR_LIT:x>' ) <EOL> elif not test . critical : <EOL> self . _stdout . write ( '<STR_LIT:f>' ) <EOL> else : <EOL> self . _stdout . highlight ( '<STR_LIT:F>' , '<STR_LIT>' ) <EOL> def end_suite ( self , suite ) : <EOL> if not suite . parent : <EOL> self . _stdout . write ( '<STR_LIT:\n>' ) <EOL> StatusReporter ( self . _stdout , self . _width ) . report ( suite ) <EOL> self . _stdout . write ( '<STR_LIT:\n>' ) <EOL> def message ( self , msg ) : <EOL> if msg . level in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> self . _stderr . error ( msg . message , msg . level ) <EOL> def output_file ( self , name , path ) : <EOL> self . _stdout . write ( '<STR_LIT>' % ( name + '<STR_LIT::>' , path ) ) <EOL> class StatusReporter ( SuiteVisitor ) : <EOL> def __init__ ( self , stream , width ) : <EOL> self . _stream = stream <EOL> self . _width = width <EOL> def report ( self , suite ) : <EOL> suite . visit ( self ) <EOL> stats = suite . statistics <EOL> self . _stream . write ( "<STR_LIT>" <EOL> % ( '<STR_LIT:=>' * self . _width , suite . name , <EOL> stats . all . total , plural_or_not ( stats . all . total ) , <EOL> secs_to_timestr ( suite . elapsedtime / <NUM_LIT> ) ) ) <EOL> self . _stream . highlight ( suite . status + '<STR_LIT>' , suite . status ) <EOL> self . _stream . write ( '<STR_LIT>' % stats . message ) <EOL> def visit_test ( self , test ) : <EOL> if not test . passed and test . critical and '<STR_LIT>' not in test . tags : <EOL> self . _stream . write ( '<STR_LIT:->' * self . _width + '<STR_LIT:\n>' ) <EOL> self . _stream . highlight ( '<STR_LIT>' ) <EOL> self . _stream . write ( '<STR_LIT>' % ( test . longname , <EOL> test . message . strip ( ) ) ) </s>
