import glob


def _get_post_file(stub):
    """Locate a post's markdown file from its stub"""
    files = glob.glob(f"../_posts/*{stub}.md")
    if not files:
        raise FileNotFoundError(f"Could not locate file with stub {stub}")
    elif len(files) > 1:
        raise ValueError(f"Multiple files located with stub {stub}")
    return files[0]