From ded1282381a1e0000cc35f3df62171a5b2209967 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 22 Sep 2024 23:36:18 +0300 Subject: [PATCH] Updated for new added packages Signed-off-by: Dimitris Zlatanidis --- slpkg/choose_packages.py | 11 ++++++++--- slpkg/main.py | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/slpkg/choose_packages.py b/slpkg/choose_packages.py index 264c1fac..3f6dcff3 100644 --- a/slpkg/choose_packages.py +++ b/slpkg/choose_packages.py @@ -9,7 +9,7 @@ from slpkg.utilities import Utilities from slpkg.dialog_box import DialogBox -class Choose(Configs): +class Choose(Configs): # pylint: disable=[R0902] """Choose packages with dialog utility and -S, --search flag.""" def __init__(self, repository: str): @@ -23,8 +23,9 @@ class Choose(Configs): self.height: int = 10 self.width: int = 70 self.list_height: int = 0 + self.ordered: bool = True - def packages(self, data: dict, packages: list, method: str) -> list: + def packages(self, data: dict, packages: list, method: str, ordered: bool = True) -> list: """Call methods to choosing packages via dialog tool. Args: @@ -38,6 +39,7 @@ class Choose(Configs): Raises: SystemExit: Exit code 0. """ + self.ordered: bool = ordered if self.dialog: title: str = f' Choose packages you want to {method} ' @@ -74,7 +76,10 @@ class Choose(Configs): def choose_for_upgraded(self, data: dict, packages: list) -> None: """Choose packages that they will going to upgrade.""" - for package in sorted(packages): + if self.ordered: + packages: list = sorted(packages) + + for package in packages: inst_package: str = self.utils.is_package_installed(package) inst_package_version: str = self.utils.split_package(inst_package)['version'] diff --git a/slpkg/main.py b/slpkg/main.py index c6c79227..a8856fa3 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -450,6 +450,7 @@ class Menu(Configs): # pylint: disable=[R0902] command: str = Menu.upgrade.__name__ removed: list = [] added: list = [] + ordered: bool = True if len(self.args) == 1: @@ -475,13 +476,14 @@ class Menu(Configs): # pylint: disable=[R0902] remove = RemovePackages(removed, self.flags) remove.remove(upgrade=True) - # New packages added to the repository are pushed to the front of - # the list to be installed first. + # If new packages are added to the repository, the sorted list will be disabled + # and the new packages will be pushed to the front of the list to be installed first. if added: packages = [pkg for pkg in packages if not pkg.endswith('_Added.')] - packages: list = added.extend(packages) + packages: list = added + packages + ordered: bool = False - packages: list = self.choose.packages(self.data, packages, command) + packages: list = self.choose.packages(self.data, packages, command, ordered) if not packages: print('\nEverything is up-to-date!\n')