fix(config): save user config to project root config.yaml
- _find_config() now looks for config.yaml at project root first - _get_user_config_path() returns project root config.yaml - config/default_config.yaml remains as template (not for saving)
This commit is contained in:
@@ -104,7 +104,7 @@ class MainWindow(ctk.CTk):
|
|||||||
"""Find the user configuration file.
|
"""Find the user configuration file.
|
||||||
|
|
||||||
Checks common locations:
|
Checks common locations:
|
||||||
1. config/config.yaml (user's config)
|
1. config.yaml (project root, user's config)
|
||||||
2. config/default_config.yaml (template, not for saving)
|
2. config/default_config.yaml (template, not for saving)
|
||||||
3. User-specified path via env var
|
3. User-specified path via env var
|
||||||
|
|
||||||
@@ -112,14 +112,14 @@ class MainWindow(ctk.CTk):
|
|||||||
Path to user config file, or None if not found.
|
Path to user config file, or None if not found.
|
||||||
"""
|
"""
|
||||||
app_dir = Path(__file__).parent.parent
|
app_dir = Path(__file__).parent.parent
|
||||||
config_dir = app_dir / "config"
|
|
||||||
|
|
||||||
# 1. Check for user config first
|
# 1. Check for user config at project root
|
||||||
user_config = config_dir / "config.yaml"
|
user_config = app_dir / "config.yaml"
|
||||||
if user_config.exists():
|
if user_config.exists():
|
||||||
return user_config
|
return user_config
|
||||||
|
|
||||||
# 2. Check for default config (template)
|
# 2. Check for default config (template)
|
||||||
|
config_dir = app_dir / "config"
|
||||||
default_config = config_dir / "default_config.yaml"
|
default_config = config_dir / "default_config.yaml"
|
||||||
if default_config.exists():
|
if default_config.exists():
|
||||||
return default_config
|
return default_config
|
||||||
@@ -134,13 +134,13 @@ class MainWindow(ctk.CTk):
|
|||||||
def _get_user_config_path(self) -> Path:
|
def _get_user_config_path(self) -> Path:
|
||||||
"""Get the path to the user config file (config.yaml).
|
"""Get the path to the user config file (config.yaml).
|
||||||
|
|
||||||
Creates config.yaml if it doesn't exist.
|
Creates config.yaml in project root if it doesn't exist.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Path to user config file.
|
Path to user config file.
|
||||||
"""
|
"""
|
||||||
app_dir = Path(__file__).parent.parent
|
app_dir = Path(__file__).parent.parent
|
||||||
config_path = app_dir / "config" / "config.yaml"
|
config_path = app_dir / "config.yaml"
|
||||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
return config_path
|
return config_path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user