#NEWLINE# def format_cell_fn( self , x , y ) : #NEWLINE# #INDENT# sum_all = ( ( x or 0 ) + ( y or 0 ) ) #NEWLINE# percentage = ( ( 100 * int ( ( x or 0 ) ) ) / float ( ( sum_all or 1 ) ) ) #NEWLINE# text = ( '%d/%d (%.2f%%)' % ( ( x or 0 ) , sum_all , percentage ) ) #NEWLINE# def _get_color( value ) : #NEWLINE# #INDENT# if ( 76 <= value <= 100 ) : #NEWLINE# #INDENT# return 'green' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 51 <= value <= 75 ) : #NEWLINE# #INDENT# return 'orange' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 26 <= value <= 51 ) : #NEWLINE# #INDENT# return 'yellow' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 'red' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ( '<span style="display: block; text-align:center;padding:10px;background-color:%s">%s</span>' % ( _get_color ( percentage ) , y ) )