Updated for binaries

This commit is contained in:
Dimitris Zlatanidis 2023-03-27 22:56:29 +03:00
parent 3b0e3d6e17
commit 5cf8bb0445
3 changed files with 35 additions and 20 deletions

View file

@ -4,8 +4,8 @@
from slpkg.configs import Configs
from slpkg.blacklist import Blacklist
from slpkg.repositories import Repositories
from slpkg.models.models import session as Session
from slpkg.models.models import BinariesTable
from slpkg.models.models import session as Session
class BinQueries(Configs):
@ -57,11 +57,10 @@ class BinQueries(Configs):
return repository[0]
return ''
def package_name_repo(self) -> tuple:
def package_name_with_repo(self) -> tuple:
""" Returns the package name with the repo. """
pkgs: tuple = self.session.query(
BinariesTable.name, BinariesTable.repo).filter(
BinariesTable.name == self.name).where(
BinariesTable.name, BinariesTable.repo).where(
BinariesTable.repo.in_(self.bin_repo)).all()
if pkgs:

View file

@ -433,7 +433,7 @@ class Argparse(Configs):
else:
if self.utils.is_option(self.flag_binaries, self.flags):
for pkg in packages:
pkg_repo = BinQueries(pkg, self.binary_repo).package_name_repo()
pkg_repo = BinQueries(pkg, self.binary_repo).package_name_with_repo()
for pr in pkg_repo:
repo_ver: str = BinQueries(pr[0], pr[1]).version()

View file

@ -4,6 +4,7 @@
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.sbos.queries import SBoQueries
from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries
@ -16,6 +17,7 @@ class SearchPackage(Configs):
self.color = self.colour()
self.utils = Utilities()
self.repos = Repositories()
self.yellow: str = self.color['yellow']
self.cyan: str = self.color['cyan']
@ -29,28 +31,42 @@ class SearchPackage(Configs):
""" Searching and print the matched slackbuilds. """
matching: int = 0
names: list = SBoQueries('').sbos()
if self.utils.is_option(self.flag_bin_repository, self.flags):
names: list = BinQueries('', repo).all_name_packages()
print(f'The list below shows the repo '
f'packages that contains \'{", ".join([p for p in packages])}\':\n')
for name in names:
for package in packages:
# Searching for binaries.
if self.utils.is_option(self.flag_bin_repository, self.flags):
pkg_repo: tuple = BinQueries('', repo).package_name_with_repo()
if package in name or package == '*':
matching += 1
for pkg in packages:
for pr in pkg_repo:
desc: str = SBoQueries(name).description().replace(name, '')
version: str = SBoQueries(name).version()
if pkg in pr[0] or pkg == '*':
matching += 1
if self.utils.is_option(self.flag_bin_repository, self.flags):
desc: str = BinQueries(name, repo).description()
version: str = BinQueries(name, repo).version()
desc: str = BinQueries(pr[0], pr[1]).description()
version: str = BinQueries(pr[0], pr[1]).version()
print(f'{self.cyan}{name}{self.endc}-{self.yellow}{version}{self.endc}'
f'{self.green}{desc}{self.endc}')
print(f'{pr[1]}: {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()
for name in names:
for package in packages:
if package in name or package == '*':
matching += 1
desc: str = SBoQueries(name).description().replace(name, '')
version: str = SBoQueries(name).version()
if self.utils.is_option(self.flag_bin_repository, self.flags):
desc: str = BinQueries(name, repo).description()
version: str = BinQueries(name, repo).version()
print(f'{self.repos.sbo_enabled_repository}: {self.cyan}{name}{self.endc}-{self.yellow}'
f'{version}{self.endc}{self.green}{desc}{self.endc}')
if not matching:
print('\nDoes not match any package.\n')