Updated for summary

This commit is contained in:
Dimitris Zlatanidis 2023-04-27 11:13:45 +03:00
parent 0444437b49
commit 6f90eb27bf
2 changed files with 23 additions and 9 deletions

View file

@ -1,6 +1,7 @@
4.8.2 - 25/04/2023
Updated:
- For exit status code
- Packages summary for calculating the file sizes
Added:
- Disable or enable the spinning bar
Fixed:

View file

@ -211,16 +211,23 @@ class ViewMessage(Configs):
def summary(self, packages: list, dependencies: list, option: str) -> None:
""" View the status of the packages action. """
packages.extend(dependencies)
install = upgrade = remove = 0
install = upgrade = remove = size_comp = size_uncomp = size_rmv = 0
for pkg in packages:
if self.option_for_binaries:
size_comp += int(''.join(re.findall(r'\d+', self.data[pkg][4])))
size_uncomp += int(''.join(re.findall(r'\d+', self.data[pkg][5])))
upgradeable: bool = False
if option != 'remove':
upgradeable: bool = self.upgrade.is_package_upgradeable(pkg)
installed: str = self.utils.is_package_installed(pkg)
if installed and option == 'remove':
size_rmv += Path(self.log_packages, installed).stat().st_size
if not installed:
install += 1
elif installed and self.option_for_reinstall:
@ -236,7 +243,9 @@ class ViewMessage(Configs):
if option in ['install', 'upgrade']:
print(f'{self.grey}Total {install} packages will be '
f'installed and {upgrade} will be upgraded.{self.endc}')
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 '
@ -244,10 +253,11 @@ class ViewMessage(Configs):
elif option == 'remove':
print(f'{self.grey}Total {remove} packages '
f'will be removed.{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':
print(f'{self.grey}{len(packages)} packages '
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}')
def logs_packages(self, dependencies: list) -> None:
@ -262,8 +272,11 @@ class ViewMessage(Configs):
def question(self) -> None:
""" Manage to proceed. """
if not self.option_for_yes and self.ask_question:
answer: str = input('\nDo you want to continue? [y/N] ')
if answer not in ['Y', 'y']:
raise SystemExit()
print()
try:
if not self.option_for_yes and self.ask_question:
answer: str = input('\nDo you want to continue? [y/N] ')
if answer not in ['Y', 'y']:
raise SystemExit()
print()
except KeyboardInterrupt:
raise SystemExit()