Fixed for search

This commit is contained in:
Dimitris Zlatanidis 2023-03-29 23:36:59 +03:00
parent 37c008dbb2
commit 6b404ae992
4 changed files with 33 additions and 16 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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()