import pathlib


def assure_dir(directory: str) -> bool:
    """
    Assure dir is a directory.
    :param directory:
    :return: If dir is a directory , return True, else create the directory
        and return False
    :raise NotADirectoryError: if param dir is a file ,
        raise NotADirectoryError
    """
    path = pathlib.Path(directory)
    if path.is_dir():
        return True
    else:
        try:
            path.mkdir(parents=True)
        except FileExistsError:
            raise NotADirectoryError()
        return False