34 lines
991 B
Python
34 lines
991 B
Python
import configparser
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def find_config():
|
|
possible_locations = [
|
|
Path.cwd() / "changelog-config.toml",
|
|
Path.cwd() / "changelog2" / "changelog-config.toml",
|
|
Path.cwd() / ".config" / "changelog-config.toml",
|
|
Path.cwd() / ".config" / "changelog-config.toml",
|
|
Path.home() / "changelog-config.toml",
|
|
Path(os.getenv("CHANGELOG_CONFIG", "")),
|
|
]
|
|
|
|
for location in possible_locations:
|
|
if location.is_file():
|
|
return str(location)
|
|
|
|
raise FileNotFoundError("changelog-config.toml nicht gefunden")
|
|
|
|
|
|
config_path = find_config()
|
|
|
|
|
|
def parse_config():
|
|
config = configparser.ConfigParser()
|
|
config.read(config_path)
|
|
return {
|
|
"REDMINE_HOST": config["DEFAULT"]["REDMINE_HOST"],
|
|
"REDMINE_API_KEY": config["DEFAULT"]["REDMINE_API_KEY"],
|
|
"OPENAI_API_KEY": config["DEFAULT"]["OPENAI_API_KEY"],
|
|
"GIT_REPO_PATH": config["DEFAULT"]["GIT_REPO_PATH"],
|
|
}
|