ref: Extract note parent dir creation function
This commit is contained in:
parent
1ea149c1de
commit
49bd1292fa
1 changed files with 6 additions and 3 deletions
9
topen.py
9
topen.py
|
|
@ -63,9 +63,7 @@ def main(cfg: "TConf | None" = None, io: "_IO | None" = None) -> int:
|
|||
|
||||
fpath = get_notes_file(uuid, notes_dir=cfg.notes_dir, notes_ext=cfg.notes_ext)
|
||||
|
||||
if not fpath.parent.exists():
|
||||
fpath.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
_ensure_parent_dir(fpath)
|
||||
io.out(f"Editing note: {fpath}")
|
||||
open_editor(fpath, editor=cfg.notes_editor)
|
||||
|
||||
|
|
@ -139,6 +137,11 @@ def _real_path(p: Path | str) -> Path:
|
|||
return Path(os.path.expandvars(p)).expanduser()
|
||||
|
||||
|
||||
def _ensure_parent_dir(file: Path) -> None:
|
||||
if not file.parent.exists():
|
||||
file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def _determine_default_task_rc() -> Path:
|
||||
if _real_path("~/.taskrc").exists():
|
||||
return _real_path("~/.taskrc")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue