def copystream(src, dest, size, chunk_size=(10 ** 5)):
 while (size > 0):
  if (size < chunk_size):
   data = src.read(size)
  else:
   data = src.read(chunk_size)
  length = len(data)
  if (length > size):
   (data, length) = (data[:size], size)
  size -= length
  if (length == 0):
   break
  dest.write(data)
  if (length < chunk_size):
   break
 dest.seek(0)
 return

def copystream ( src , dest , size , chunk_size = ( 10 ** 5 ) ) : while ( size > 0 ) : if ( size < chunk_size ) : data = src . read ( size ) else : data = src . read ( chunk_size ) length = len ( data ) if ( length > size ) : ( data , length ) = ( data [ : size ] , size ) size -= length if ( length == 0 ) : break dest . write ( data ) if ( length < chunk_size ) : break dest . seek ( 0 ) return
this is here because i think there is a bug in shutil .