INNER CODE UNIT · Python

_apply_plans

faridrashidi/cnsplots · src/cnsplots/_cli.py:152

def _apply_plans(plans: Sequence[_Plan]) -> None:
    """Stage every target, then swap trees; restore originals on an I/O failure."""
    staged: list[tuple[_Plan, Path]] = []
    backups: list[tuple[Path, Path]] = []
    installed: list[tuple[Path, Path]] = []
    cleanup = True
    try:
        for plan in plans:
            destination = plan.destination
            destination.parent.mkdir(parents=True, exist_ok=True)
            work = Path(tempfile.mkdtemp(prefix=".cnsplots-", dir=destination.parent))
            staged.append((plan, work))
            tree = work / "new"
            if destination.exists():
                shutil.copytree(destination, tree, symlinks=True)
            else:
                tree.mkdir()
            for name in plan.removals:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…