2022-12-23 20:17:06 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from slpkg.configs import Configs
|
2023-01-04 12:15:10 +02:00
|
|
|
from slpkg.views.ascii import Ascii
|
2023-01-27 23:45:36 +02:00
|
|
|
from slpkg.utilities import Utilities
|
2023-03-28 20:50:59 +03:00
|
|
|
from slpkg.sbos.queries import SBoQueries
|
|
|
|
from slpkg.binaries.queries import BinQueries
|
2022-12-23 20:17:06 +02:00
|
|
|
|
|
|
|
|
2023-03-28 20:50:59 +03:00
|
|
|
class Tracking(Configs):
|
2022-12-23 20:17:06 +02:00
|
|
|
""" Tracking of the package dependencies. """
|
|
|
|
|
2023-01-17 21:03:01 +02:00
|
|
|
def __init__(self, flags: list):
|
2023-04-08 19:57:26 +03:00
|
|
|
__slots__ = 'flags'
|
2023-01-17 01:04:20 +02:00
|
|
|
super(Configs, self).__init__()
|
2023-03-01 13:03:53 +02:00
|
|
|
self.flags: list = flags
|
2023-03-01 18:03:35 +02:00
|
|
|
|
2023-01-04 12:15:10 +02:00
|
|
|
self.ascii = Ascii()
|
2023-03-01 18:03:35 +02:00
|
|
|
self.color = self.colour()
|
2023-03-28 20:50:59 +03:00
|
|
|
self.utils = Utilities()
|
2023-03-01 18:03:35 +02:00
|
|
|
|
2023-03-01 13:03:53 +02:00
|
|
|
self.llc: str = self.ascii.lower_left_corner
|
|
|
|
self.hl: str = self.ascii.horizontal_line
|
|
|
|
self.vl: str = self.ascii.vertical_line
|
|
|
|
self.cyan: str = self.color['cyan']
|
|
|
|
self.grey: str = self.color['grey']
|
|
|
|
self.yellow: str = self.color['yellow']
|
|
|
|
self.endc: str = self.color['endc']
|
2023-03-01 18:03:35 +02:00
|
|
|
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
2023-04-03 17:16:36 +03:00
|
|
|
self.flag_bin_repository: list = ['-B', '--bin-repo=']
|
2022-12-23 20:17:06 +02:00
|
|
|
|
2023-03-28 20:50:59 +03:00
|
|
|
def packages(self, packages: list, repo: str) -> None:
|
2022-12-23 20:17:06 +02:00
|
|
|
""" Prints the packages dependencies. """
|
2023-04-01 12:59:05 +03:00
|
|
|
print(f"The list below shows the packages '{', '.join([p for p in packages])}' with dependencies:\n")
|
2023-04-08 12:31:44 +03:00
|
|
|
sbo_repo_dict: dict = {}
|
|
|
|
bin_repo_dict: dict = {}
|
2022-12-23 20:17:06 +02:00
|
|
|
|
2023-04-01 12:53:31 +03:00
|
|
|
packages: list = self.utils.apply_package_pattern(self.flags, packages, repo)
|
2023-04-08 12:31:44 +03:00
|
|
|
|
|
|
|
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
|
|
|
bin_repo_dict: dict = BinQueries(repo).repository_data()
|
|
|
|
else:
|
|
|
|
sbo_repo_dict: dict = SBoQueries('').repository_data()
|
2023-04-01 12:27:53 +03:00
|
|
|
|
2023-03-01 13:03:53 +02:00
|
|
|
char: str = f' {self.llc}{self.hl}'
|
|
|
|
sp: str = ' ' * 4
|
2023-03-30 18:17:10 +03:00
|
|
|
|
2023-01-17 01:06:04 +02:00
|
|
|
for package in packages:
|
2023-01-17 21:03:01 +02:00
|
|
|
pkg = f'{self.yellow}{package}{self.endc}'
|
|
|
|
|
2023-03-28 20:50:59 +03:00
|
|
|
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
|
|
|
|
|
|
|
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
2023-04-07 22:01:11 +03:00
|
|
|
version: str = bin_repo_dict[package][0]
|
2023-04-08 12:31:44 +03:00
|
|
|
else:
|
|
|
|
version: str = sbo_repo_dict[package][2]
|
2023-03-28 20:50:59 +03:00
|
|
|
|
2023-03-31 22:16:51 +03:00
|
|
|
pkg = f'{self.yellow}{package} {version}{self.endc}'
|
2023-03-28 20:50:59 +03:00
|
|
|
|
|
|
|
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
2023-04-08 12:38:46 +03:00
|
|
|
requires: list = bin_repo_dict[package][6].split()
|
2023-03-28 20:50:59 +03:00
|
|
|
else:
|
2023-04-08 12:38:46 +03:00
|
|
|
requires: list = sbo_repo_dict[package][7].split()
|
2023-01-17 21:03:01 +02:00
|
|
|
|
2023-03-01 13:03:53 +02:00
|
|
|
how_many: int = len(requires)
|
2022-12-23 20:17:06 +02:00
|
|
|
|
2023-01-17 21:03:01 +02:00
|
|
|
print(pkg)
|
2023-01-17 20:32:44 +02:00
|
|
|
print(char, end='')
|
2023-01-17 21:03:01 +02:00
|
|
|
|
2023-03-30 18:17:10 +03:00
|
|
|
if not requires:
|
|
|
|
print(f' {self.cyan}No dependencies{self.endc}')
|
|
|
|
else:
|
|
|
|
for i, req in enumerate(requires, start=1):
|
|
|
|
require: str = f'{self.cyan}{req}{self.endc}'
|
|
|
|
|
|
|
|
if self.utils.is_option(self.flag_pkg_version, self.flags):
|
2023-03-28 20:50:59 +03:00
|
|
|
|
2023-03-30 18:17:10 +03:00
|
|
|
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
2023-04-07 22:01:11 +03:00
|
|
|
version: str = f" {self.yellow}{bin_repo_dict[req][0]}{self.endc}"
|
2023-04-08 12:31:44 +03:00
|
|
|
else:
|
|
|
|
version: str = f" {self.yellow}{sbo_repo_dict[req][2]}{self.endc}"
|
2023-03-28 20:50:59 +03:00
|
|
|
|
2023-03-30 18:17:10 +03:00
|
|
|
require: str = f'{self.cyan}{req}{self.endc}{version}'
|
2023-01-17 21:03:01 +02:00
|
|
|
|
2023-03-30 18:17:10 +03:00
|
|
|
if i == 1:
|
|
|
|
print(f' {require}')
|
|
|
|
else:
|
|
|
|
print(f'{sp}{require}')
|
2023-01-17 21:03:01 +02:00
|
|
|
|
2023-01-04 12:15:10 +02:00
|
|
|
print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n')
|