def replacing_copy(src, dest, follow_symlinks=False):
with make_tmp_name(dest) as tmp_dest:<EOL><INDENT>if os.path.islink(src) and not follow_symlinks:<EOL><INDENT>src_ = os.readlink(src)<EOL>os.symlink(src_, tmp_dest)<EOL><DEDENT>elif os.path.isdir(src):<EOL><INDENT>shutil.copytree(src, tmp_dest, symlinks=(not follow_symlinks))<EOL><DEDENT>else:<EOL><INDENT>shutil.copy2(src, tmp_dest)<EOL><DEDENT>replace_file_or_dir(dest, tmp_dest)<EOL><DEDENT>
Perform copy that overwrites any existing target.

    Will copy/copytree `src` to `dest`, and will remove `dest` if it exists,
    regardless of what it is.

    If `follow_symlinks` is False, symlinks are preserved, otherwise their
    contents are copied.

    Note that this behavior is different to `shutil.copy`, which copies src
    into dest if dest is an existing dir.