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