"""Utilities for deleting files and directories."""

import shutil
from pathlib import Path

from core.logger_config import logger


def delete(path: str | Path) -> None:
    """Deletes a file or directory.

    Args:
        path: Path of the file or directory to delete.

    Raises:
        FileNotFoundError: If the path does not exist.
        OSError: If the deletion fails.
    """
    target = Path(path)
    if not target.exists():
        msg = f"Path does not exist: {target}"
        raise FileNotFoundError(msg)
    logger.info(f"Deleting: {target}")
    if target.is_dir():
        shutil.rmtree(target)
    else:
        target.unlink()
    logger.info(f"Deleted: {target}")
