From ff914b6bea6c23fda07087b053e449b84c1d82b6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 24 Apr 2023 13:48:42 +0300 Subject: [PATCH] Merged for methods --- slpkg/check_updates.py | 106 +++-------------------------------------- slpkg/main.py | 5 +- slpkg/repositories.py | 4 -- 3 files changed, 9 insertions(+), 106 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index e21dffad..eda34201 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -38,35 +38,16 @@ class CheckUpdates(Configs): ['-B', '--bin-repo='], self.flags) def check(self) -> dict: - bin_repositories: dict = { - self.repos.slack_repo_name: self.slack_repository, - self.repos.slack_extra_repo_name: self.slack_extra_repository, - self.repos.slack_patches_repo_name: self.slack_patches_repository, - self.repos.alien_repo_name: self.alien_repository, - self.repos.multilib_repo_name: self.multilib_repository, - self.repos.restricted_repo_name: self.restricted_repository, - self.repos.gnome_repo_name: self.gnome_repository, - self.repos.msb_repo_name: self.msb_repository, - self.repos.csb_repo_name: self.csb_repository, - self.repos.conraid_repo_name: self.conraid_repository, - self.repos.slackonly_repo_name: self.slackonly_repository, - self.repos.salixos_repo_name: self.salixos_repository, - self.repos.salixos_extra_repo_name: self.salixos_extra_repository, - self.repos.salixos_patches_repo_name: self.salixos_patches_repository, - self.repos.slackel_repo_name: self.slackel_repository, - self.repos.slint_repo_name: self.slint_repository - } - if self.option_for_binaries: - for repo in bin_repositories.keys(): + for repo in list(self.repos.repositories.keys())[2:]: if self.repos.repositories[repo][0] and repo == self.repo: - bin_repositories[repo]() + self.binary_repository(repo) break if self.repos.repositories[repo][0] and self.repo == '*': - bin_repositories[repo]() + self.binary_repository(repo) else: if self.repos.ponce_repo: @@ -76,86 +57,11 @@ class CheckUpdates(Configs): return self.compare - def slack_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slack_repo_path, self.repos.slack_repo_changelog) - repo_chg_txt: str = f'{self.repos.slack_repo_mirror[0]}{self.repos.slack_repo_changelog}' + def binary_repository(self, repo) -> None: + local_chg_txt: Path = Path(self.repos.repositories[repo][1], self.repos.repositories[repo][5]) + repo_chg_txt: str = f'{self.repos.repositories[repo][2][0]}{self.repos.repositories[repo][5]}' self.compare[self.repos.slack_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - def slack_extra_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slack_extra_repo_path, self.repos.slack_extra_repo_changelog) - repo_chg_txt: str = f'{self.repos.slack_extra_repo_mirror[0]}{self.repos.slack_extra_repo_changelog}' - self.compare[self.repos.slack_extra_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def slack_patches_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slack_patches_repo_path, self.repos.slack_patches_repo_changelog) - repo_chg_txt: str = f'{self.repos.slack_patches_repo_mirror[0]}{self.repos.slack_patches_repo_changelog}' - self.compare[self.repos.slack_patches_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def alien_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog) - repo_chg_txt: str = f'{self.repos.alien_repo_mirror[0]}{self.repos.alien_repo_changelog}' - self.compare[self.repos.alien_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def multilib_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog) - repo_chg_txt: str = f'{self.repos.multilib_repo_mirror[0]}{self.repos.multilib_repo_changelog}' - self.compare[self.repos.multilib_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def restricted_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog) - repo_chg_txt: str = f'{self.repos.restricted_repo_mirror[0]}{self.repos.restricted_repo_changelog}' - self.compare[self.repos.restricted_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def gnome_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) - repo_chg_txt: str = f'{self.repos.gnome_repo_mirror[0]}{self.repos.gnome_repo_changelog}' - self.compare[self.repos.gnome_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def msb_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog) - repo_chg_txt: str = f'{self.repos.msb_repo_mirror[0]}{self.repos.msb_repo_changelog}' - self.compare[self.repos.msb_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def csb_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.csb_repo_path, self.repos.csb_repo_changelog) - repo_chg_txt: str = f'{self.repos.csb_repo_mirror[0]}{self.repos.csb_repo_changelog}' - self.compare[self.repos.csb_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def conraid_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) - repo_chg_txt: str = f'{self.repos.conraid_repo_mirror[0]}{self.repos.conraid_repo_changelog}' - self.compare[self.repos.conraid_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def slackonly_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_changelog) - repo_chg_txt: str = f'{self.repos.slackonly_repo_mirror[0]}{self.repos.slackonly_repo_changelog}' - self.compare[self.repos.slackonly_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def salixos_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog) - repo_chg_txt: str = f'{self.repos.salixos_repo_mirror[0]}{self.repos.salixos_repo_changelog}' - self.compare[self.repos.salixos_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def salixos_extra_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_changelog) - repo_chg_txt: str = f'{self.repos.salixos_extra_repo_mirror[0]}{self.repos.salixos_extra_repo_changelog}' - self.compare[self.repos.salixos_extra_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def salixos_patches_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_changelog) - repo_chg_txt: str = f'{self.repos.salixos_patches_repo_mirror[0]}{self.repos.salixos_patches_repo_changelog}' - self.compare[self.repos.salixos_patches_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def slackel_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog) - repo_chg_txt: str = f'{self.repos.slackel_repo_mirror[0]}{self.repos.slackel_repo_changelog}' - self.compare[self.repos.slackel_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - - def slint_repository(self) -> None: - local_chg_txt: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog) - repo_chg_txt: str = f'{self.repos.slint_repo_mirror[0]}{self.repos.slint_repo_changelog}' - self.compare[self.repos.slint_repo_name] = self.compare_dates(local_chg_txt, repo_chg_txt) - def sbo_repository(self) -> None: local_chg_txt: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog) repo_chg_txt: str = f'{self.repos.sbo_repo_mirror[0]}{self.repos.sbo_repo_changelog}' diff --git a/slpkg/main.py b/slpkg/main.py index 3b2c63fc..ed51f93c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -306,13 +306,14 @@ class Argparse(Configs): '-c', 'check-updates', ] - if self.binary_repo in self.repos.bin_repos_names and not self.repos.repositories[self.binary_repo][0]: + if (self.binary_repo in list(self.repos.repositories.keys())[2:] + and not self.repos.repositories[self.binary_repo][0]): self.usage.help_minimal(f"{self.prog_name}: repository '{self.binary_repo}' is disabled") elif self.binary_repo == '*' and not self.utils.is_option(except_options, self.args): self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") - elif self.binary_repo not in self.repos.bin_repos_names and self.binary_repo != '*': + elif self.binary_repo not in list(self.repos.repositories.keys())[2:] and self.binary_repo != '*': self.usage.help_minimal(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") def invalid_options(self) -> None: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index a16676b6..7142cc7a 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -20,7 +20,6 @@ class Repositories: repos_config = {} repositories = {} - bin_repos_name = [] sbo_repo: bool = True sbo_repo_name: str = 'sbo' @@ -530,6 +529,3 @@ class Repositories: slint_repo_changelog, slint_repo_tag] } - - # All the binary repositories names. - bin_repos_names = list(repositories.keys())[2:]