mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 16:23:36 +05:00
refactor: extract config filenames into constants
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
# ======================================================================= #
|
||||
from __future__ import annotations
|
||||
|
||||
import textwrap
|
||||
from typing import Union
|
||||
|
||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
||||
@@ -16,12 +15,14 @@ from core.submodules.simple_config_parser.src.simple_config_parser.simple_config
|
||||
NoSectionError,
|
||||
SimpleConfigParser,
|
||||
)
|
||||
from utils.constants import COLOR_RED, RESET_FORMAT
|
||||
from utils.logger import Logger
|
||||
from utils.logger import DialogType, Logger
|
||||
from utils.sys_utils import kill
|
||||
|
||||
from kiauh import PROJECT_ROOT
|
||||
|
||||
DEFAULT_CFG = PROJECT_ROOT.joinpath("default.kiauh.cfg")
|
||||
CUSTOM_CFG = PROJECT_ROOT.joinpath("kiauh.cfg")
|
||||
|
||||
|
||||
class AppSettings:
|
||||
def __init__(self) -> None:
|
||||
@@ -56,8 +57,6 @@ class FluiddSettings:
|
||||
# noinspection PyMethodMayBeStatic
|
||||
class KiauhSettings:
|
||||
_instance = None
|
||||
_default_cfg = PROJECT_ROOT.joinpath("default_kiauh.cfg")
|
||||
_custom_cfg = PROJECT_ROOT.joinpath("kiauh.cfg")
|
||||
|
||||
def __new__(cls, *args, **kwargs) -> "KiauhSettings":
|
||||
if cls._instance is None:
|
||||
@@ -120,14 +119,14 @@ class KiauhSettings:
|
||||
|
||||
def save(self) -> None:
|
||||
self._set_config_options()
|
||||
self.config.write(self._custom_cfg)
|
||||
self.config.write(CUSTOM_CFG)
|
||||
self._load_config()
|
||||
|
||||
def _load_config(self) -> None:
|
||||
if not self._custom_cfg.exists() and not self._default_cfg.exists():
|
||||
if not CUSTOM_CFG.exists() or not DEFAULT_CFG.exists():
|
||||
self._kill()
|
||||
|
||||
cfg = self._custom_cfg if self._custom_cfg.exists() else self._default_cfg
|
||||
cfg = CUSTOM_CFG if CUSTOM_CFG.exists() else DEFAULT_CFG
|
||||
self.config.read(cfg)
|
||||
|
||||
self._validate_cfg()
|
||||
|
||||
Reference in New Issue
Block a user