from pathlib import Path


def get_data_path(sub_path: str) -> Path:
    """
    Returns the Path object of a path in data and
    creates the parent folders if they don't exist already

    Parameters
    ----------
    sub_path : str
        subpath in data directory

    Returns
    -------
    Path
        Path to a file in data
    """
    data_base_path = Path(__file__).parent.parent / "data"
    data_path = data_base_path / sub_path
    if data_path.suffixes == []:
        data_path.mkdir(parents=True, exist_ok=True)
    else:
        data_path.parent.mkdir(parents=True, exist_ok=True)
    return data_path