Files
sublime-music/sublime/util.py

15 lines
453 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():
return fullpath
raise FileNotFoundError(
f"{Path(*joinpath_args)} could not be found in any of the following "
"directories: {', '.join(roots)}"
)