diff --git a/configs/repositories.toml b/configs/repositories.toml index dfbcb9bc..aa449ad9 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -1,7 +1,21 @@ # Repositories configuration file. [REPOSITORIES] -GNOME_REPO = true -GNOME_REPO_URL = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" -GNOME_REPO_PKG_TXT = "PACKAGES.TXT" -GNOME_REPO_CHGLOG_TXT = "ChangeLog.txt" + SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/" + SBO_REPO_TXT = "SLACKBUILDS.TXT" + SBO_REPO_CHGLOG_TXT = "ChangeLog.txt" + SBO_REPO_TAR_SUFFIX = ".tar.gz" + SBO_REPO_TAG = "_SBo" + + PONCE_REPO = false + PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/" + PONCE_REPO_TXT = "SLACKBUILDS.TXT" + PONCE_REPO_CHGLOG_TXT = "ChangeLog.txt" + PONCE_REPO_TAG = "_SBo" + + GNOME_REPO = true + GNOME_REPO_URL = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" + GNOME_REPO_PKG_TXT = "PACKAGES.TXT" + GNOME_REPO_CHGLOG_TXT = "ChangeLog.txt" + + diff --git a/configs/slpkg.toml b/configs/slpkg.toml index f9e14dc2..8c50fb40 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -41,23 +41,23 @@ SPINNER_COLOR = "green" # SLACKBUILDS.ORG REPOSITORY CONFIGS. - SBO_REPO_PATH = "/var/lib/slpkg/repositories/sbo/" - SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/" - SBO_TXT = "SLACKBUILDS.TXT" - SBO_CHGLOG_TXT = "ChangeLog.txt" - SBO_TAR_SUFFIX = ".tar.gz" - SBO_REPO_TAG = "_SBo" + # SBO_REPO_PATH = "/var/lib/slpkg/repositories/sbo/" + # SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/" + # SBO_TXT = "SLACKBUILDS.TXT" + # SBO_CHGLOG_TXT = "ChangeLog.txt" + # SBO_TAR_SUFFIX = ".tar.gz" + # SBO_REPO_TAG = "_SBo" # PONCE REPOSITORY CONFIGS. # Set the 'PONCE_REPO = true' to switch to the ponce repository and # run 'slpkg update' to update the database if it is necessary. # Default is false. [true/false]. - PONCE_REPO = false - PONCE_REPO_PATH = "/var/lib/slpkg/repositories/ponce/" - PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/" - PONCE_TXT = "SLACKBUILDS.TXT" - PONCE_CHGLOG_TXT = "ChangeLog.txt" - PONCE_REPO_TAG = "_SBo" + # PONCE_REPO = false + # PONCE_REPO_PATH = "/var/lib/slpkg/repositories/ponce/" + # PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/" + # PONCE_TXT = "SLACKBUILDS.TXT" + # PONCE_CHGLOG_TXT = "ChangeLog.txt" + # PONCE_REPO_TAG = "_SBo" # Slackware command for install packages, instead, you can use 'installpkg'. INSTALLPKG = "upgradepkg --install-new" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index cef37cef..5f6803ec 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -21,8 +21,7 @@ class CheckUpdates(Configs): self.utils = Utilities() self.progress = ProgressBar() self.color = self.colour() - self.repositories = Repositories() - self.repos: dict = self.repositories.configs() + self.repos = Repositories() self.bold: str = self.color['bold'] self.green: str = self.color['green'] @@ -31,24 +30,27 @@ class CheckUpdates(Configs): self.endc: str = self.color['endc'] self.flag_binary: list = ['-B', '--binary'] - # Slackbuilds.org repository settings. - self.changelog_txt: str = self.sbo_chglog_txt - self.local_chg_txt = Path(self.sbo_repo_path, self.changelog_txt) - self.repo_chg_txt: str = f'{self.sbo_repo_url}{self.changelog_txt}' + self.local_chg_txt = None + self.repo_chg_txt = None - def check(self) -> bool: + def check(self) -> None: """ Checks the ChangeLogs and returns True or False. """ - local_date: int = 0 - # Ponce repository settings. if self.utils.is_option(self.flag_binary, self.flags): - pass + if self.repos.gnome_repo: + pass else: - if self.ponce_repo: - self.changelog_txt: str = self.ponce_chglog_txt - self.local_chg_txt = Path(self.ponce_repo_path, self.changelog_txt) - self.repo_chg_txt: str = f'{self.ponce_repo_url}{self.changelog_txt}' + if self.repos.ponce_repo: + self.local_chg_txt = Path(self.ponce_repo_path, self.repos.ponce_repo_chglog_txt) + self.repo_chg_txt: str = f'{self.repos.ponce_repo_url}{self.repos.ponce_repo_chglog_txt}' + self.compare_dates() + else: + self.local_chg_txt = Path(self.sbo_repo_path, self.repos.sbo_repo_chglog_txt) + self.repo_chg_txt: str = f'{self.repos.sbo_repo_url}{self.repos.sbo_repo_chglog_txt}' + self.compare_dates() + def compare_dates(self): + local_date: int = 0 try: http = urllib3.PoolManager() repo = http.request('GET', self.repo_chg_txt) @@ -70,7 +72,7 @@ class CheckUpdates(Configs): def updates(self) -> None: """ Starting multiprocessing download process. """ - message: str = f'Checking for news in the {self.changelog_txt} file...' + message: str = f'Checking for news in the {self.repo_chg_txt} file...' # Starting multiprocessing p1 = Process(target=self.view_message) diff --git a/slpkg/checks.py b/slpkg/checks.py index 10d5944d..304b0099 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -7,6 +7,7 @@ from slpkg.configs import Configs from slpkg.queries import SBoQueries from slpkg.blacklist import Blacklist from slpkg.utilities import Utilities +from slpkg.repositories import Repositories class Check(Configs): @@ -16,9 +17,10 @@ class Check(Configs): super(Configs, self).__init__() self.black = Blacklist() self.utils = Utilities() + self.repos = Repositories() self.repo_path = self.sbo_repo_path - if self.ponce_repo: + if self.repos.ponce_repo: self.repo_path = self.ponce_repo_path def exists_in_the_database(self, slackbuilds: list) -> None: diff --git a/slpkg/configs.py b/slpkg/configs.py index 8313697c..c47397c0 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -66,22 +66,24 @@ class Configs: # File suffix for list packages. file_list_suffix: str = '.pkgs' + sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore + ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore # SBo repository configs. - sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore - sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/' - sbo_txt: str = 'SLACKBUILDS.TXT' - sbo_chglog_txt: str = 'ChangeLog.txt' - sbo_tar_suffix: str = '.tar.gz' - sbo_repo_tag: str = '_SBo' + # sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore + # sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/' + # sbo_txt: str = 'SLACKBUILDS.TXT' + # sbo_chglog_txt: str = 'ChangeLog.txt' + # sbo_tar_suffix: str = '.tar.gz' + # sbo_repo_tag: str = '_SBo' # Ponce repo configs. - ponce_repo: bool = False - ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore - ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' - ponce_txt: str = 'SLACKBUILDS.TXT' - ponce_chglog_txt: str = 'ChangeLog.txt' - ponce_repo_tag: str = '_SBo' + # ponce_repo: bool = False + # ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore + # ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' + # ponce_txt: str = 'SLACKBUILDS.TXT' + # ponce_chglog_txt: str = 'ChangeLog.txt' + # ponce_repo_tag: str = '_SBo' # Slackware commands. installpkg: str = 'upgradepkg --install-new' @@ -146,7 +148,7 @@ class Configs: tmp_slpkg: str = config['TMP_SLPKG'] build_path: str = config['BUILD_PATH'] download_only_path: str = config['DOWNLOAD_ONLY_PATH'] - sbo_repo_path: str = config['SBO_REPO_PATH'] + # sbo_repo_path: str = config['SBO_REPO_PATH'] # Database name. database_name: str = config['DATABASE_NAME'] @@ -155,19 +157,19 @@ class Configs: ask_question: bool = config['ASK_QUESTION'] # SBo repository details. - sbo_repo_url: str = config['SBO_REPO_URL'] - sbo_txt: str = config['SBO_TXT'] - sbo_chglog_txt: str = config['SBO_CHGLOG_TXT'] - sbo_tar_suffix: str = config['SBO_TAR_SUFFIX'] - sbo_repo_tag: str = config['SBO_REPO_TAG'] + # sbo_repo_url: str = config['SBO_REPO_URL'] + # sbo_txt: str = config['SBO_TXT'] + # sbo_chglog_txt: str = config['SBO_CHGLOG_TXT'] + # sbo_tar_suffix: str = config['SBO_TAR_SUFFIX'] + # sbo_repo_tag: str = config['SBO_REPO_TAG'] # Ponce repo configs. - ponce_repo: bool = config['PONCE_REPO'] - ponce_repo_path: str = config['PONCE_REPO_PATH'] - ponce_repo_url: str = config['PONCE_REPO_URL'] - ponce_txt: str = config['PONCE_TXT'] - ponce_chglog_txt: str = config['PONCE_CHGLOG_TXT'] - ponce_repo_tag: str = config['PONCE_REPO_TAG'] + # ponce_repo: bool = config['PONCE_REPO'] + # ponce_repo_path: str = config['PONCE_REPO_PATH'] + # ponce_repo_url: str = config['PONCE_REPO_URL'] + # ponce_txt: str = config['PONCE_TXT'] + # ponce_chglog_txt: str = config['PONCE_CHGLOG_TXT'] + # ponce_repo_tag: str = config['PONCE_REPO_TAG'] # Slackware commands. installpkg: str = config['INSTALLPKG'] @@ -222,10 +224,6 @@ class Configs: f"'mv {etc_path}/{prog_name}.toml.new {etc_path}/{prog_name}.toml'.\n" f"or '{color['cyan']}slpkg_new-configs{color['endc']}' command.\n") - repo_tag: str = sbo_repo_tag - if ponce_repo: - repo_tag: str = ponce_repo_tag - # Creating the paths if not exists paths = [ tmp_slpkg, diff --git a/slpkg/install_data.py b/slpkg/install_data.py index ea3dcff6..3c3b790c 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -6,6 +6,7 @@ from pathlib import Path from slpkg.configs import Configs from slpkg.queries import SBoQueries from slpkg.utilities import Utilities +from slpkg.repositories import Repositories from slpkg.models.models import session as Session from slpkg.models.models import SBoTable, PonceTable, BinariesTable @@ -19,6 +20,8 @@ class CreateData(Configs): self.session = Session self.utils = Utilities() self.query = SBoQueries('') + self.repositories = Repositories() + self.repos: dict = self.repositories.configs() def install_sbo_table(self) -> None: """ Install the data for SBo repository. """ @@ -35,11 +38,11 @@ class CreateData(Configs): 'SLACKBUILD SHORT DESCRIPTION:' ] sbo_table = SBoTable - path = Path(self.sbo_repo_path, self.sbo_txt) + path = Path(self.sbo_repo_path, self.repos['SBO_REPO_TXT']) - if self.ponce_repo: + if self.repos['PONCE_REPO']: sbo_table = PonceTable - path = Path(self.ponce_repo_path, self.ponce_txt) + path = Path(self.ponce_repo_path, self.repos['PONCE_REPO_TXT']) sbo_file: list = self.utils.read_file(path) @@ -68,7 +71,7 @@ class CreateData(Configs): self.session.commit() - def install_gnome_data(self, repo_txt: str) -> None: + def install_gnome_data(self) -> None: """ Install the data for SBo repository. """ repo: str = 'gnome' pkg_tag = [ @@ -79,7 +82,7 @@ class CreateData(Configs): 'PACKAGE SIZE (uncompressed):', 'PACKAGE DESCRIPTION:', ] - path = Path(self.lib_path, 'repositories', repo, repo_txt) + path = Path(self.lib_path, 'repositories', repo, self.repos['GNOME_REPO_PKG_TXT']) pkg_txt: list = self.utils.read_file(path) diff --git a/slpkg/main.py b/slpkg/main.py index a3d20d21..1ecb92b0 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -21,6 +21,7 @@ from slpkg.slackbuild import Slackbuilds from slpkg.views.views import ViewMessage from slpkg.form_configs import FormConfigs from slpkg.views.help_commands import Help +from slpkg.repositories import Repositories from slpkg.check_updates import CheckUpdates from slpkg.find_installed import FindInstalled from slpkg.views.view_package import ViewPackage @@ -42,13 +43,15 @@ class Argparse(Configs): self.check = Check() self.form_configs = FormConfigs() self.color = self.colour() + self.repos = Repositories() self.bold: str = self.color['bold'] self.red: str = self.color['red'] self.endc: str = self.color['endc'] self.bred: str = f'{self.bold}{self.red}' - self.file_pattern: str = f'*{self.repo_tag}' + self.file_pattern: str = f'*{self.repos.repo_tag}' + if self.file_pattern_conf: self.file_pattern = self.file_pattern_conf @@ -481,7 +484,7 @@ class Argparse(Configs): def check_updates(self) -> None: if len(self.args) == 1: self.check.is_empty_database() - check = CheckUpdates() + check = CheckUpdates(self.flags) check.updates() raise SystemExit() self.usage.help_short(1) diff --git a/slpkg/queries.py b/slpkg/queries.py index 05cb2409..faf8b40c 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -5,6 +5,7 @@ from typing import Union from slpkg.configs import Configs from slpkg.blacklist import Blacklist +from slpkg.repositories import Repositories from slpkg.models.models import session as Session from slpkg.models.models import SBoTable, PonceTable @@ -16,6 +17,7 @@ class SBoQueries(Configs): super(Configs, self).__init__() self.name: str = name self.session = Session + self.repos = Repositories() self.black = Blacklist() if self.name in self.black.packages(): @@ -23,7 +25,7 @@ class SBoQueries(Configs): # Switch between sbo and ponce repository. self.sbo_table = SBoTable - if self.ponce_repo: + if self.repos.ponce_repo: self.sbo_table = PonceTable def sbos(self) -> list: diff --git a/slpkg/repositories.py b/slpkg/repositories.py index e01f65ca..62482cc1 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -23,17 +23,55 @@ class Repositories(Configs): self.bred: str = f'{self.bold}{self.red}' self.repositories_file_toml = Path(self.etc_path, 'repositories.toml') - def configs(self) -> dict: + self.sbo_repo_url: str = "https://slackbuilds.org/slackbuilds/15.0/" + self.sbo_repo_txt: str = "SLACKBUILDS.TXT" + self.sbo_repo_chglog_txt: str = "ChangeLog.txt" + self.sbo_repo_tar_suffix: str = ".tar.gz" + self.sbo_repo_tag: str = "_SBo" + + self.ponce_repo: bool = False + self.ponce_repo_url: str = "https://cgit.ponce.cc/slackbuilds/plain/" + self.ponce_repo_txt: str = "SLACKBUILDS.TXT" + self.ponce_repo_chglog_txt: str = "ChangeLog.txt" + self.ponce_repo_tag: str = "_SBo" + + self.gnome_repo: bool = True + self.gnome_repo_url: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" + self.gnome_repo_pkg_txt: str = "PACKAGES.TXT" + self.gnome_repo_chglog_pkg_txt: str = "ChangeLog.txt" + + self.repo_tag: str = self.sbo_repo_tag + + def configs(self) -> None: """ Reads the repositories file. """ if self.repositories_file_toml.is_file(): try: with open(self.repositories_file_toml, 'rb') as repo: - return tomli.load(repo)['REPOSITORIES'] + repos = tomli.load(repo)['REPOSITORIES'] except (tomli.TOMLDecodeError, KeyError) as error: raise SystemExit(f"\n{self.prog_name} {self.bred}Error{self.endc}: {error}: in the configuration file " f"'{self.repositories_file_toml}'.\n" f"\nIf you have upgraded the '{self.prog_name}' probably you need to run:\n" f"'mv {self.repositories_file_toml}.new {self.repositories_file_toml}'.\n" f"or '{self.cyan}slpkg_new-configs{self.endc}' command.\n") - return [] + + self.sbo_repo_url: str = repos['SBO_REPO_URL'] + self.sbo_repo_txt: str = repos['SBO_REPO_TXT'] + self.sbo_repo_chglog_txt: str = repos['SBO_REPO_CHGLOG_TXT'] + self.sbo_repo_tar_suffix: str = repos['SBO_REPO_TAR_SUFFIX'] + self.sbo_repo_tag: str = repos['SBO_REPO_TAG'] + + self.ponce_repo: bool = repos['PONCE_REPO'] + self.ponce_repo_url: str = repos['PONCE_REPO_URL'] + self.ponce_repo_txt: str = repos['PONCE_REPO_TXT'] + self.ponce_repo_chglog_txt: str = repos['PONCE_REPO_CHGLOG_TXT'] + self.ponce_repo_tag: str = repos['PONCE_REPO_TAG'] + + self.gnome_repo: bool = repos['GNOME_REPO'] + self.gnome_repo_url: str = repos['GNOME_REPO_URL'] + self.gnome_repo_pkg_txt: str = repos['GNOME_REPO_PKG_TXT'] + self.gnome_repo_chglog_pkg_txt: str = repos['GNOME_REPO_CHGLOG_TXT'] + + if self.ponce_repo: + self.repo_tag: str = self.ponce_repo_tag diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 4d332f97..ee1b546b 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -27,8 +27,7 @@ class UpdateRepository(Configs): self.session = Session self.view = ViewMessage(self.flags) - self.repositories = Repositories() - self.repos: dict = self.repositories.configs() + self.repos = Repositories() self.progress = ProgressBar() self.utils = Utilities() self.color = self.colour() @@ -60,17 +59,17 @@ class UpdateRepository(Configs): def binary_repositories(self): """ Update the binary repositories. """ - if self.repos['GNOME_REPO']: + if self.repos.gnome_repo: print('Gnome repository -> Updating the packages list...\n') repo: str = 'gnome' self.make_dirs(repo) - self.urls.append(f"{self.repos['GNOME_REPO_URL']}{self.repos['GNOME_REPO_PKG_TXT']}") - self.urls.append(f"{self.repos['GNOME_REPO_URL']}{self.repos['GNOME_REPO_CHGLOG_TXT']}") + self.urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_pkg_txt}') + self.urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_chglog_pkg_txt}') repo_path = Path(self.lib_path, 'repositories', repo) - self.delete_file(f"{self.lib_path}/repositories/{repo}", self.repos['GNOME_REPO_PKG_TXT']) - self.delete_file(f"{self.lib_path}/repositories/{repo}", self.repos['GNOME_REPO_CHGLOG_TXT']) + self.delete_file(f'{self.lib_path}/repositories/{repo}', self.repos.gnome_repo_pkg_txt) + self.delete_file(f'{self.lib_path}/repositories/{repo}', self.repos.gnome_repo_chglog_pkg_txt) down = Downloader(repo_path, self.urls, self.flags) down.download() @@ -78,38 +77,39 @@ class UpdateRepository(Configs): self.delete_binaries_data(repo) - self.data.install_gnome_data(self.repos['GNOME_REPO_PKG_TXT']) + self.data.install_gnome_data() def slackbuild_repositories(self): """ Update the slackbuild repositories. """ - if self.ponce_repo: + if self.repos.ponce_repo: if not self.utils.is_option(self.flag_generate, self.flags): print('Ponce repository -> Updating the packages list...\n') print(f"Downloading the '{self.green}ponce{self.endc}' repository, please wait...\n") - self.delete_file(self.ponce_repo_path, self.ponce_chglog_txt) - lftp_command: str = f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} {self.ponce_repo_path}' + self.delete_file(self.ponce_repo_path, self.repos .ponce_repo_txt) + lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.ponce_repo_url} ' + f'{self.ponce_repo_path}') self.utils.process(lftp_command) # Remove the SLACKBUILDS.TXT file before generating the new one. - sbo_file_txt = Path(self.ponce_repo_path, self.ponce_txt) + sbo_file_txt = Path(self.ponce_repo_path, self.repos.ponce_repo_txt) if sbo_file_txt.is_file(): sbo_file_txt.unlink() # Generating the ponce SLACKBUILDS.TXT file. - print(f'Generating the {self.ponce_txt} file... ', end='', flush=True) + print(f'Generating the {self.repos.ponce_repo_txt} file... ', end='', flush=True) os.chdir(self.ponce_repo_path) - gen_command: str = f'./gen_sbo_txt.sh > {self.ponce_txt}' + gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_txt}' self.utils.process(gen_command) print('\n') else: print('SBo repository -> Updating the packages list...\n') - self.delete_file(self.sbo_repo_path, self.sbo_txt) - self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt) + self.delete_file(self.sbo_repo_path, self.repos.sbo_repo_txt) + self.delete_file(self.sbo_repo_path, self.repos.sbo_repo_chglog_txt) print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n") - lftp_command: str = f'lftp {self.lftp_mirror_options} {self.sbo_repo_url} {self.sbo_repo_path}' + lftp_command: str = f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_url} {self.sbo_repo_path}' self.utils.process(lftp_command) self.delete_sbo_data() @@ -170,7 +170,7 @@ class UpdateRepository(Configs): def delete_sbo_data(self) -> None: """ Delete all the data from a table of the database. """ - if self.ponce_repo: + if self.repos.ponce_repo: self.session.query(PonceTable).delete() else: self.session.query(SBoTable).delete() diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 7fe4b58f..421c2f01 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -13,6 +13,7 @@ from distutils.version import LooseVersion from slpkg.configs import Configs from slpkg.queries import SBoQueries from slpkg.blacklist import Blacklist +from slpkg.repositories import Repositories class Utilities: @@ -22,6 +23,7 @@ class Utilities: self.colors = self.configs.colour self.color = self.colors() self.black = Blacklist() + self.repos = Repositories() self.bold: str = self.color['bold'] self.yellow: str = self.color['yellow'] @@ -94,7 +96,7 @@ class Utilities: name: str = '-'.join(package.split('-')[:-3]) version: str = ''.join(package[len(name):].split('-')[:-2]) arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1]) - build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.configs.repo_tag, '') + build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.repos.repo_tag, '') tag: str = ''.join(package[len(name + version + arch + build) + 4:].split('-')) return [name, version, arch, build, tag] diff --git a/slpkg/views/ascii.py b/slpkg/views/ascii.py index 40d2bdcc..6c1a81d7 100644 --- a/slpkg/views/ascii.py +++ b/slpkg/views/ascii.py @@ -4,6 +4,7 @@ import shutil from slpkg.configs import Configs +from slpkg.repositories import Repositories class Ascii(Configs): @@ -11,6 +12,7 @@ class Ascii(Configs): def __init__(self): super(Configs, self).__init__() self.color = self.colour() + self.repos = Repositories() self.columns, self.rows = shutil.get_terminal_size() self.vertical_line: str = '|' @@ -50,7 +52,7 @@ class Ascii(Configs): self.bred: str = f'{self.bold}{self.red}' self.repo: str = 'sbo' - if self.ponce_repo: + if self.repos.ponce_repo: self.repo: str = 'ponce' def draw_package_title_box(self, message: str, title: str) -> None: diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 525ca588..a291ccdb 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -9,6 +9,7 @@ from slpkg.views.ascii import Ascii from slpkg.queries import SBoQueries from slpkg.utilities import Utilities from slpkg.dialog_box import DialogBox +from slpkg.repositories import Repositories from slpkg.models.models import LogsDependencies from slpkg.models.models import session as Session @@ -25,6 +26,7 @@ class ViewMessage(Configs): self.dialogbox = DialogBox() self.ascii = Ascii() self.color = self.colour() + self.repos = Repositories() self.yellow: str = self.color['yellow'] self.cyan: str = self.color['cyan'] @@ -37,7 +39,9 @@ class ViewMessage(Configs): self.flag_resolve_off: list = ['-o', '--resolve-off'] self.flag_reinstall: list = ['-r', '--reinstall'] self.flag_yes: list = ['-y', '--yes'] - self.file_pattern: str = f'*{self.repo_tag}' + + self.file_pattern: str = f'*{self.repos.repo_tag}' + self.all_installed: list = list(self.utils.all_installed_names(self.file_pattern)) def view_packages(self, package: str, version: str, mode: str) -> None: