#NEWLINE# def pipe_in_out( in_fh , out_fh , chunk_size = 1024 , chunk_cb = None ) : #NEWLINE# #INDENT# bytes_piped = 0 #NEWLINE# LOG . debug ( 'Transferring the contents of %s to %s in chunks of size %s.' , in_fh , out_fh , chunk_size ) #NEWLINE# while True : #NEWLINE# #INDENT# data = in_fh . read ( chunk_size ) #NEWLINE# if ( data == '' ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# out_fh . write ( data ) #NEWLINE# bytes_piped += len ( data ) #NEWLINE# if chunk_cb : #NEWLINE# #INDENT# chunk_cb ( bytes_piped ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return bytes_piped