From 8d4166a2aa51ee5321b3500bffb026589119669a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 25 Mar 2024 21:53:43 +0200 Subject: [PATCH] Updated for color --- slpkg/upgrade.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 55161df5..e3f2899a 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -62,7 +62,6 @@ class Upgrade(Configs): # if not self.utils.is_package_installed(name): if name not in self.installed_names: yield name - print(f'{self.bgreen}{self.ascii.done}{self.endc}') def is_package_upgradeable(self, installed: str) -> bool: @@ -100,7 +99,7 @@ class Upgrade(Configs): 'repo_build': repo_build, 'inst_version': inst_version, 'inst_build': inst_build, - 'repo': self.repository + 'type': 'upgrade' } if self.repository == self.repos.slack_repo_name and self.removed_packages: @@ -118,7 +117,7 @@ class Upgrade(Configs): 'repo_build': repo_build, 'inst_version': inst_version, 'inst_build': inst_build, - 'repo': self.repository + 'type': 'remove' } if self.repository == self.repos.slack_repo_name and self.new_packages: @@ -129,8 +128,8 @@ class Upgrade(Configs): self.sum_added += 1 repo_version: str = self.data[name]['version'] repo_build: str = self.data[name]['build'] - inst_version: str = self.utils.split_package(name)['version'] - inst_build: str = self.utils.split_package(name)['build'] + inst_version: str = '' + inst_build: str = '' found_packages[self.id]: dict = { 'name': name, @@ -138,7 +137,7 @@ class Upgrade(Configs): 'repo_build': repo_build, 'inst_version': inst_version, 'inst_build': inst_build, - 'repo': self.repository + 'type': 'add' } if found_packages: @@ -153,6 +152,7 @@ class Upgrade(Configs): repo_build: str = data['repo_build'] inst_version: str = data['inst_version'] inst_build: str = data['inst_build'] + mode: str = data['type'] if len(name) > 17: name: str = f'{name[:14]}...' @@ -161,8 +161,14 @@ class Upgrade(Configs): if len(repo_version) > 15: repo_version: str = f"{repo_version[:11]}..." - print(f"{name:<18} {inst_version:<15} {inst_build:<6} {repo_version:<15} " - f"{repo_build:<5} {data['repo']:>15}") + color: str = self.violet + if mode == 'remove': + color: str = self.red + if mode == 'add': + color: str = self.cyan + + print(f"{color}{name:<18}{self.endc} {inst_version:<15} {inst_build:<6} {repo_version:<15} " + f"{repo_build:<5} {self.repository:>15}") print(len(title) * '=') print(f'{self.grey}Packages to upgrade {self.sum_upgrade}, packages to remove '