(src, dst, buffer_size=16*1024)
Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
Copy the file src to dst ; both must be filenames . Any error opening either file reading from src or writing to dst raises DistutilsFileError . Data is read / written in chunks of buffer_size bytes ( default 16k ) . No attempt is made to handle anything apart from regular files .
def _copy_file_contents(src, dst, buffer_size=16*1024):
    """Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
    """
    # Stolen from shutil module in the standard library, but with
    # custom error-handling added.
    fsrc = None
    fdst = None
    try:
        try:
            fsrc = open(src, 'rb')
        except OSError as e:
            raise DistutilsFileError("could not open '%s': %s" % (src, e.strerror))

        if os.path.exists(dst):
            try:
                os.unlink(dst)
            except OSError as e:
                raise DistutilsFileError(
                      "could not delete '%s': %s" % (dst, e.strerror))

        try:
            fdst = open(dst, 'wb')
        except OSError as e:
            raise DistutilsFileError(
                  "could not create '%s': %s" % (dst, e.strerror))

        while True:
            try:
                buf = fsrc.read(buffer_size)
            except OSError as e:
                raise DistutilsFileError(
                      "could not read from '%s': %s" % (src, e.strerror))

            if not buf:
                break

            try:
                fdst.write(buf)
            except OSError as e:
                raise DistutilsFileError(
                      "could not write to '%s': %s" % (dst, e.strerror))
    finally:
        if fdst:
            fdst.close()
        if fsrc:
            fsrc.close()
def _copy_file_contents ( src , dst , buffer_size = 16 * 1024 ) : # Stolen from shutil module in the standard library, but with # custom error-handling added. fsrc = None fdst = None try : try : fsrc = open ( src , 'rb' ) except OSError as e : raise DistutilsFileError ( "could not open '%s': %s" % ( src , e . strerror ) ) if os . path . exists ( dst ) : try : os . unlink ( dst ) except OSError as e : raise DistutilsFileError ( "could not delete '%s': %s" % ( dst , e . strerror ) ) try : fdst = open ( dst , 'wb' ) except OSError as e : raise DistutilsFileError ( "could not create '%s': %s" % ( dst , e . strerror ) ) while True : try : buf = fsrc . read ( buffer_size ) except OSError as e : raise DistutilsFileError ( "could not read from '%s': %s" % ( src , e . strerror ) ) if not buf : break try : fdst . write ( buf ) except OSError as e : raise DistutilsFileError ( "could not write to '%s': %s" % ( dst , e . strerror ) ) finally : if fdst : fdst . close ( ) if fsrc : fsrc . close ( )