Updated for methods

This commit is contained in:
Dimitris Zlatanidis 2023-05-09 17:30:45 +03:00
parent 659c383c95
commit b304d10db9

View file

@ -35,20 +35,14 @@ class Dependees(Configs):
['-p', '--pkg-version'], flags) ['-p', '--pkg-version'], flags)
def find(self) -> None: def find(self) -> None:
print(f"The list below shows the " self.view_the_title()
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
self.packages: tuple = tuple(self.utils.apply_package_pattern(self.data, self.packages))
for pkg in self.packages: for pkg in self.packages:
dependees: dict = dict(self.find_requires(pkg)) dependees: dict = dict(self.find_requires(pkg))
print(f'{self.byellow}{pkg}{self.endc}') self.view_the_main_package(pkg)
print(f"{'':>1}{self.llc}{self.hl}", end='') self.view_no_dependees(dependees)
self.view_dependees(dependees)
if not dependees: self.view_summary_of_dependees(dependees, pkg)
print(f"{'':>1}{self.cyan}No dependees{self.endc}")
self.print_dependees(dependees)
self.summary_of_dependees(dependees, pkg)
def set_the_package_version(self, name: str): def set_the_package_version(self, name: str):
if self.is_binary: if self.is_binary:
@ -56,35 +50,6 @@ class Dependees(Configs):
else: else:
self.package_version: str = self.data[name][2] self.package_version: str = self.data[name][2]
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:
self.set_the_package_version(name)
dependency: str = (f'{self.cyan}{name}{self.endc} {self.yellow}'
f'{self.package_version}{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:
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):
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')
def find_requires(self, pkg: str) -> Generator: def find_requires(self, pkg: str) -> Generator:
""" Find requires that package dependees. """ """ Find requires that package dependees. """
if self.is_binary: if self.is_binary:
@ -95,3 +60,45 @@ class Dependees(Configs):
for name, data in self.data.items(): for name, data in self.data.items():
if pkg in data[7].split(): if pkg in data[7].split():
yield name, data[7] yield name, data[7]
def view_the_title(self) -> None:
print(f"The list below shows the "
f"packages that dependees on '{', '.join([p for p in self.packages])}':\n")
self.packages: tuple = tuple(self.utils.apply_package_pattern(self.data, self.packages))
def view_no_dependees(self, dependees: dict) -> None:
if not dependees:
print(f"{'':>1}{self.cyan}No dependees{self.endc}")
def view_the_main_package(self, pkg):
print(f'{self.byellow}{pkg}{self.endc}')
print(f"{'':>1}{self.llc}{self.hl}", end='')
@staticmethod
def view_dependency_line(n: int, dependency: str) -> None:
str_dependency: str = f"{'':>4}{dependency}"
if n == 1:
str_dependency: str = f"{'':>1}{dependency}"
print(str_dependency)
def view_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:
self.set_the_package_version(name)
dependency: str = (f'{self.cyan}{name}{self.endc} {self.yellow}'
f'{self.package_version}{self.endc}')
self.view_dependency_line(n, dependency)
if self.option_for_full_reverse:
self.view_full_reverse(n, dependees, requires)
def view_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):
str_requires: str = f"{'':>5}{self.llc}{self.hl} {self.violet}{requires}{self.endc}"
print(str_requires)
def view_summary_of_dependees(self, dependees: dict, pkg: str) -> None:
print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n')