diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index eaa66ce4..52be380f 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -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: diff --git a/slpkg/checks.py b/slpkg/checks.py index 315d9e9e..1867f41b 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -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 diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 11b700e7..d0cf3b4a 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -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 diff --git a/slpkg/configs.py b/slpkg/configs.py index 05ebff1d..3d306824 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -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() diff --git a/slpkg/dialog_configs.py b/slpkg/dialog_configs.py index 2ce0574e..38bb294b 100644 --- a/slpkg/dialog_configs.py +++ b/slpkg/dialog_configs.py @@ -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): diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 6d6ea62f..e315e761 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -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): diff --git a/slpkg/error_messages.py b/slpkg/error_messages.py new file mode 100644 index 00000000..c7457059 --- /dev/null +++ b/slpkg/error_messages.py @@ -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") diff --git a/slpkg/repositories.py b/slpkg/repositories.py index be1570c4..fadad566 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -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') diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 2c9a2312..aac13b9d 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -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 diff --git a/slpkg/errors_messages.py b/slpkg/toml_error_message.py similarity index 73% rename from slpkg/errors_messages.py rename to slpkg/toml_error_message.py index fa6cc853..bd83f3e1 100644 --- a/slpkg/errors_messages.py +++ b/slpkg/toml_error_message.py @@ -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 " diff --git a/slpkg/utilities.py b/slpkg/utilities.py index c77e8cb1..8e49d335 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -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