Updated for errors messages

This commit is contained in:
Dimitris Zlatanidis 2023-04-24 20:56:22 +03:00
parent 613ecad738
commit bb22ef0530
11 changed files with 30 additions and 17 deletions

View file

@ -5,7 +5,7 @@ import tomli
from pathlib import Path
from slpkg.configs import Configs
from slpkg.errors_messages import Errors
from slpkg.toml_error_message import TomlErrors
from slpkg.models.models import session as Session
@ -16,7 +16,7 @@ class Blacklist(Configs):
super(Configs, self).__init__()
self.session = Session
self.errors = Errors()
self.errors = TomlErrors()
self.blacklist_file_toml = Path(self.etc_path, 'blacklist.toml')
def packages(self) -> list:

View file

@ -6,7 +6,7 @@ from pathlib import Path
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.repositories import Repositories
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
from slpkg.models.models import session as Session
from slpkg.models.models import SBoTable, PonceTable, BinariesTable

View file

@ -8,7 +8,7 @@ from urllib.parse import unquote
from slpkg.views.ascii import Ascii
from slpkg.utilities import Utilities
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
from slpkg.views.views import ViewMessage

View file

@ -7,14 +7,14 @@ import platform
from pathlib import Path
from dataclasses import dataclass
from slpkg.errors_messages import Errors
from slpkg.toml_error_message import TomlErrors
from slpkg.logging_config import LoggingConfig
@dataclass
class Configs:
""" Default configurations. """
errors = Errors()
errors = TomlErrors()
prog_name: str = 'slpkg'
os_arch: str = platform.machine()

View file

@ -7,7 +7,7 @@ from pathlib import Path
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.dialog_box import DialogBox
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
class FormConfigs(Configs):

View file

@ -9,7 +9,7 @@ from multiprocessing import Process
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
class Downloader(Configs):

17
slpkg/error_messages.py Normal file
View file

@ -0,0 +1,17 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from slpkg.colors import Colors
from slpkg.configs import Configs
class Errors(Configs, Colors):
def __init__(self):
super(Configs, self).__init__()
super(Colors, self).__init__()
def raise_error_message(self, message: str) -> None:
""" A general method to raise an error message and exit. """
raise SystemExit(f"\n{self.prog_name}: {self.bred}Error{self.endc}: {message}.\n")

View file

@ -7,13 +7,13 @@ from pathlib import Path
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.errors_messages import Errors
from slpkg.toml_error_message import TomlErrors
@dataclass
class Repositories:
configs = Configs
errors = Errors()
errors = TomlErrors()
repositories_toml_file: Path = Path(configs.etc_path, 'repositories.toml')
repositories_path: Path = Path(configs.lib_path, 'repositories')

View file

@ -17,7 +17,7 @@ from slpkg.upgrade import Upgrade
from slpkg.utilities import Utilities
from slpkg.dialog_box import DialogBox
from slpkg.downloader import Downloader
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
from slpkg.views.views import ViewMessage
from slpkg.progress_bar import ProgressBar
from slpkg.repositories import Repositories

View file

@ -2,15 +2,11 @@
# -*- coding: utf-8 -*-
class Errors:
class TomlErrors:
def __init__(self):
self.tool_name: str = 'slpkg'
def raise_error_message(self, message: str) -> None:
""" A general method to raise an error message and exit. """
raise SystemExit(f"\n{self.tool_name}: Error: {message}.\n")
def raise_toml_error_message(self, error, toml_file) -> None:
""" A general error message for .toml configs files. """
raise SystemExit(f"\n{self.tool_name} Error: {error}: in the configuration file "

View file

@ -13,7 +13,7 @@ from typing import Generator, Union
from slpkg.colors import Colors
from slpkg.configs import Configs
from slpkg.blacklist import Blacklist
from slpkg.errors_messages import Errors
from slpkg.error_messages import Errors
from slpkg.repositories import Repositories
from slpkg.logging_config import LoggingConfig