From dc2f5d0173755f82f7207c60b7dfbda00134dc3f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Mar 2023 17:24:57 +0300 Subject: [PATCH] updated for flags --- slpkg/upgrade.py | 4 ++-- slpkg/utilities.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index de3665a7..5f3913df 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -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() diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 989db245..9b07b0e5 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -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]