'Transfer data between files (Python IO objects).'

def _transfer_data(self, src, src_name, dest, dest_name, length):

    LOG.debug("Transferring    data    between    '%(src)s'    and    '%(dest)s'", {'src': src_name, 'dest': dest_name})
    chunks = int((length / self.chunk_size))
    LOG.debug('%(chunks)s    chunks    of    %(bytes)s    bytes    to    be    transferred', {'chunks': chunks, 'bytes': self.chunk_size})
    for chunk in range(0, chunks):
        before = time.time()
        data = src.read(self.chunk_size)
        if (data == ''):
            if CONF.restore_discard_excess_bytes:
                self._discard_bytes(dest, dest.tell(), (length - dest.tell()))
            return
        dest.write(data)
        dest.flush()
        delta = (time.time() - before)
        rate = ((self.chunk_size / delta) / 1024)
        LOG.debug('Transferred    chunk    %(chunk)s    of    %(chunks)s    (%(rate)dK/s)', {'chunk': (chunk + 1), 'chunks': chunks, 'rate': rate})
        eventlet.sleep(0)
    rem = int((length % self.chunk_size))
    if rem:
        LOG.debug('Transferring    remaining    %s    bytes', rem)
        data = src.read(rem)
        if (data == ''):
            if CONF.restore_discard_excess_bytes:
                self._discard_bytes(dest, dest.tell(), rem)
        else:
            dest.write(data)
            dest.flush()
            eventlet.sleep(0)
