mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-29 10:26:12 +01:00
Updated for views
This commit is contained in:
parent
69860b8492
commit
fb77b57b79
3 changed files with 36 additions and 31 deletions
|
@ -65,7 +65,7 @@ class Packages(Configs):
|
|||
def execute(self) -> None:
|
||||
self.dependencies()
|
||||
|
||||
self.view_message.install_packages(self.packages, self.packages_requires, self.mode)
|
||||
self.view_message.install_upgrade_packages(self.packages, self.packages_requires, self.mode)
|
||||
self.view_message.question()
|
||||
|
||||
start: float = time.time()
|
||||
|
|
|
@ -135,7 +135,7 @@ class Slackbuilds(Configs):
|
|||
def view_before_build(self) -> None:
|
||||
""" View slackbuilds before proceed. """
|
||||
if not self.mode == 'build':
|
||||
self.view_message.install_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||
self.view_message.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||
else:
|
||||
self.view_message.build_packages(self.slackbuilds, self.dependencies)
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ class ViewMessage(Configs):
|
|||
else:
|
||||
version: str = self.data[package][2]
|
||||
|
||||
# Default highlight colors for all modes
|
||||
if mode in ['install', 'download']:
|
||||
color: str = self.cyan
|
||||
if mode == 'build':
|
||||
|
@ -66,13 +67,12 @@ class ViewMessage(Configs):
|
|||
if mode == 'upgrade':
|
||||
color: str = self.violet
|
||||
|
||||
if package in list(self.utils.installed_packages.keys()) and mode == 'install':
|
||||
# Change the colors for install mode
|
||||
if self.utils.is_package_installed(package) and mode == 'install':
|
||||
color: str = self.grey
|
||||
|
||||
if self.upgrade.is_package_upgradeable(package) and mode == 'install':
|
||||
color: str = self.violet
|
||||
|
||||
if (package in list(self.utils.installed_packages.keys()) and mode == 'install'
|
||||
if (self.utils.is_package_installed(package) and mode == 'install'
|
||||
and self.option_for_reinstall):
|
||||
color: str = self.violet
|
||||
|
||||
|
@ -84,25 +84,23 @@ class ViewMessage(Configs):
|
|||
|
||||
def build_packages(self, slackbuilds: list, dependencies: list) -> None:
|
||||
""" View packages for build only. """
|
||||
mode = 'build'
|
||||
self.ascii.draw_package_title_box('The following packages will be build:', 'slpkg build packages')
|
||||
|
||||
for sbo in slackbuilds:
|
||||
self.view_packages(sbo, mode='build')
|
||||
self.view_packages(sbo, mode=mode)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for sbo in dependencies:
|
||||
self.view_packages(sbo, mode='build')
|
||||
self.view_packages(sbo, mode=mode)
|
||||
|
||||
self.summary(slackbuilds, dependencies, option='build')
|
||||
self.summary(slackbuilds, dependencies, option=mode)
|
||||
|
||||
def install_packages(self, packages: list, dependencies: list, mode: str) -> None:
|
||||
def install_upgrade_packages(self, packages: list, dependencies: list, mode: str) -> None:
|
||||
""" View packages for install. """
|
||||
if dependencies is None:
|
||||
dependencies: list = []
|
||||
|
||||
title: str = 'slpkg install packages'
|
||||
if mode == 'upgrade':
|
||||
title: str = 'slpkg upgrade packages'
|
||||
|
@ -135,6 +133,7 @@ class ViewMessage(Configs):
|
|||
|
||||
def remove_packages(self, packages: list) -> Any:
|
||||
""" View remove packages. """
|
||||
mode = 'remove'
|
||||
pkgs, dependencies = [], []
|
||||
|
||||
for pkg in packages:
|
||||
|
@ -159,13 +158,12 @@ class ViewMessage(Configs):
|
|||
if dependencies and not self.option_for_resolve_off:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for pkg in dependencies:
|
||||
self._view_removed(pkg)
|
||||
else:
|
||||
dependencies: list = []
|
||||
|
||||
self.summary(pkgs, dependencies, option='remove')
|
||||
self.summary(pkgs, dependencies, option=mode)
|
||||
|
||||
return self.installed_packages, dependencies
|
||||
|
||||
|
@ -195,7 +193,6 @@ class ViewMessage(Configs):
|
|||
choices.extend([(package, inst_ver, True, f'Package: {inst_pkg}')])
|
||||
|
||||
text: str = f'There are {len(choices)} dependencies:'
|
||||
|
||||
code, tags = self.dialogbox.checklist(text, dependencies, title, height,
|
||||
width, list_height, choices)
|
||||
|
||||
|
@ -206,8 +203,8 @@ class ViewMessage(Configs):
|
|||
return tags
|
||||
|
||||
def summary(self, packages: list, dependencies: list, option: str) -> None:
|
||||
""" View the status of the packages action. """
|
||||
packages.extend(dependencies)
|
||||
summary_message: str = ''
|
||||
install = upgrade = remove = size_comp = size_uncomp = size_rmv = 0
|
||||
|
||||
for pkg in packages:
|
||||
|
@ -230,9 +227,7 @@ class ViewMessage(Configs):
|
|||
install += 1
|
||||
elif installed and self.option_for_reinstall:
|
||||
upgrade += 1
|
||||
elif installed and upgradeable and self.option_for_reinstall:
|
||||
upgrade += 1
|
||||
elif installed and upgradeable:
|
||||
elif upgradeable:
|
||||
upgrade += 1
|
||||
elif installed and option == 'remove':
|
||||
remove += 1
|
||||
|
@ -240,23 +235,33 @@ class ViewMessage(Configs):
|
|||
self.ascii.draw_bottom_line()
|
||||
|
||||
if option in ['install', 'upgrade']:
|
||||
print(f'{self.grey}Total {install} packages will be '
|
||||
f'installed and {upgrade} will be upgraded, and total '
|
||||
f'{self.utils.convert_file_sizes(size_comp)} will be downloaded and '
|
||||
f'{self.utils.convert_file_sizes(size_uncomp)} will be installed.{self.endc} ')
|
||||
summary_message: str = (
|
||||
f'{self.grey}Total {install} packages will be '
|
||||
f'installed and {upgrade} will be upgraded, and total '
|
||||
f'{self.utils.convert_file_sizes(size_comp)} will be downloaded and '
|
||||
f'{self.utils.convert_file_sizes(size_uncomp)} will be installed.{self.endc} '
|
||||
)
|
||||
|
||||
elif option == 'build':
|
||||
print(f'{self.grey}Total {len(packages)} packages '
|
||||
f'will be build in {self.tmp_path} folder.{self.endc}')
|
||||
summary_message: str = (
|
||||
f'{self.grey}Total {len(packages)} packages '
|
||||
f'will be build in {self.tmp_path} folder.{self.endc}'
|
||||
)
|
||||
|
||||
elif option == 'remove':
|
||||
print(f'{self.grey}Total {remove} packages '
|
||||
f'will be removed and {self.utils.convert_file_sizes(size_rmv)} '
|
||||
f'of space will be freed up.{self.endc}')
|
||||
summary_message: str = (
|
||||
f'{self.grey}Total {remove} packages '
|
||||
f'will be removed and {self.utils.convert_file_sizes(size_rmv)} '
|
||||
f'of space will be freed up.{self.endc}'
|
||||
)
|
||||
|
||||
elif option == 'download':
|
||||
print(f'{self.grey}Total {len(packages)} packages and {self.utils.convert_file_sizes(size_comp)} '
|
||||
f'will be downloaded in {self.download_only} folder.{self.endc}')
|
||||
summary_message: str = (
|
||||
f'{self.grey}Total {len(packages)} packages and {self.utils.convert_file_sizes(size_comp)} '
|
||||
f'will be downloaded in {self.download_only} folder.{self.endc}'
|
||||
)
|
||||
|
||||
print(summary_message)
|
||||
|
||||
def logs_packages(self, dependencies: list) -> None:
|
||||
""" View the logging packages. """
|
||||
|
|
Loading…
Reference in a new issue