Updated for skipped

This commit is contained in:
Dimitris Zlatanidis 2023-03-25 21:48:46 +02:00
parent fc306ca789
commit 64f6a6e394

View file

@ -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