Fixed for methods

This commit is contained in:
Dimitris Zlatanidis 2023-05-07 17:31:23 +03:00
parent 6246e9fa0f
commit e3549d8df0

View file

@ -34,22 +34,14 @@ class Dependees(Configs):
['-p', '--pkg-version'], flags)
def find(self) -> None:
""" Collecting the dependees. """
print(f"The list below shows the "
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
self.packages: list = self.utils.apply_package_pattern(self.data, self.packages)
for pkg in self.packages:
dependees: dict = dict(self.find_requires(pkg))
package: str = f'{self.byellow}{pkg}{self.endc}'
if self.option_for_pkg_version:
if self.is_binary:
version: str = self.data[pkg][0]
else:
version: str = self.data[pkg][2]
package: str = f'{self.byellow}{pkg} {version}{self.endc}'
print(package)
print(f' {self.llc}{self.hl}', end='')
@ -57,29 +49,40 @@ class Dependees(Configs):
print(f'{self.cyan} No dependees{self.endc}')
sp: str = ' ' * 4
for i, (name, requires) in enumerate(dependees.items(), start=1):
for n, (name, requires) in enumerate(dependees.items(), start=1):
dependency: str = f'{self.cyan}{name}{self.endc}'
if self.option_for_pkg_version:
if self.is_binary:
version: str = self.data[name][0]
else:
version: str = self.data[name][2]
version: str = self.choose_version(name)
dependency: str = (f'{self.cyan}{name}{self.endc} {self.yellow}'
f'{version}{self.endc}')
if i == 1:
if n == 1:
print(f' {dependency}')
else:
print(f'{sp}{dependency}')
if self.option_for_full_reverse:
if i == len(dependees):
print(' ' * 4 + f' {self.llc}{self.hl} {self.violet}{requires}{self.endc}')
else:
print(' ' * 4 + f' {self.var}{self.hl} {self.violet}{requires}{self.endc}')
self.print_full_reverse(n, dependees, requires)
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
self.summary_of_dependees(dependees, pkg)
def choose_version(self, name: str) -> str:
if self.is_binary:
version: str = self.data[name][0]
else:
version: str = self.data[name][2]
return version
def print_full_reverse(self, n: int, dependees: dict, requires: str) -> None:
if n == len(dependees):
print(' ' * 4 + f' {self.llc}{self.hl} {self.violet}{requires}{self.endc}')
else:
print(' ' * 4 + f' {self.var}{self.hl} {self.violet}{requires}{self.endc}')
def summary_of_dependees(self, dependees: dict, pkg: str) -> None:
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')
def find_requires(self, pkg: str) -> Generator:
""" Find requires that package dependees. """