#NEWLINE# def calculate_total_row( self , headers , rows ) : #NEWLINE# #INDENT# total_row = [ 'Total' ] #NEWLINE# for header in range ( 1 , headers . __len__ ( ) ) : #NEWLINE# #INDENT# total_row . append ( '0/0' ) #NEWLINE# #UNINDENT# def _calc_totals( row , idx ) : #NEWLINE# #INDENT# TAG_RE = re . compile ( '<[^>]+>' ) #NEWLINE# def remove_tags( text ) : #NEWLINE# #INDENT# return TAG_RE . sub ( '' , text ) #NEWLINE# #UNINDENT# if ( 'html' in row ) : #NEWLINE# #INDENT# row = remove_tags ( row [ 'html' ] ) #NEWLINE# #UNINDENT# init_values = map ( int , re . findall ( '\\d+' , total_row [ idx ] ) ) #NEWLINE# new_values = map ( int , re . findall ( '\\d+' , row ) ) #NEWLINE# init_values [ 0 ] += new_values [ 0 ] #NEWLINE# init_values [ 1 ] += new_values [ 1 ] #NEWLINE# percentage = ( ( 100 * int ( ( init_values [ 0 ] or 0 ) ) ) / float ( ( init_values [ 1 ] or 1 ) ) ) #NEWLINE# text = ( '%d/%d (%.2f%%)' % ( ( init_values [ 0 ] or 0 ) , init_values [ 1 ] , percentage ) ) #NEWLINE# total_row [ idx ] = text #NEWLINE# #UNINDENT# for row in rows : #NEWLINE# #INDENT# for ( idx , practice ) in enumerate ( row [ 1 : ] , 1 ) : #NEWLINE# #INDENT# _calc_totals ( practice , practice ) #NEWLINE# #UNINDENT# #UNINDENT# return total_row