| 248 | |
| 249 | |
| 250 | def resolve_output(inp: str, out: Optional[str], force=False) -> str: |
| 251 | from urllib.parse import urlparse |
| 252 | |
| 253 | from dvc.exceptions import FileExistsLocallyError |
| 254 | |
| 255 | name = os.path.basename(os.path.normpath(urlparse(inp).path)) |
| 256 | if not out: |
| 257 | ret = name |
| 258 | elif os.path.isdir(out): |
| 259 | ret = os.path.join(out, name) |
| 260 | else: |
| 261 | ret = out |
| 262 | |
| 263 | if os.path.exists(ret) and not force: |
| 264 | hint = "\nTo override it, re-run with '--force'." |
| 265 | raise FileExistsLocallyError(ret, hint=hint) |
| 266 | |
| 267 | return ret |
| 268 | |
| 269 | |
| 270 | def resolve_paths(repo, out, always_local=False): |