Files
sublime-music/sublime/util.py
2020-08-02 13:22:05 -06:00

15 lines
464 B
Python

from pathlib import Path
from typing import Union
def resolve_path(*joinpath_args: Union[str, Path]) -> Path:
roots = (Path(__file__).parent, Path("/usr/share/sublime-music"))
for root in roots:
if (fullpath := root.joinpath(*joinpath_args).resolve()).exists():
return fullpath
raise FileNotFoundError(
f"{Path(*joinpath_args)} could not be found in any of the following "
"directories: {', '.join(roots)}"
)