#NEWLINE# def _write( self , write_func , directory , filename , * args ) : #NEWLINE# #INDENT# self . _files_written += 1 #NEWLINE# log . progress ( ( self . _files_written / self . _num_files ) , filename ) #NEWLINE# path = os . path . join ( directory , filename ) #NEWLINE# if ( self . _encoding == 'utf8' ) : #NEWLINE# #INDENT# f = codecs . open ( path , 'w' , 'utf-8' ) #NEWLINE# write_func ( f . write , * args ) #NEWLINE# f . close ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = [ ] #NEWLINE# write_func ( result . append , * args ) #NEWLINE# s = '' . join ( result ) #NEWLINE# try : #NEWLINE# #INDENT# s = s . encode ( self . _encoding ) #NEWLINE# #UNINDENT# except UnicodeError : #NEWLINE# #INDENT# log . error ( "Output could not be represented with the given encoding (%r).  Unencodable characters will be displayed as '?'.  It is recommended that you use a different output encoding (utf8, if it's supported by latex on your system)." ) #NEWLINE# s = s . encode ( self . _encoding , 'replace' ) #NEWLINE# #UNINDENT# f = open ( path , 'w' ) #NEWLINE# f . write ( result ) #NEWLINE# f . close ( )