Updated for dependees

This commit is contained in:
Dimitris Zlatanidis 2023-05-07 18:13:14 +03:00
parent b0d8aeabcb
commit 690def539a

View file

@ -9,7 +9,7 @@ from slpkg.repositories import Repositories
class Dependees(Configs):
""" Show which packages depend. """
""" Prints the packages that depend on. """
def __init__(self, data: dict, packages: list, flags: list, repository: str):
super(Configs, self).__init__()
@ -47,41 +47,43 @@ class Dependees(Configs):
if not dependees:
print(f"{'':>1}{self.cyan}No dependees{self.endc}")
for n, (name, requires) in enumerate(dependees.items(), start=1):
dependency: str = f'{self.cyan}{name}{self.endc}'
if self.option_for_pkg_version:
version: str = self.choose_version(name)
dependency: str = (f'{self.cyan}{name}{self.endc} {self.yellow}'
f'{version}{self.endc}')
self.print_dependency(n, dependency)
if self.option_for_full_reverse:
self.print_full_reverse(n, dependees, requires)
self.print_dependees(dependees)
self.summary_of_dependees(dependees, pkg)
def choose_version(self, name: str) -> str:
version: str = self.data[name][2]
if self.is_binary:
version: str = self.data[name][0]
else:
version: str = self.data[name][2]
return version
def print_dependees(self, dependees: dict) -> None:
for n, (name, requires) in enumerate(dependees.items(), start=1):
dependency: str = f'{self.cyan}{name}{self.endc}'
if self.option_for_pkg_version:
dependency: str = (f'{self.cyan}{name}{self.endc} {self.yellow}'
f'{self.choose_version(name)}{self.endc}')
self.print_dependency(n, dependency)
if self.option_for_full_reverse:
self.print_full_reverse(n, dependees, requires)
@staticmethod
def print_dependency(n: int, dependency: str) -> None:
str_dependency: str = f"{'':>4}{dependency}"
if n == 1:
print(f' {dependency}')
else:
print(f"{'':>4}{dependency}")
str_dependency: str = f"{'':>1}{dependency}"
print(str_dependency)
def print_full_reverse(self, n: int, dependees: dict, requires: str) -> None:
str_requires: str = f"{'':>5}{self.var}{self.hl} {self.violet}{requires}{self.endc}"
if n == len(dependees):
print(f"{'':>5}{self.llc}{self.hl} {self.violet}{requires}{self.endc}")
else:
print(f"{'':>5}{self.var}{self.hl} {self.violet}{requires}{self.endc}")
str_requires: str = f"{'':>5}{self.llc}{self.hl} {self.violet}{requires}{self.endc}"
print(str_requires)
def summary_of_dependees(self, dependees: dict, pkg: str) -> None:
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')