|
|
@ -24,7 +24,7 @@ This module has all for simplify work with the toml configuration file.
|
|
|
|
|
|
|
|
|
|
|
|
from rich.console import Console
|
|
|
|
from rich.console import Console
|
|
|
|
import tomli
|
|
|
|
import tomli
|
|
|
|
import os
|
|
|
|
from pathlib import PosixPath
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
@ -70,7 +70,7 @@ class Config:
|
|
|
|
del config["URLS"]
|
|
|
|
del config["URLS"]
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
|
def get_config(config_path:str, console:Console) -> dict:
|
|
|
|
def get_config(config_path:PosixPath, console:Console) -> dict:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Read the configuration file and return dict as configuration.
|
|
|
|
Read the configuration file and return dict as configuration.
|
|
|
|
The configuration file must be in the application folder.
|
|
|
|
The configuration file must be in the application folder.
|
|
|
@ -81,6 +81,7 @@ class Config:
|
|
|
|
config = tomli.load(file)
|
|
|
|
config = tomli.load(file)
|
|
|
|
except FileNotFoundError:
|
|
|
|
except FileNotFoundError:
|
|
|
|
console.print(f"[red][ERROR] Please, create configuration file.[/]")
|
|
|
|
console.print(f"[red][ERROR] Please, create configuration file.[/]")
|
|
|
|
|
|
|
|
console.print(f"[yellow][ERROR] The configuration file path: {config_path}.[/]")
|
|
|
|
except tomli.TOMLDecodeError:
|
|
|
|
except tomli.TOMLDecodeError:
|
|
|
|
console.print(f"[red][ERROR] Please, check configuration file for correctness.[/]")
|
|
|
|
console.print(f"[red][ERROR] Please, check configuration file for correctness.[/]")
|
|
|
|
Config.config_validation_error(config)
|
|
|
|
Config.config_validation_error(config)
|
|
|
|