mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-19 10:27:07 +01:00
Updated for errors messages
This commit is contained in:
parent
613ecad738
commit
bb22ef0530
11 changed files with 30 additions and 17 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
17
slpkg/error_messages.py
Normal 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")
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue