def symlink(src, dst): try: if readlink(expanduser(dst)) == expanduser(src): return except OSError: pass _symlink(expanduser(src), expanduser(dst))
def symlink(src, dst): """ Extended "os.symlink" that: - Autodetect if target is directory. - Ignore error if file already exists. - Ensure to link to real absolute path of the source. Args: src (path-like object): Source path. dst (path-like object): Destination path. """ src = _realpath(_fsdecode(src)) try: _symlink(src, _fsdecode(dst), target_is_directory=_isdir(src)) except FileExistsError: pass
def symlink(src, dest): from os import symlink as _symlink, unlink if exists(dest): unlink(dest) _symlink(src, dest)
def os_symlink(source, link_name): return os._symlink(longpathify(uni(source)), longpathify(uni(link_name)))