#NEWLINE# def write( self , line ) : #NEWLINE# #INDENT# 'Write method.' #NEWLINE# line_m = ColouredWriter . line_re . match ( line ) #NEWLINE# if line_m : #NEWLINE# #INDENT# time = line_m . group ( 1 ) #NEWLINE# request = line_m . group ( 2 ) #NEWLINE# code = int ( line_m . group ( 3 ) ) #NEWLINE# size = int ( line_m . group ( 4 ) ) #NEWLINE# if ( code >= 500 ) : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'fail' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code >= 400 ) : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'warning' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code == 301 ) : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'fail' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code >= 300 ) : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'okgreen' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( code >= 200 ) : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'okblue' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# command = ColouredWriter . colors [ 'unknown' ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( code in ColouredWriter . status_code_text ) : #NEWLINE# #INDENT# meaning = ColouredWriter . status_code_text [ code ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# meaning = '*unknown*' #NEWLINE# #UNINDENT# self . stdout . write ( time ) #NEWLINE# set_text_attr ( ( command | self . default_bg ) ) #NEWLINE# self . stdout . write ( ( ' ' + request ) ) #NEWLINE# set_text_attr ( self . default_colors ) #NEWLINE# self . stdout . write ( ( ' %i %i (%s)\n' % ( code , size , meaning ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# build_m = ColouredWriter . build_re . match ( time ) #NEWLINE# if build_m : #NEWLINE# #INDENT# time = build_m . group ( 1 ) #NEWLINE# request = build_m . group ( 2 ) #NEWLINE# self . stdout . write ( ( time + ' ' ) ) #NEWLINE# if request [ 1 : ] . startswith ( 'FAILED' ) : #NEWLINE# #INDENT# set_text_attr ( ColouredWriter . colors [ 'fail' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# set_text_attr ( ( ColouredWriter . colors [ 'build' ] | self . default_bg ) ) #NEWLINE# #UNINDENT# self . stdout . write ( ( '%s' % request ) ) #NEWLINE# set_text_attr ( self . default_colors ) #NEWLINE# self . stdout . write ( '\n' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . stdout . write ( line )