Updated for resolve off

This commit is contained in:
Dimitris Zlatanidis 2024-03-18 21:52:48 +02:00
parent 35b8e11a63
commit 1dd6cd1ddb
5 changed files with 65 additions and 58 deletions

View file

@ -50,9 +50,6 @@ class Packages(Configs):
self.option_for_skip_installed: bool = self.utils.is_option(
('-k', '--skip-installed'), flags)
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
self.packages: list = self.utils.apply_package_pattern(data, packages)
def execute(self) -> None:
@ -78,10 +75,9 @@ class Packages(Configs):
self.utils.finished_time(elapsed_time)
def creating_dependencies_list(self) -> None:
if not self.option_for_resolve_off:
print('\rResolving dependencies... ', end='')
for package in self.packages:
dependencies: tuple = Required(self.data, package).resolve()
dependencies: tuple = Required(self.data, package, self.flags).resolve()
for dependency in dependencies:
self.dependencies.append(dependency)

View file

@ -3,6 +3,7 @@
from typing import Generator
from slpkg.utilities import Utilities
from slpkg.repositories import Repositories
@ -10,14 +11,16 @@ class Required:
""" Creates a tuple of dependencies with
the right order to install. """
__slots__ = (
'data', 'name', 'repos',
'special_repos', 'repo', 'repository_packages'
'data', 'name', 'flags', 'repos', 'utils',
'special_repos', 'repo', 'repository_packages',
'option_for_resolve_off'
)
def __init__(self, data: dict, name: str):
def __init__(self, data: dict, name: str, flags: list):
self.data: dict = data
self.name: str = name
self.repos = Repositories()
self.utils = Utilities()
self.special_repos: list = [
self.repos.salixos_repo_name,
@ -30,8 +33,13 @@ class Required:
self.repo: str = data[name]['repo']
self.repository_packages: tuple = tuple(self.data.keys())
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
def resolve(self) -> tuple:
""" Resolve the dependencies. """
dependencies: tuple = ()
if not self.option_for_resolve_off:
requires: list[str] = list(
self.remove_deps(self.data[self.name]['requires'])
)
@ -51,7 +59,9 @@ class Required:
requires.append(sub)
requires.reverse()
return tuple(dict.fromkeys(requires))
dependencies: tuple = tuple(dict.fromkeys(requires))
return dependencies
def remove_deps(self, requires: list) -> Generator:
""" Remove requires that not in the repository or blacklisted. """

View file

@ -36,12 +36,6 @@ class RemovePackages(Configs):
self.llc: str = self.ascii.lower_left_corner
self.hl: str = self.ascii.horizontal_line
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
self.option_for_yes: bool = self.utils.is_option(
('-y', '--yes'), flags)
def remove(self) -> None:
self.deps_log: dict = self.utils.read_json_file(self.deps_log_file)
self.add_packages_for_remove()

View file

@ -1,18 +1,28 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from slpkg.utilities import Utilities
class Requires:
""" Creates a tuple of dependencies with
the right order to install. """
__slots__ = ('data', 'name', 'repository_packages')
__slots__ = (
'data', 'name', 'flags', 'utils', 'option_for_resolve_off'
)
def __init__(self, data: dict, name: str):
def __init__(self, data: dict, name: str, flags: list):
self.data: dict = data
self.name: str = name
self.repository_packages: tuple = tuple(data.keys())
self.utils = Utilities()
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
def resolve(self) -> tuple:
""" Resolve the dependencies. """
dependencies: tuple = ()
if not self.option_for_resolve_off:
requires: list[str] = self.data[self.name]['requires']
for require in requires:
sub_requires: list[str] = self.data[require]['requires']
@ -20,5 +30,6 @@ class Requires:
requires.append(sub)
requires.reverse()
dependencies: tuple = tuple(dict.fromkeys(requires))
return tuple(dict.fromkeys(requires))
return dependencies

View file

@ -34,6 +34,7 @@ class Slackbuilds(Configs):
self.flags: list = flags
self.mode: str = mode
self.ascii = AsciiBox()
self.errors = Errors()
self.repos = Repositories()
self.utils = Utilities()
@ -42,7 +43,6 @@ class Slackbuilds(Configs):
self.view = View(flags, repository, data)
self.check_md5 = Md5sum(flags)
self.download = Downloader(flags)
self.ascii = AsciiBox()
self.sources: dict = {}
self.install_order: list = []
@ -57,9 +57,6 @@ class Slackbuilds(Configs):
self.option_for_skip_installed: bool = self.utils.is_option(
('-k', '--skip-installed'), flags)
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
self.option_for_jobs: bool = self.utils.is_option(
('-j', '--jobs'), flags)
@ -90,10 +87,9 @@ class Slackbuilds(Configs):
self.utils.finished_time(elapsed_time)
def creating_dependencies_list(self) -> None:
if not self.option_for_resolve_off:
print('\rResolving dependencies... ', end='')
for slackbuild in self.slackbuilds:
dependencies: tuple = Requires(self.data, slackbuild).resolve()
dependencies: tuple = Requires(self.data, slackbuild, self.flags).resolve()
for dependency in dependencies:
self.dependencies.append(dependency)
@ -216,7 +212,7 @@ class Slackbuilds(Configs):
deps: dict = {}
deps_logs: dict = {}
installed_requires: list = []
requires: tuple = Requires(self.data, name).resolve()
requires: tuple = Requires(self.data, name, self.flags).resolve()
# Verify for installation.
for req in requires:
if self.utils.is_package_installed(req):