updated for flags

This commit is contained in:
Dimitris Zlatanidis 2023-03-29 17:24:57 +03:00
parent 23c8992032
commit dc2f5d0173
2 changed files with 9 additions and 8 deletions

View file

@ -17,7 +17,7 @@ class Upgrade(Configs):
super(Configs, self).__init__()
self.flags = flags
self.repo = repo
self.utils = Utilities()
self.utils = Utilities(self.flags)
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
@ -36,7 +36,7 @@ class Upgrade(Configs):
if inst_pkg_name in repo_packages:
if self.utils.is_package_upgradeable(inst_pkg_name, self.flags, self.repo):
if self.utils.is_package_upgradeable(inst_pkg_name, self.repo):
if not self.utils.is_option(self.flag_bin_repository, self.flags):
requires += Requires(inst_pkg_name).resolve()

View file

@ -18,7 +18,8 @@ from slpkg.binaries.queries import BinQueries
class Utilities:
def __init__(self):
def __init__(self, flags=None):
self.flags = flags
self.configs = Configs
self.colors = self.configs.colour
self.color = self.colors()
@ -33,6 +34,9 @@ class Utilities:
self.bred: str = f'{self.bold}{self.red}'
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
if self.flags is None:
self.flags: list = []
self.installed_packages: list = list(self.all_installed())
self.installed_package_names: list = list(self.all_installed_names())
@ -111,16 +115,13 @@ class Utilities:
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
time.gmtime(elapsed_time)))
def is_package_upgradeable(self, package: str, flags=None, repo='*') -> Any:
def is_package_upgradeable(self, package: str, repo='*') -> Any:
""" Checks if the package is installed and if it is upgradeable, returns true. """
installed_version: str = '0'
installed = self.is_package_installed(package)
inst_build_tag: str = self.split_binary_pkg(installed)[3]
if flags is None:
flags: list = []
if self.is_option(self.flag_bin_repository, flags):
if self.is_option(self.flag_bin_repository, self.flags):
repository_version = BinQueries(package, repo).version()
repo_package: str = BinQueries(package, repo).package_bin()
repo_build_tag: str = self.split_binary_pkg(repo_package)[3]