blob: 8eb57712562bef23706482271d69aee8c63ff7fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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
|