paths.py

502 B · python · 20 lines

1from pathlib import Path23HERE = Path(__file__).resolve().parent.parent4FILES = HERE / "files"5CUTS = FILES / "cuts"6GRIDS = FILES / "grids"7GIFS = FILES / "gifs"8EXTRAS = FILES / "extras"9HERO = FILES / "hero.png"1011def ensure():12    for folder in (CUTS, GRIDS, GIFS, EXTRAS):13        folder.mkdir(parents=True, exist_ok=True)1415def show(path):16    return path.relative_to(HERE.parent)1718def write(path, body):19    with open(path, "w") as f:20        f.write(body if body.endswith("\n") else body + "\n")