def replace(src, dst):
        # argument names match stdlib docs, docstring below
        try:
            # ReplaceFile fails if the dest file does not exist, so
            # first try to rename it into position
            os.rename(src, dst)
            return
        except WindowsError as we:
            if we.errno == errno.EEXIST:
                pass  # continue with the ReplaceFile logic below
            else:
                raise

        src = path_to_unicode(src)
        dst = path_to_unicode(dst)
        bak = dst + u'.bak'
        res = _ReplaceFile(c_wchar_p(dst), c_wchar_p(src), c_wchar_p(bak),
                           0, None, None)
        if not res:
            raise OSError('failed to replace %r with %r' % (dst, src))
        return
dataset/ETHPy150Open mahmoud/boltons/boltons/fileutils.py/replace/original