continue-custom/server/continuedev/libs/util/map_path.py
Nate Sesti 279593a848
Strong typing (#533)
* refactor: ♻️ get rid of continuedev.src.continuedev structure

* refactor: ♻️ switching back to server folder

* feat: ✨ make config.py imports shorter

* feat: 🔖 publish as pre-release vscode extension

* refactor: ♻️ refactor and add more completion params to ui

* build: 🏗️ download from preview S3
2023-10-04 23:47:59 -07:00

16 lines
511 B
Python

from pathlib import Path
def map_path(path: str, orig_root: str, copy_root: str) -> Path:
path = Path(path)
if path.is_relative_to(orig_root):
if path.is_absolute():
return Path(copy_root) / path.relative_to(orig_root)
else:
return path
else:
if path.is_absolute():
return path
else:
# For this one, you need to know the directory from which the relative path is being used.
return Path(orig_root) / path