#NEWLINE# def escape_rows( rows , nulls_only = False ) : #NEWLINE# #INDENT# data = [ ] #NEWLINE# for row in rows : #NEWLINE# #INDENT# escaped_row = [ ] #NEWLINE# for field in row : #NEWLINE# #INDENT# if isinstance ( field , numbers . Number ) : #NEWLINE# #INDENT# if ( math . isnan ( field ) or math . isinf ( field ) ) : #NEWLINE# #INDENT# escaped_field = json . dumps ( field ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# escaped_field = field #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( field is None ) : #NEWLINE# #INDENT# escaped_field = 'NULL' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# escaped_field = smart_unicode ( field , errors = 'replace' ) #NEWLINE# if ( not nulls_only ) : #NEWLINE# #INDENT# escaped_field = escape ( escaped_field ) . replace ( ' ' , '&nbsp;' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# escaped_row . append ( escaped_field ) #NEWLINE# #UNINDENT# data . append ( escaped_row ) #NEWLINE# #UNINDENT# return data