mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-13 20:01:48 +01:00
Updated summary
This commit is contained in:
parent
cf14800f19
commit
0f0dce5045
1 changed files with 48 additions and 52 deletions
|
@ -28,12 +28,16 @@ class View(Configs):
|
|||
self.ascii = AsciiBox()
|
||||
self.upgrade = Upgrade(repository, data)
|
||||
|
||||
self.sum_install = 0
|
||||
self.sum_upgrade = 0
|
||||
self.sum_remove = 0
|
||||
self.sum_size_comp = 0
|
||||
self.sum_size_uncomp = 0
|
||||
self.sum_size_rmv = 0
|
||||
|
||||
self.download_only = None
|
||||
self.summary_message: str = ''
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
self.option_for_reinstall: bool = self.utils.is_option(
|
||||
('-r', '--reinstall'), flags)
|
||||
|
||||
|
@ -47,6 +51,7 @@ class View(Configs):
|
|||
|
||||
for slackbuild in slackbuilds:
|
||||
self.build_package(slackbuild)
|
||||
self.summary(slackbuild, mode)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
|
@ -54,8 +59,12 @@ class View(Configs):
|
|||
|
||||
for dependency in dependencies:
|
||||
self.build_package(dependency)
|
||||
self.summary(dependency, mode)
|
||||
|
||||
self.summary(slackbuilds + dependencies, option=mode)
|
||||
self.ascii.draw_bottom_line()
|
||||
self.set_summary_for_install_and_upgrade(self.sum_install, self.sum_upgrade,
|
||||
self.sum_size_comp, self.sum_size_uncomp)
|
||||
print(self.summary_message)
|
||||
|
||||
def install_upgrade_packages(self, packages: list, dependencies: list, mode: str) -> None:
|
||||
title: str = 'slpkg install packages'
|
||||
|
@ -65,6 +74,7 @@ class View(Configs):
|
|||
|
||||
for package in packages:
|
||||
self.install_upgrade_package(package)
|
||||
self.summary(package, mode)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
|
@ -72,8 +82,12 @@ class View(Configs):
|
|||
|
||||
for dependency in dependencies:
|
||||
self.install_upgrade_package(dependency)
|
||||
self.summary(dependency, mode)
|
||||
|
||||
self.summary(packages + dependencies, option=mode)
|
||||
self.ascii.draw_bottom_line()
|
||||
self.set_summary_for_install_and_upgrade(self.sum_install, self.sum_upgrade,
|
||||
self.sum_size_comp, self.sum_size_uncomp)
|
||||
print(self.summary_message)
|
||||
|
||||
def download_packages(self, packages: list, directory: Path) -> None:
|
||||
mode: str = 'download'
|
||||
|
@ -83,8 +97,12 @@ class View(Configs):
|
|||
|
||||
for package in packages:
|
||||
self.download_package(package)
|
||||
self.summary(package, mode)
|
||||
|
||||
self.summary(packages, option=mode)
|
||||
self.ascii.draw_bottom_line()
|
||||
self.set_summary_for_install_and_upgrade(self.sum_install, self.sum_upgrade,
|
||||
self.sum_size_comp, self.sum_size_uncomp)
|
||||
print(self.summary_message)
|
||||
|
||||
def remove_packages(self, packages: list, dependencies: list) -> Any:
|
||||
mode: str = 'remove'
|
||||
|
@ -92,6 +110,7 @@ class View(Configs):
|
|||
'slpkg remove packages')
|
||||
for package in packages:
|
||||
self.remove_package(package)
|
||||
self.summary(package, mode)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
|
@ -99,17 +118,18 @@ class View(Configs):
|
|||
|
||||
for dependency in dependencies:
|
||||
self.remove_package(dependency)
|
||||
self.summary(dependency, mode)
|
||||
|
||||
self.summary(packages + dependencies, option=mode)
|
||||
self.ascii.draw_bottom_line()
|
||||
self.set_summary_for_install_and_upgrade(self.sum_install, self.sum_upgrade,
|
||||
self.sum_size_comp, self.sum_size_uncomp)
|
||||
print(self.summary_message)
|
||||
|
||||
def build_package(self, package: str) -> None:
|
||||
size: str = ''
|
||||
color: str = self.yellow
|
||||
version: str = self.data[package]['version']
|
||||
|
||||
if self.repository not in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
|
||||
size: str = self.utils.convert_file_sizes(int(self.data[package]['size_comp']))
|
||||
|
||||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def install_upgrade_package(self, package: str) -> None:
|
||||
|
@ -156,52 +176,28 @@ class View(Configs):
|
|||
|
||||
self.ascii.draw_package_line(package, version, size, self.red, repository)
|
||||
|
||||
def logs_dependencies(self, dependencies: list) -> None:
|
||||
print('The following logs will be removed:\n')
|
||||
for dep in dependencies:
|
||||
print(f'{self.yellow}{dep[0]}{self.endc}')
|
||||
self.ascii.draw_log_package(dep[1])
|
||||
def summary(self, package: str, option: str) -> None:
|
||||
installed: str = self.utils.is_package_installed(package)
|
||||
|
||||
print('Note: After cleaning you should remove them one by one.')
|
||||
if self.repository not in list(self.repos.repositories.keys())[:2] and self.repository is not None:
|
||||
self.sum_size_comp += float(self.data[package]['size_comp']) * 1024
|
||||
self.sum_size_uncomp += float(self.data[package]['size_uncomp']) * 1024
|
||||
|
||||
def summary(self, packages: list, option: str) -> None:
|
||||
install = upgrade = remove = size_comp = size_uncomp = size_rmv = int()
|
||||
if installed and option == 'remove':
|
||||
self.sum_size_rmv += self.utils.count_file_size(package)
|
||||
|
||||
for pkg in packages:
|
||||
installed: str = self.utils.is_package_installed(pkg)
|
||||
upgradeable: bool = False
|
||||
if option != 'remove':
|
||||
upgradeable: bool = self.upgrade.is_package_upgradeable(package)
|
||||
|
||||
if self.repository not in list(self.repos.repositories.keys())[:2] and self.repository is not None:
|
||||
size_comp += float(self.data[pkg]['size_comp']) * 1024
|
||||
size_uncomp += float(self.data[pkg]['size_uncomp']) * 1024
|
||||
|
||||
if installed and option == 'remove':
|
||||
size_rmv += self.utils.count_file_size(pkg)
|
||||
|
||||
upgradeable: bool = False
|
||||
if option != 'remove':
|
||||
upgradeable: bool = self.upgrade.is_package_upgradeable(pkg)
|
||||
|
||||
if not installed:
|
||||
install += 1
|
||||
elif installed and self.option_for_reinstall:
|
||||
upgrade += 1
|
||||
elif upgradeable:
|
||||
upgrade += 1
|
||||
elif installed and option == 'remove':
|
||||
remove += 1
|
||||
|
||||
self.ascii.draw_bottom_line()
|
||||
|
||||
if option in ['install', 'upgrade']:
|
||||
self.set_summary_for_install_and_upgrade(install, upgrade, size_comp, size_uncomp)
|
||||
elif option == 'build':
|
||||
self.set_summary_for_build(packages)
|
||||
elif option == 'remove':
|
||||
self.set_summary_for_remove(remove, size_rmv)
|
||||
elif option == 'download':
|
||||
self.set_summary_for_download(packages, size_comp)
|
||||
|
||||
print(self.summary_message)
|
||||
if not installed:
|
||||
self.sum_install += 1
|
||||
elif installed and self.option_for_reinstall:
|
||||
self.sum_upgrade += 1
|
||||
elif upgradeable:
|
||||
self.sum_upgrade += 1
|
||||
elif installed and option == 'remove':
|
||||
self.sum_remove += 1
|
||||
|
||||
def set_summary_for_install_and_upgrade(self, install: int, upgrade: int, size_comp: int, size_uncomp: int) -> None:
|
||||
self.summary_message: str = (
|
||||
|
|
Loading…
Reference in a new issue