From 64f6a6e3948addbc6e872b5479152533dad8bece Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 25 Mar 2023 21:48:46 +0200 Subject: [PATCH] Updated for skipped --- slpkg/binaries/install.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 3aa9812a..697d3e4a 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -20,13 +20,18 @@ class Packages(Configs): self.repo: str = repo self.mode: str = mode + self.color = self.colour() self.utils = Utilities() self.repos = Repositories() self.view_message = ViewMessage(self.flags) + self.cyan: str = self.color['cyan'] + self.endc: str = self.color['endc'] + self.binary_packages: list = [] self.flag_binary: list = ['-B', '--binary'] self.flag_reinstall: list = ['-r', '--reinstall'] + self.flag_skip_installed: list = ['-k', '--skip-installed'] def execute(self) -> None: self.view_message.install_packages(self.packages, self.mode) @@ -40,6 +45,9 @@ class Packages(Configs): pkg_urls: list = [] for pkg in self.packages: + if self.skip_installed_package(pkg): + continue + mirror: str = BinQueries(pkg, self.repo).mirror() location: str = BinQueries(pkg, self.repo).location() package: str = BinQueries(pkg, self.repo).package_bin() @@ -67,4 +75,15 @@ class Packages(Configs): for package in self.binary_packages: command: str = f'{slack_command} {self.tmp_slpkg}/{package}' + + if self.skip_installed_package(package): + continue + self.utils.process(command) + + def skip_installed_package(self, package) -> bool: + """ Skip installed package when the option --skip-installed is applied. """ + if (self.utils.is_option(self.flag_skip_installed, self.flags) and + self.utils.is_package_installed(package, self.file_pattern)): + print(f"slpkg: package '{self.cyan}{package}{self.endc}' skipped by the user.") + return True