Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from datetime import datetime
2from pathlib import Path
3from typing import Tuple, Union
6def resolve_path(*joinpath_args: Union[str, Path]) -> Path:
7 roots = (Path(__file__).parent, Path("/usr/share/sublime-music"))
8 for root in roots:
9 if (fullpath := root.joinpath(*joinpath_args).resolve()).exists():
10 return fullpath
12 raise FileNotFoundError(
13 f"{Path(*joinpath_args)} could not be found in any of the following "
14 "directories: {', '.join(roots)}"
15 )
18def this_decade() -> Tuple[int, int]:
19 """Returns a tuple representing the start and end year of the current decade."""
20 now = datetime.now()
21 decade_start = now.year // 10 * 10
22 return (decade_start, decade_start + 10)