From bf5d286d591859d49984609a67f9c57011b4a6bf Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 22 May 2023 20:52:25 +0300 Subject: [PATCH] Updated for tuples --- slpkg/main.py | 22 +++++++++++----------- slpkg/utilities.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 34ee6e81..0f06c44c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -48,9 +48,6 @@ class Menu(Configs): self.repository: str = self.repos.default_repository - if len(args) == 0 or '' in args: - self.usage.help_short(1) - self.data: dict = {} self.flag_yes: str = '--yes' self.flag_short_yes: str = '-y' @@ -81,17 +78,17 @@ class Menu(Configs): self.flag_directory: str = '--directory=' self.flag_short_directory: str = '-z' - self.flag_searches: list = [ + self.flag_searches: tuple = ( self.flag_short_search, self.flag_search - ] + ) - self.flag_no_cases: list = [ + self.flag_no_cases: tuple = ( self.flag_no_case, self.flag_short_no_case - ] + ) - self.options: list = [ + self.options: tuple = ( self.flag_yes, self.flag_short_yes, self.flag_jobs, @@ -120,7 +117,7 @@ class Menu(Configs): self.flag_short_repository, self.flag_directory, self.flag_short_directory, - ] + ) self.commands: dict = { '--help': [], @@ -325,9 +322,9 @@ class Menu(Configs): def check_for_repositories(self) -> None: """ Checks combination for binaries use repositories only and if repository exists. """ - except_options: list = [ + except_options: tuple = ( '-s', 'search', - ] + ) if self.repository == '*' and not self.utils.is_option(except_options, self.args): self.usage.help_minimal(f"{self.prog_name}: invalid repository '{self.repository}'") @@ -841,6 +838,9 @@ def main() -> None: args.pop(0) usage = Usage() + if len(args) == 0 or '' in args: + usage.help_short(1) + sub_menu = SubMenu(args) arguments_no_options: dict[str] = { '-h': sub_menu.help, diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 0de1c7c1..43856984 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -107,7 +107,7 @@ class Utilities(Configs): return build @staticmethod - def is_option(options: list, flags: list) -> bool: + def is_option(options: tuple, flags: list) -> bool: """ Checking if the option is applied. """ for option in options: if option in flags: