diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index a87b5d6b..3b5a52d4 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -40,11 +40,11 @@ class BinQueries(Configs): return [pkg[0] for pkg in pkgs] - def all_package_name_with_repo(self) -> tuple: + def package_names_from_all_repositories(self) -> tuple: """ Returns the package name with the repo. """ pkgs: tuple = self.session.query( BinariesTable.name, BinariesTable.repo).where( - BinariesTable.repo == self.repo).all() + BinariesTable.repo.in_(self.repos.bin_enabled_repos)).all() if pkgs: return pkgs diff --git a/slpkg/main.py b/slpkg/main.py index c09694dc..beb2bba4 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -287,7 +287,8 @@ class Argparse(Configs): and not self.utils.is_option(self.flag_binaries, self.flags)): self.usage.help_minimal(f"{self.prog_name}: invalid options '{', '.join(self.flags)}'") - if self.binary_repo not in self.repos.binaries_repositories_dict.keys(): + if self.binary_repo not in self.repos.binaries_repositories_dict.keys() \ + and self.binary_repo == '*' and not self.utils.is_option(['-s', 'search'], self.args): 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 5985a93e..313244a3 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -22,7 +22,7 @@ class Repositories: repos = {} binaries_repositories_dict = {} - bin_enabled_repositories = [] + bin_enabled_repos = [] sbo_enabled: bool = True sbo_repo_name: str = 'sbo' @@ -146,7 +146,7 @@ class Repositories: # All enabled binaries repositories. for repo, enable in binaries_repositories_dict.items(): if enable: - bin_enabled_repositories.append(repo) + bin_enabled_repos.append(repo) if ponce_repo: sbo_enabled_repository: str = ponce_repo_name diff --git a/slpkg/search.py b/slpkg/search.py index 2c5f8e2a..84e0fabf 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -37,22 +37,38 @@ class SearchPackage(Configs): # Searching for binaries. if self.utils.is_option(self.flag_bin_repository, self.flags): - pkg_repo: tuple = BinQueries('', repo).all_package_name_with_repo() + if repo == '*': + pkg_repo: tuple = BinQueries('', repo).package_names_from_all_repositories() - for pkg in packages: - for pr in pkg_repo: + for pkg in packages: + for pr in pkg_repo: - if pkg in pr[0] or pkg == '*': - matching += 1 + if pkg in pr[0] or pkg == '*': + matching += 1 - desc: str = BinQueries(pr[0], pr[1]).description() - version: str = BinQueries(pr[0], pr[1]).version() + desc: str = BinQueries(pr[0], pr[1]).description() + version: str = BinQueries(pr[0], pr[1]).version() - if repo == '*': - repository: str = f'{pr[1]}: ' + if repo == '*': + repository: str = f'{pr[1]}: ' + + print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' + f'{self.green}{desc}{self.endc}') + else: + pkg_repo: list = BinQueries('', repo).all_package_names() + + for pkg in packages: + for pr in pkg_repo: + + if pkg in pr: + matching += 1 + + desc: str = BinQueries(pr, repo).description() + version: str = BinQueries(pr, repo).version() + + print(f'{repository}{self.cyan}{pr}{self.endc}-{self.yellow}{version}{self.endc}' + f'{self.green}{desc}{self.endc}') - print(f'{repository}{self.cyan}{pr[0]}{self.endc}-{self.yellow}{version}{self.endc}' - f'{self.green}{desc}{self.endc}') else: # Searching for slackbuilds. names: list = SBoQueries('').sbos()