36 lines
840 B
Python
36 lines
840 B
Python
import configparser
|
|
|
|
from .defaults import default_db_query
|
|
from .defaults import default_app_port, default_app_debug
|
|
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read("config.ini")
|
|
logger.debug(f"config: {config.sections()}")
|
|
|
|
|
|
def save_config():
|
|
with open("config.ini", "w") as f:
|
|
config.write(f)
|
|
|
|
def check_config():
|
|
save = False
|
|
if not "DataBase" in config:
|
|
logger.debug("DataBase not found in Config")
|
|
config["DataBase"] = {
|
|
"query": default_db_query
|
|
}
|
|
save = True
|
|
if not "App" in config:
|
|
logger.debug("App not found in Config")
|
|
|
|
config["App"] = {
|
|
"port": default_app_port,
|
|
"debug": default_app_debug
|
|
}
|
|
save = True
|
|
if save: save_config()
|
|
|
|
check_config() |