Create a symbolic link. Args: src: The path to the file or directory. dest: The path to the destination. overwrite: Whether to overwrite the destination. Returns: Whether the link was successful.
(src: str, dest: str, overwrite: bool = False)
| 82 | |
| 83 | |
| 84 | def ln(src: str, dest: str, overwrite: bool = False) -> bool: |
| 85 | """Create a symbolic link. |
| 86 | |
| 87 | Args: |
| 88 | src: The path to the file or directory. |
| 89 | dest: The path to the destination. |
| 90 | overwrite: Whether to overwrite the destination. |
| 91 | |
| 92 | Returns: |
| 93 | Whether the link was successful. |
| 94 | """ |
| 95 | if src == dest: |
| 96 | return False |
| 97 | if not overwrite and (os.path.exists(dest) or os.path.islink(dest)): |
| 98 | return False |
| 99 | if os.path.isdir(src): |
| 100 | rm(dest) |
| 101 | os.symlink(src, dest, target_is_directory=True) |
| 102 | else: |
| 103 | os.symlink(src, dest) |
| 104 | return True |
| 105 | |
| 106 | |
| 107 | def which(program: str) -> str | None: |