[info] using python internal tomllib
This commit is contained in:
parent
f7cfc96dde
commit
1332e067c6
@ -1,29 +1,26 @@
|
|||||||
import tomlkit
|
import tomllib
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
def load_project_settings(project_root):
|
def load_project_settings(project_root):
|
||||||
print(project_root)
|
|
||||||
# Read the pyproject.toml file
|
# Read the pyproject.toml file
|
||||||
with open(pathlib.Path.joinpath(project_root, "pyproject.toml"), "r") as f:
|
pyproject_path = pathlib.Path.joinpath(project_root, "pyproject.toml")
|
||||||
pyproject_content = f.read()
|
with open(pyproject_path, "rb") as f:
|
||||||
|
pyproject_content = tomllib.load(f)
|
||||||
|
|
||||||
# Parse the toml content
|
info_dict = {
|
||||||
pyproject = tomlkit.parse(pyproject_content)
|
"name": pyproject_content["tool"]["poetry"]["name"],
|
||||||
|
"version": pyproject_content["tool"]["poetry"]["version"],
|
||||||
# Access project settings
|
"description": pyproject_content["tool"]["poetry"]["description"],
|
||||||
return {
|
"authors": pyproject_content["tool"]["poetry"]["authors"],
|
||||||
"name": pyproject["tool"]["poetry"]["name"],
|
"readme": pyproject_content["tool"]["poetry"]["authors"],
|
||||||
"version": pyproject["tool"]["poetry"]["version"],
|
"licence": pyproject_content["tool"]["poetry"]["license"],
|
||||||
"description": pyproject["tool"]["poetry"]["description"],
|
"organization": pyproject_content["project"]["organization"],
|
||||||
"authors": pyproject["tool"]["poetry"]["authors"],
|
"classifiers": pyproject_content["tool"]["poetry"]["classifiers"],
|
||||||
"readme": pyproject["tool"]["poetry"]["authors"],
|
"copyright": pyproject_content["project"]["copyright"],
|
||||||
"licence": pyproject["tool"]["poetry"]["license"],
|
"repository": pyproject_content["tool"]["poetry"]["repository"],
|
||||||
"organization": pyproject["project"]["organization"],
|
|
||||||
"classifiers": pyproject["tool"]["poetry"]["classifiers"],
|
|
||||||
"copyright": pyproject["project"]["copyright"],
|
|
||||||
"repository": pyproject["tool"]["poetry"]["repository"],
|
|
||||||
}
|
}
|
||||||
|
return info_dict
|
||||||
|
|
||||||
|
|
||||||
_root = pathlib.Path(__file__).parent.parent
|
_root = pathlib.Path(__file__).parent.parent
|
||||||
|
Loading…
Reference in New Issue
Block a user