[UPD] Added api to create Library
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import configparser
|
||||
|
||||
from .defaults import default_db_query
|
||||
from .defaults import default_app_port, default_app_debug
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -8,9 +9,28 @@ logger = logging.getLogger(__name__)
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config.ini")
|
||||
logger.debug(f"config: {config.sections()}")
|
||||
if not "DataBase" in config:
|
||||
config["DataBase"] = default_db_query
|
||||
|
||||
|
||||
def save_config():
|
||||
with open("config.ini", "w") as f:
|
||||
f.write(config)
|
||||
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()
|
||||
@@ -1 +1,3 @@
|
||||
default_db_query = "sqlite:///library.db"
|
||||
default_db_query = "sqlite:///library.db"
|
||||
default_app_port = 15012
|
||||
default_app_debug = False
|
||||
Reference in New Issue
Block a user