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

View file

@ -6,7 +6,7 @@ from pathlib import Path
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.repositories import Repositories 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 session as Session
from slpkg.models.models import SBoTable, PonceTable, BinariesTable 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.views.ascii import Ascii
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.errors_messages import Errors from slpkg.error_messages import Errors
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage

View file

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

View file

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

View file

@ -9,7 +9,7 @@ from multiprocessing import Process
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.errors_messages import Errors from slpkg.error_messages import Errors
class Downloader(Configs): 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 dataclasses import dataclass
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.errors_messages import Errors from slpkg.toml_error_message import TomlErrors
@dataclass @dataclass
class Repositories: class Repositories:
configs = Configs configs = Configs
errors = Errors() errors = TomlErrors()
repositories_toml_file: Path = Path(configs.etc_path, 'repositories.toml') repositories_toml_file: Path = Path(configs.etc_path, 'repositories.toml')
repositories_path: Path = Path(configs.lib_path, 'repositories') 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.utilities import Utilities
from slpkg.dialog_box import DialogBox from slpkg.dialog_box import DialogBox
from slpkg.downloader import Downloader 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.views.views import ViewMessage
from slpkg.progress_bar import ProgressBar from slpkg.progress_bar import ProgressBar
from slpkg.repositories import Repositories from slpkg.repositories import Repositories

View file

@ -2,15 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class Errors: class TomlErrors:
def __init__(self): def __init__(self):
self.tool_name: str = 'slpkg' 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: def raise_toml_error_message(self, error, toml_file) -> None:
""" A general error message for .toml configs files. """ """ A general error message for .toml configs files. """
raise SystemExit(f"\n{self.tool_name} Error: {error}: in the configuration file " 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.colors import Colors
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.blacklist import Blacklist from slpkg.blacklist import Blacklist
from slpkg.errors_messages import Errors from slpkg.error_messages import Errors
from slpkg.repositories import Repositories from slpkg.repositories import Repositories
from slpkg.logging_config import LoggingConfig from slpkg.logging_config import LoggingConfig