

def copy(source, dest, autoflush=True, print_status=None):
    '\n    Read from the source file handle and write the data to the dest file handle.\n    '
    n = 0
    while True:
        buf = source.read(BUFFER_SIZE)
        if (not buf):
            break
        dest.write(buf)
        n += len(buf)
        if autoflush:
            dest.flush()
        if print_status:
            ((print >> sys.stderr), ('\r%s: %s' % (print_status, formatting.size_str(n))))
            sys.stderr.flush()
    if print_status:
        ((print >> sys.stderr), ('\r%s: %s [done]' % (print_status, formatting.size_str(n))))

dataset/ETHPy150Open codalab/codalab-cli/codalab/lib/file_util.py copy/original