From 644522f2a7c8ed5c7a2cf6630f54937607e4b3a7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 16 Jan 2023 23:21:16 +0200 Subject: [PATCH] Updated for inheritance classes --- slpkg/download_only.py | 14 +++++++------- slpkg/upgrade.py | 15 ++++----------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 751ec6a1..9af29f7e 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -11,16 +11,16 @@ from slpkg.views.views import ViewMessage from slpkg.models.models import session as Session -class Download: +class Download(Configs, Utilities): """ Download the slackbuilds with the sources only. """ def __init__(self, directory: str, flags: list): + super(Configs, self).__init__() + super(Utilities, self).__init__() self.flags = flags self.directory = directory self.flag_directory = '--directory=' - self.configs = Configs self.session = Session - self.utils = Utilities() def packages(self, slackbuilds: list): """ Download the package only. """ @@ -28,15 +28,15 @@ class Download: view.download_packages(slackbuilds) view.question() - download_path = self.configs.download_only + download_path = self.download_only if self.flag_directory in self.flags: download_path = self.directory start = time.time() for sbo in slackbuilds: - file = f'{sbo}{self.configs.sbo_tar_suffix}' + file = f'{sbo}{self.sbo_tar_suffix}' location = SBoQueries(sbo).location() - url = f'{self.configs.sbo_repo_url}/{location}/{file}' + url = f'{self.sbo_repo_url}/{location}/{file}' down_sbo = Downloader(download_path, url, self.flags) down_sbo.download() @@ -47,4 +47,4 @@ class Download: down_source.download() elapsed_time = time.time() - start - self.utils.finished_time(elapsed_time) + self.finished_time(elapsed_time) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 0b1f32c4..3772f4ba 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -1,36 +1,29 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -from slpkg.configs import Configs from slpkg.queries import SBoQueries from slpkg.utilities import Utilities from slpkg.blacklist import Blacklist -from slpkg.dialog_box import DialogBox from slpkg.dependencies import Requires -class Upgrade: +class Upgrade(Utilities): """ Upgrade the installed packages. """ - def __init__(self): - self.configs = Configs - self.utils = Utilities() - self.dialog = DialogBox() - def packages(self): """ Compares version of packages and returns the maximum. """ repo_packages = SBoQueries('').sbos() black = Blacklist().get() upgrade, requires = [], [] - installed = self.utils.all_installed() + installed = self.all_installed() for pkg in installed: - inst_pkg_name = self.utils.split_installed_pkg(pkg)[0] + inst_pkg_name = self.split_installed_pkg(pkg)[0] if inst_pkg_name not in black and inst_pkg_name in repo_packages: - if self.utils.is_repo_version_bigger(inst_pkg_name): + if self.is_repo_version_bigger(inst_pkg_name): requires += Requires(inst_pkg_name).resolve() upgrade.append(inst_pkg_name)