Resell1/modules/project_info.py

24 lines
1.0 KiB
Python

import tomllib
import os
def get_project_info():
# pyproject.toml 파일의 경로: 프로젝트 루트에서 찾습니다.
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "pyproject.toml")
try:
with open(path, "rb") as f:
data = tomllib.load(f)
project = data.get("project", {})
name = project.get("name", "App")
window_title = project.get("window_title", "App")
version = project.get("version", "0.0.0")
authors = project.get("authors", [])
if isinstance(authors, list):
# authors가 딕셔너리의 리스트인 경우 name 필드 사용
author_names = ", ".join(a.get("name", "") for a in authors)
else:
author_names = ""
return {"name": name, "window_title": window_title, "version": version, "authors": author_names}
except Exception as e:
print("pyproject.toml 읽기 오류:", e)
return {"name": "Unknown App", "window_title": "---", "version": "0.0.0", "authors": ""}