def report_raw_stats(sect, stats, old_stats):
 total_lines = stats['total_lines']
 if (not total_lines):
  raise EmptyReport()
 sect.description = ('%s lines have been analyzed' % total_lines)
 lines = ('type', 'number', '%', 'previous', 'difference')
 for node_type in ('code', 'docstring', 'comment', 'empty'):
  key = (node_type + '_lines')
  total = stats[key]
  percent = (float((total * 100)) / total_lines)
  old = old_stats.get(key, None)
  if (old is not None):
   diff_str = diff_string(old, total)
  else:
   (old, diff_str) = ('NC', 'NC')
  lines += (node_type, str(total), ('%.2f' % percent), str(old), diff_str)
 sect.append(Table(children=lines, cols=5, rheaders=1))

def report_raw_stats ( sect , stats , old_stats ) : total_lines = stats [ 'total_lines' ] if ( not total_lines ) : raise EmptyReport ( ) sect . description = ( '%s lines have been analyzed' % total_lines ) lines = ( 'type' , 'number' , '%' , 'previous' , 'difference' ) for node_type in ( 'code' , 'docstring' , 'comment' , 'empty' ) : key = ( node_type + '_lines' ) total = stats [ key ] percent = ( float ( ( total * 100 ) ) / total_lines ) old = old_stats . get ( key , None ) if ( old is not None ) : diff_str = diff_string ( old , total ) else : ( old , diff_str ) = ( 'NC' , 'NC' ) lines += ( node_type , str ( total ) , ( '%.2f' % percent ) , str ( old ) , diff_str ) sect . append ( Table ( children = lines , cols = 5 , rheaders = 1 ) )
calculate percentage of code / doc / comment / empty .