gui.model.initial_root(root, cwd, recent=())
Which repository to open at start.
The order is the --root option, the repository above the current directory and the most recent entry of the recent list.
Parameters
| root |
Path | str | None |
The --root option, or None. |
required |
| cwd |
Path | str |
The current directory. |
required |
| recent |
Sequence[str] |
The recent repositories, newest first. Entries that no longer exist are skipped. |
() |
Returns
|
Path | None |
Path | None: The root to open, or None if there is none. |
Examples
from pathlib import Path
from tempfile import TemporaryDirectory
from spotregen import make_sample_repo
from spotregen.gui.model import initial_root
with TemporaryDirectory() as tmp:
root = make_sample_repo(Path(tmp) / "demo")
print(initial_root(None, root / "src").name)
print(initial_root(None, tmp, ["/old/repo", str(root)]).name)