from pathlib import Path
from typing import Union


def get_gt(path: Path, suffix: str) -> Union[Path, None]:
    """Gets ground truth file associated with line image.

    Args:
        path (Path): Path to the line image.
        suffix (str): Suffix for the ground truth text files.

    Returns:
         Union[Path, None]: Path to the ground truth text file or None if not ground truth text file exists.
    """
    gt_path = Path(path.parent, path.stem).with_suffix(suffix)
    if gt_path.is_file():
        return gt_path
    return None