Updated for binaries queries

This commit is contained in:
Dimitris Zlatanidis 2023-04-07 22:25:40 +03:00
parent 26b299a2f1
commit d25d6a6256

View file

@ -36,6 +36,7 @@ class Dependees(Configs):
self.flag_full_reverse: list = ['-E', '--full-reverse']
self.flag_pkg_version: list = ['-p', '--pkg-version']
self.flag_bin_repository: list = ['-B', '--bin-repo=']
self.bin_repo_dict: dict = {}
def find(self, repo: str) -> None:
""" Collecting the dependees. """
@ -43,15 +44,16 @@ class Dependees(Configs):
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
self.packages: list = self.utils.apply_package_pattern(self.flags, self.packages, repo)
self.bin_repo_dict: dict = BinQueries(repo).repository_data()
for pkg in self.packages:
dependees: list = list(self.find_requires(pkg, repo))
dependees: list = list(self.find_requires(pkg))
package: str = f'{self.byellow}{pkg}{self.endc}'
if self.utils.is_option(self.flag_pkg_version, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
version: str = BinQueries(pkg, repo).version()
version: str = self.bin_repo_dict[package][0]
else:
version: str = SBoQueries(pkg).version()
@ -71,7 +73,7 @@ class Dependees(Configs):
if self.utils.is_option(self.flag_pkg_version, self.flags):
if self.utils.is_option(self.flag_bin_repository, self.flags):
version: str = BinQueries(dep[0], repo).version()
version: str = self.bin_repo_dict[package][0]
else:
version: str = SBoQueries(dep[0]).version()
@ -91,13 +93,24 @@ class Dependees(Configs):
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
def find_requires(self, pkg: str, repo) -> Generator[str, None, None]:
def find_requires(self, pkg: str) -> Generator[str, None, None]:
""" Find requires that slackbuild dependees. """
repo_dict: dict = {}
if self.utils.is_option(self.flag_bin_repository, self.flags):
requires: list = BinQueries(pkg, repo).all_package_names_with_required()
else:
requires: list = SBoQueries('').all_sbo_and_requires()
repo_dict: dict = self.bin_repo_dict
# # requires: list = BinQueries(pkg, repo).all_package_names_with_required()
# else:
# requires: list = SBoQueries('').all_sbo_and_requires()
for req in requires:
if [r for r in req[1].split() if r == pkg]:
yield req
for repo in repo_dict.values():
if repo_dict.get(pkg):
for req in repo[6].split():
if req == pkg:
yield repo[6].split()
# for req in requires:
# # if req == pkg:
# # for r in req[1].split():
# # if r == pkg:
# if [r for r in req[1].split() if r == pkg]:
# yield req