From b48b33ce79d0d295558984078402b9d5d8dd01c1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 19 Jun 2022 00:13:54 +0300 Subject: [PATCH] Updated views --- slpkg/views/views.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 11441b84..4107c71a 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -17,28 +17,37 @@ class ViewMessage: for sbo in slackbuilds: version = SBoQueries(sbo).version() - self._view_packages(sbo, version) + self._view_build(sbo, version) if dependencies: print('Dependencies:') for sbo in dependencies: version = SBoQueries(sbo).version() - self._view_packages(sbo, version) + self._view_build(sbo, version) def install_packages(self, slackbuilds: list, dependencies: list): print('The following packages will be installed or upgraded:\n') for sbo in slackbuilds: version = SBoQueries(sbo).version() - self._view_packages(sbo, version) + self._view_install(sbo, version) if dependencies: print('Dependencies:') for sbo in dependencies: version = SBoQueries(sbo).version() - self._view_packages(sbo, version) + self._view_install(sbo, version) - def _view_packages(self, sbo: str, version: str): + self._view_total(slackbuilds, dependencies) + + def _view_build(self, sbo: str, version: str): + color = self.colors() + + if self.utils.is_installed(f'{sbo}-{version}-'): + print(f'[{color["CYAN"]} build {color["ENDC"]}] -> ' + f'{sbo}-{version}') + + def _view_install(self, sbo: str, version: str): color = self.colors() if self.utils.is_installed(f'{sbo}-{version}-'): @@ -48,6 +57,20 @@ class ViewMessage: print(f'[{color["CYAN"]} install {color["ENDC"]}] -> ' f'{sbo}-{version}') + def _view_total(self, slackbuilds: list, dependencies: list): + slackbuilds.extend(dependencies) + installed = upgraded = 0 + + for sbo in slackbuilds: + version = SBoQueries(sbo).version() + if self.utils.is_installed(f'{sbo}-{version}-'): + upgraded += 1 + else: + installed += 1 + + print(f'\nTotal {installed} will be installed and ' + f'{upgraded} will be upgraded.') + def remove_packages(self): print('The following packages will be removed:\n')