import tomllib
import pathlib


def load_project_settings(project_root):
    # Read the pyproject.toml file
    pyproject_path = pathlib.Path.joinpath(project_root, "pyproject.toml")
    with open(pyproject_path, "rb") as f:
        pyproject_content = tomllib.load(f)

    info_dict = {
        "name": pyproject_content["tool"]["poetry"]["name"],
        "version": pyproject_content["tool"]["poetry"]["version"],
        "description": pyproject_content["tool"]["poetry"]["description"],
        "authors": pyproject_content["tool"]["poetry"]["authors"],
        "readme": pyproject_content["tool"]["poetry"]["authors"],
        "licence": pyproject_content["tool"]["poetry"]["license"],
        "organization": pyproject_content["project"]["organization"],
        "classifiers": pyproject_content["tool"]["poetry"]["classifiers"],
        "copyright": pyproject_content["project"]["copyright"],
        "repository": pyproject_content["tool"]["poetry"]["repository"],
    }
    return info_dict


_root = pathlib.Path(__file__).parent.parent
_infodict = load_project_settings(_root)

NAME = _infodict["name"]
VERSION = _infodict["version"]
AUTHORS = _infodict["authors"]
COPYRIGHT = _infodict["copyright"]
HOMEPAGE = _infodict["repository"]
CLASSIFIERS = _infodict["classifiers"]
DESCRIPTION = _infodict["description"]
ORGANIZATION = _infodict["organization"]