Updated for dialog

This commit is contained in:
Dimitris Zlatanidis 2023-03-08 09:38:08 +02:00
parent 0e9f1bd7db
commit 22dabe9f4d
2 changed files with 13 additions and 10 deletions

View file

@ -15,12 +15,25 @@ class FormConfigs(Configs):
super(Configs).__init__() super(Configs).__init__()
self.load_configs = LoadConfigs() self.load_configs = LoadConfigs()
self.dialogbox = DialogBox() self.dialogbox = DialogBox()
self.color = self.colour()
self.orig_configs: list = [] self.orig_configs: list = []
self.config_file = Path(self.etc_path, f'{self.prog_name}.toml') self.config_file = Path(self.etc_path, f'{self.prog_name}.toml')
self.bold: str = self.color['bold']
self.red: str = self.color['red']
self.endc: str = self.color['endc']
self.bred: str = f'{self.bold}{self.red}'
def is_dialog_enabled(self):
""" Checking if the dialog box is enabled by the user. """
if not self.dialog:
raise SystemExit(f"\n[{self.bred}Error{self.endc}]: You should enable the dialog "
"in the '/etc/slpkg/slpkg.toml' file.\n")
def edit(self) -> None: def edit(self) -> None:
""" Read and write the configuration file. """ """ Read and write the configuration file. """
self.is_dialog_enabled()
elements: list = [] elements: list = []
height: int = 35 height: int = 35
width: int = 74 width: int = 74

View file

@ -82,8 +82,6 @@ class Argparse(Configs):
self.flag_searches: list = [self.flag_short_search, self.flag_search] self.flag_searches: list = [self.flag_short_search, self.flag_search]
self.is_dialog_enabled()
self.options: list = [ self.options: list = [
self.flag_yes, self.flag_yes,
self.flag_short_yes, self.flag_short_yes,
@ -303,14 +301,6 @@ class Argparse(Configs):
self.args.remove(opt) self.args.remove(opt)
self.flags.append(opt) self.flags.append(opt)
def is_dialog_enabled(self) -> None:
""" Checking if the dialog box is enabled. """
if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or
not self.dialogbox.dialog and not self.utils.is_option(['-g', 'configs'], self.flags)):
raise SystemExit(f"\n[{self.bred}Error{self.endc}]: You should enable the dialog "
"in the '/etc/slpkg/slpkg.toml' file.\n")
def check_for_flags(self, command: str) -> None: def check_for_flags(self, command: str) -> None:
""" Check for correct flags. """ """ Check for correct flags. """
flags: list = self.commands[command] flags: list = self.commands[command]