mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 00:33:37 +05:00
refactor(ConfigManager): allow to take in any config file
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -9,19 +9,16 @@
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
|
||||
import os
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
from kiauh import APPLICATION_ROOT
|
||||
from kiauh.utils.logger import Logger
|
||||
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
class ConfigManager:
|
||||
def __init__(self):
|
||||
self.config_file = self._get_cfg_location()
|
||||
def __init__(self, cfg_file: str):
|
||||
self.config_file = cfg_file
|
||||
self.config = configparser.ConfigParser()
|
||||
|
||||
def read_config(self) -> None:
|
||||
@@ -56,11 +53,3 @@ class ConfigManager:
|
||||
|
||||
def set_value(self, section: str, key: str, value: str):
|
||||
self.config.set(section, key, value)
|
||||
|
||||
def check_config_exist(self) -> bool:
|
||||
return True if self._get_cfg_location() else False
|
||||
|
||||
def _get_cfg_location(self) -> str:
|
||||
cfg_path = os.path.join(APPLICATION_ROOT, "kiauh.cfg")
|
||||
|
||||
return cfg_path if Path(cfg_path).exists() else None
|
||||
|
||||
Reference in New Issue
Block a user