From fcf9b926391b7a3d2396f6508eefca2feb7f4e58 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:07:07 +0200 Subject: [PATCH 01/39] Remove message --- slpkg/upgrade.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 48a8192b..ec5e7101 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -19,8 +19,6 @@ class Upgrade: def packages(self): """ Compares version of packages and returns the maximum. """ - print("Do not forget to run 'slpkg update' before.\n") - repo_packages = SBoQueries('').names() black = Blacklist().get() From a22e7d1d0817d03b965125db7deb3c09402440c5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:10:51 +0200 Subject: [PATCH 02/39] Updated question --- slpkg/views/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index a2a75024..ae8ef184 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -184,7 +184,7 @@ class ViewMessage: def question(self): """ Manage to proceed. """ if '--yes' not in self.flags: - answer = input('\nDo you want to continue [y/N]: ') + answer = input('\nDo you want to continue (y/N)?: ') if answer not in ['Y', 'y']: raise SystemExit() print() From 507b41a754050885b20c3ad540f89b4f6aad3a34 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:13:06 +0200 Subject: [PATCH 03/39] Updated for Feature: only update .txt files if they have been modified #153 --- slpkg/check_updates.py | 10 +++++++--- slpkg/update_repository.py | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 2ee72212..0038bb02 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -14,7 +14,8 @@ class CheckUpdates: def __init__(self): self.configs = Configs - def updates(self): + def check(self): + print('Checking for news in the Changelog.txt file...') local_date = 0 local_chg_txt = (f'{self.configs.sbo_repo_path}/' f'{self.configs.chglog_txt}') @@ -28,7 +29,10 @@ class CheckUpdates: repo_date = int(repo.headers['Content-Length']) - if repo_date != local_date: - print('\nThere are new updates available.\n') + return repo_date != local_date + + def updates(self): + if self.check(): + print('\nThere are new updates available!\n') else: print('\nNo updated packages since the last check.\n') diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 28d7f147..7eb04a8f 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -8,6 +8,8 @@ from os import path from slpkg.downloader import Wget from slpkg.configs import Configs +from slpkg.check_updates import CheckUpdates +from slpkg.views.views import ViewMessage from slpkg.create_data import CreateData from slpkg.models.models import SBoTable from slpkg.models.models import session as Session @@ -21,6 +23,16 @@ class UpdateRepository: self.session = Session def sbo(self): + view = ViewMessage('') + check_updates = CheckUpdates() + + if not check_updates.check(): + print('\nNo changes in ChangeLog.txt between your last update and now.') + else: + print('\nThere are new updates available!') + + view.question() + print('Updating the package list...\n') self.delete_file(self.configs.sbo_repo_path, self.configs.sbo_txt) self.delete_file(self.configs.sbo_repo_path, self.configs.chglog_txt) From ae60c95b705cbbf88d29c5d1157d659c44fdcfa8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:14:07 +0200 Subject: [PATCH 04/39] Updated code style --- slpkg/update_repository.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 7eb04a8f..a925ae9e 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -8,10 +8,10 @@ from os import path from slpkg.downloader import Wget from slpkg.configs import Configs -from slpkg.check_updates import CheckUpdates -from slpkg.views.views import ViewMessage from slpkg.create_data import CreateData from slpkg.models.models import SBoTable +from slpkg.views.views import ViewMessage +from slpkg.check_updates import CheckUpdates from slpkg.models.models import session as Session From 03d8a9af5a9e7a385d15025ac8b4922dbdf19805 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:16:45 +0200 Subject: [PATCH 05/39] Updated the changelog file for version 4.3.9 --- ChangeLog.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d9b07765..6bed786f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,7 @@ -4.3.8 - 17/12/2022 +4.3.9 - 20/12/2022 +Added: +- Feature to check the ChangeLog.txt file before update #153 + BugFixed: - View installed version - slpkg issue : permission denied #152 From 03f87d15841baaa1542031f09aa5cae29f6e927c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:37:03 +0200 Subject: [PATCH 06/39] Updated message --- slpkg/find_installed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index 7ca98fda..a66a496a 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -18,7 +18,7 @@ class FindInstalled: def find(self, packages: list): matching = [] - print(f'The list below shows the packages ' + print(f'The list below shows the installed packages ' f'that contains \'{", ".join([p for p in packages])}\' files:\n') for pkg in packages: From a12fc7b29a61358332f2a2c0e11e3b53b019532a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 20 Dec 2022 22:39:53 +0200 Subject: [PATCH 07/39] Updated message --- slpkg/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/search.py b/slpkg/search.py index 74093cf0..95c842b4 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -20,8 +20,8 @@ class SearchPackage: names = SBoQueries('').names() - print(f'The list below shows the packages ' - f'that contains \'{", ".join([p for p in packages])}\' files:\n') + print(f'The list below shows the repo ' + f'packages that contains \'{", ".join([p for p in packages])}\' files:\n') for name in names: for package in packages: From e82d860ad6fa7b1972c7831df56318e885849d78 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 08:42:32 +0200 Subject: [PATCH 08/39] Updated for version 4.3.9 Signed-off-by: Dimitris Zlatanidis --- README.rst | 4 ++-- setup.cfg | 2 +- slpkg/views/version.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 18d83c25..e84cdac9 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Date: Wed, 21 Dec 2022 08:52:54 +0200 Subject: [PATCH 09/39] Fixed error for the config file Signed-off-by: Dimitris Zlatanidis --- slpkg/configs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/slpkg/configs.py b/slpkg/configs.py index 74dae696..f450b34d 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -90,8 +90,9 @@ class Configs: # Wget options wget_options: str = config['wget_options'] - except KeyError as err: - raise KeyError(f"ERROR: {err} in the configurations.") + except KeyError: + print("Error: check the configuration file " + "in the '/etc/slpkg/' folder.\n") # Creating the paths if not exists paths = [tmp_slpkg, From 59f3849d1789c1569b09ce1e5f0a0bc1cd41be0e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 11:19:47 +0200 Subject: [PATCH 10/39] Added some comments --- slpkg/blacklist.py | 1 + slpkg/check_updates.py | 1 + slpkg/checksum.py | 2 ++ slpkg/clean_logs.py | 1 + slpkg/create_data.py | 2 ++ slpkg/dependencies.py | 1 + slpkg/download_only.py | 1 + slpkg/downloader.py | 1 + slpkg/find_installed.py | 2 ++ slpkg/queries.py | 11 +++++++++++ slpkg/search.py | 1 + slpkg/update_repository.py | 3 +++ slpkg/views/cli_menu.py | 2 ++ slpkg/views/version.py | 1 + 14 files changed, 30 insertions(+) diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 20586e07..3bb5f1e5 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -15,6 +15,7 @@ class Blacklist: self.configs = Configs def get(self): + """ Reads the blacklist file. """ file = f'{self.configs.etc_path}/blacklist.toml' if os.path.isfile(file): with open(file, 'rb') as black: diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 0038bb02..26e315de 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -15,6 +15,7 @@ class CheckUpdates: self.configs = Configs def check(self): + """ Checks the ChangeLogs and returns True or False. """ print('Checking for news in the Changelog.txt file...') local_date = 0 local_chg_txt = (f'{self.configs.sbo_repo_path}/' diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 5bd043b1..f89919bb 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -14,6 +14,7 @@ class Md5sum: self.flags = flags def check(self, path: str, source: str, checksum: str, name: str): + """ Checksum the source. """ filename = f'{path}/{source.split("/")[-1]}' md5 = self.read_file(filename) @@ -30,5 +31,6 @@ class Md5sum: @staticmethod def read_file(filename: str): + """ Reads the text file. """ with open(filename, 'rb') as f: return f.read() diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py index c5cb2c29..ee2eec8d 100644 --- a/slpkg/clean_logs.py +++ b/slpkg/clean_logs.py @@ -15,6 +15,7 @@ class CleanLogsDependencies: self.session = Session def clean(self): + """ Deletes the log table from the database. """ dependencies = self.session.query( LogsDependencies.name, LogsDependencies.requires).all() diff --git a/slpkg/create_data.py b/slpkg/create_data.py index 2f151554..0bdeb9f9 100644 --- a/slpkg/create_data.py +++ b/slpkg/create_data.py @@ -15,6 +15,7 @@ class CreateData: self.session = Session def insert_sbo_table(self): + """ Install the data. """ sbo_tags = [ 'SLACKBUILD NAME:', 'SLACKBUILD LOCATION:', @@ -57,5 +58,6 @@ class CreateData: @staticmethod def read_file(file: str): + """ Reades the text file. """ with open(file, 'r', encoding='utf-8') as f: return f.readlines() diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py index e19c7ae7..8f57cd22 100644 --- a/slpkg/dependencies.py +++ b/slpkg/dependencies.py @@ -13,6 +13,7 @@ class Requires: self.name = name def resolve(self) -> list: + """ Resolve the dependencies. """ requires = SBoQueries(self.name).requires() for req in requires: diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 17a25b09..77295bfb 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -18,6 +18,7 @@ class Download: self.session = Session def packages(self, slackbuilds: list): + """ Download the package only. """ view = ViewMessage(self.flags) view.download_packages(slackbuilds) view.question() diff --git a/slpkg/downloader.py b/slpkg/downloader.py index e1be310d..fc112fa1 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -14,5 +14,6 @@ class Wget: self.wget_options: str = Configs.wget_options def download(self, path: str, url: str): + """ Wget downloader. """ subprocess.call(f'wget {self.wget_options} --directory-prefix={path}' f' {url}', shell=True) diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index a66a496a..7064c6b6 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -16,6 +16,7 @@ class FindInstalled: self.color = colors() def find(self, packages: list): + """ Find the packages. """ matching = [] print(f'The list below shows the installed packages ' @@ -28,6 +29,7 @@ class FindInstalled: self.matched(matching) def matched(self, matching: list): + """ Print the matched packages. """ if matching: for package in matching: print(f'{self.color["cyan"]}{package}{self.color["endc"]}') diff --git a/slpkg/queries.py b/slpkg/queries.py index 101ee59e..3bec26ba 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -21,9 +21,11 @@ class SBoQueries: self.name = '' def names(self): + """ Returns all the slackbuilds. """ return list(self._names_grabbing()) def slackbuild(self): + """ Returns a slackbuild. """ sbo = self.session.query( SBoTable.name).filter(SBoTable.name == self.name).first() @@ -32,6 +34,7 @@ class SBoQueries: return '' def location(self): + """ Returns the category of a slackbuild. """ location = self.session.query( SBoTable.location).filter(SBoTable.name == self.name).first() @@ -40,6 +43,7 @@ class SBoQueries: return '' def sources(self): + """ Returns the source of a slackbuild. """ source, source64 = self.session.query( SBoTable.download, SBoTable.download64).filter( SBoTable.name == self.name).first() @@ -49,6 +53,7 @@ class SBoQueries: return '' def requires(self): + """ Returns the requirements of a slackbuild. """ requires = self.session.query( SBoTable.requires).filter( SBoTable.name == self.name).first() @@ -62,6 +67,7 @@ class SBoQueries: return '' def version(self): + """ Returns the version of a slackbuild. """ version = self.session.query( SBoTable.version).filter( SBoTable.name == self.name).first() @@ -71,6 +77,7 @@ class SBoQueries: return '' def checksum(self): + """ Returns the source checkcum. """ md5sum, md5sum64, = [], [] mds5, md5s64 = self.session.query( SBoTable.md5sum, SBoTable.md5sum64).filter( @@ -86,6 +93,7 @@ class SBoQueries: return '' def description(self): + """ Returns the slackbuild description. """ desc = self.session.query( SBoTable.short_description).filter( SBoTable.name == self.name).first() @@ -95,6 +103,7 @@ class SBoQueries: return '' def files(self): + """ Returns the files of a slackbuild. """ files = self.session.query( SBoTable.files).filter( SBoTable.name == self.name).first() @@ -104,11 +113,13 @@ class SBoQueries: return '' def _chose_arch(self, arch, arch64): + """ Choosing the right arch. """ if self.configs.os_arch == 'x86_64' and arch64: return arch64 return arch def _names_grabbing(self): + """ Generate and returns all the slackbuilds. """ names = self.session.query(SBoTable.name).all() for n in names: yield n[0] diff --git a/slpkg/search.py b/slpkg/search.py index 95c842b4..f3767dcc 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -13,6 +13,7 @@ class SearchPackage: self.colors = Configs.colour def package(self, packages): + """ Searching and print the matched slackbuilds. """ color = self.colors() cyan = color['cyan'] endc = color['endc'] diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index a925ae9e..d1042548 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -23,6 +23,7 @@ class UpdateRepository: self.session = Session def sbo(self): + """ Updated the sbo repository. """ view = ViewMessage('') check_updates = CheckUpdates() @@ -50,10 +51,12 @@ class UpdateRepository: @staticmethod def delete_file(folder: str, txt_file: str): + """ Delete the file. """ file = f'{folder}/{txt_file}' if path.exists(file): os.remove(file) def delete_sbo_data(self): + """ Delete the table from the database. """ self.session.query(SBoTable).delete() self.session.commit() diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 445a7367..77a5121b 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -18,6 +18,7 @@ class Usage: self.endc = color['endc'] def help_short(self): + """ Prints the short menu. """ args = ( f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n' @@ -30,6 +31,7 @@ class Usage: raise SystemExit() def help(self, status: int): + """ Prints the main menu. """ args = [ f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n', f'{self.bold}DESCRIPTION:{self.endc}', diff --git a/slpkg/views/version.py b/slpkg/views/version.py index 53196f12..5610a0eb 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -13,6 +13,7 @@ class Version: self.homepage: str = 'https://dslackw.gitlab.io/slpkg' def view(self): + """ Prints the version. """ print(f'Version: {self.version}\n' f'Author: {self.author}\n' f'License: {self.license}\n' From 95922fb43e6187377d231a5bdbcbef283645502a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 20:44:56 +0200 Subject: [PATCH 11/39] Added dependees --- ChangeLog.txt | 1 + slpkg/views/view_package.py | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 6bed786f..c97602de 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ 4.3.9 - 20/12/2022 Added: - Feature to check the ChangeLog.txt file before update #153 +- Dependees in the view command BugFixed: - View installed version diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index b9b1f2bb..c8abe9b3 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- +import sys import urllib3 from slpkg.configs import Configs @@ -20,7 +21,6 @@ class ViewPackage: def package(self, packages): """ View the packages from the repository. """ - http = urllib3.PoolManager() color = self.colors() green = color['green'] blue = color['blue'] @@ -29,6 +29,7 @@ class ViewPackage: red = color['red'] endc = color['endc'] + print(end='\rCollecting the data... ') for package in packages: info = self.session.query( SBoTable.name, @@ -43,11 +44,9 @@ class ViewPackage: SBoTable.location ).filter(SBoTable.name == package).first() - readme = http.request( - 'GET', f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/README') + readme = self.http_request(f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/README') - info_file = http.request( - 'GET', f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info') + info_file = self.http_request(f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info') maintainer, email, homepage = '', '', '' for line in info_file.data.decode().splitlines(): @@ -60,11 +59,13 @@ class ViewPackage: deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()])) - print(f'Name: {green}{info[0]}{endc}\n' + print(f'\n\nName: {green}{info[0]}{endc}\n' f'Version: {green}{info[1]}{endc}\n' f'Requires: {green}{deps}{endc}\n' + f'Dependees: {green}{" ".join(list(self.dependees(package)))}{endc}\n' f'Homepage: {blue}{homepage}{endc}\n' - f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{self.configs.sbo_tar_suffix}{endc}\n' + f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}' + f'{self.configs.sbo_tar_suffix}{endc}\n' f'Download sources: {blue}{info[3]}{endc}\n' f'Download_x86_64 sources: {blue}{info[4]}{endc}\n' f'Md5sum: {yellow}{info[5]}{endc}\n' @@ -77,3 +78,18 @@ class ViewPackage: f'Maintainer: {yellow}{maintainer}{endc}\n' f'Email: {yellow}{email}{endc}\n' f'\nREADME: {cyan}{readme.data.decode()}{endc}') + + @staticmethod + def dependees(name): + """ Collecting the dependees. """ + sbos = SBoQueries(name).names() + for sbo in sbos: + requires = SBoQueries(sbo).requires() + if name in requires: + yield sbo + + @staticmethod + def http_request(link): + """ Http get request. """ + http = urllib3.PoolManager() + return http.request('GET', link) From c5a9221f53e2b843e2167ff8bf6fcd395e75b910 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 20:47:37 +0200 Subject: [PATCH 12/39] Updated print --- slpkg/check_updates.py | 6 +++--- slpkg/update_repository.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 26e315de..8dd62b46 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -16,7 +16,7 @@ class CheckUpdates: def check(self): """ Checks the ChangeLogs and returns True or False. """ - print('Checking for news in the Changelog.txt file...') + print(end='\rChecking for news in the Changelog.txt file... ') local_date = 0 local_chg_txt = (f'{self.configs.sbo_repo_path}/' f'{self.configs.chglog_txt}') @@ -34,6 +34,6 @@ class CheckUpdates: def updates(self): if self.check(): - print('\nThere are new updates available!\n') + print('\n\nThere are new updates available!\n') else: - print('\nNo updated packages since the last check.\n') + print('\n\nNo updated packages since the last check.\n') diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index d1042548..80de90de 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -28,9 +28,9 @@ class UpdateRepository: check_updates = CheckUpdates() if not check_updates.check(): - print('\nNo changes in ChangeLog.txt between your last update and now.') + print('\n\nNo changes in ChangeLog.txt between your last update and now.') else: - print('\nThere are new updates available!') + print('\n\nThere are new updates available!') view.question() From 42fb6bf7c5d7ea84c3eb3019607a368dd39328f5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 21:23:54 +0200 Subject: [PATCH 13/39] Added flag --dependees --- ChangeLog.txt | 1 + README.rst | 1 + man/slpkg.1 | 12 +++++++++--- slpkg/main.py | 13 +++++++++---- slpkg/views/cli_menu.py | 5 +++-- slpkg/views/view_package.py | 31 ++++++++++++++++++++----------- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c97602de..30e57cce 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,7 @@ Added: - Feature to check the ChangeLog.txt file before update #153 - Dependees in the view command +- Flag --dependees BugFixed: - View installed version diff --git a/README.rst b/README.rst index e84cdac9..173ac233 100644 --- a/README.rst +++ b/README.rst @@ -67,6 +67,7 @@ Usage --resolve-off Turns off dependency resolving. --reinstall Upgrade packages of the same version. --skip-installed Skip installed packages. + --dependees Show which packages depend. -h, --help Show this message and exit. -v, --version Print version and exit. diff --git a/man/slpkg.1 b/man/slpkg.1 index 23020b8d..67236ceb 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -1,10 +1,10 @@ -.TH slpkg 1 "Orestiada, Greece" "slpkg 4.3.1" dslackw +.TH slpkg 1 "Orestiada, Greece" "slpkg 4.3.9" dslackw .SH NAME .P slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .P -slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] --yes --jobs --resolve-off --reinstall --skip-installed +slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] --yes --jobs --resolve-off --reinstall --skip-installed, --dependees .SH DESCRIPTION .P Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. @@ -98,10 +98,16 @@ Use this option if you want to upgrade all packages even if the same version is This a helpful option if you want to avoid building and reinstalling packages. Note: This option affects only the dependencies. .RE +.RE +.P +--dependees +.RS +This flag works only with the -w, view command to show which packages depend. +.RE .P -h | --help .RS -Show help informatio and exit. +Show help information and exit. .RE .P -v | --version diff --git a/slpkg/main.py b/slpkg/main.py index 607d5867..b3461081 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -39,7 +39,13 @@ class Argparse: '--jobs', '--resolve-off', '--reinstall', - '--skip-installed'] + '--skip-installed', + '--dependees'] + + for opt in self.args: + if opt.startswith('--'): + if opt not in self.options: + raise SystemExit(f"\nError: flag '{opt}' does not exist.\n") for option in self.options: if option in self.args: @@ -127,7 +133,6 @@ class Argparse: self.check.exists(packages) download = Download(self.flags) download.packages(packages) - raise SystemExit() self.usage.help(1) @@ -147,13 +152,13 @@ class Argparse: self.usage.help(1) def view(self): - if len(self.args) >= 2 and not self.flags: + if len(self.args) >= 2: packages = list(set(self.args[1:])) self.check.database() self.check.exists(packages) - view = ViewPackage() + view = ViewPackage(self.flags) view.package(packages) raise SystemExit() self.usage.help(1) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 77a5121b..6acd6ec9 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -21,7 +21,7 @@ class Usage: """ Prints the short menu. """ args = ( f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' - f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n' + f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed, --dependees]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] \n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-r, remove, -f, find, -w, view, -s, search] \n' @@ -54,7 +54,8 @@ class Usage: f' {self.yellow}--jobs{self.endc} Set it for multicore systems.', f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.', f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.', - f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n', + f' {self.yellow}--skip-installed{self.endc} Skip installed packages.', + f' {self.yellow}--dependees{self.endc} Show which packages depend.\n', ' -h, --help Show this message and exit.', ' -v, --version Print version and exit.\n', 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index c8abe9b3..12a91636 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -14,7 +14,8 @@ from slpkg.models.models import session as Session class ViewPackage: """ View the repository packages. """ - def __init__(self): + def __init__(self, flags): + self.flags = flags self.session = Session self.configs = Configs self.colors = self.configs.colour @@ -29,8 +30,10 @@ class ViewPackage: red = color['red'] endc = color['endc'] - print(end='\rCollecting the data... ') for package in packages: + + dependees = " ".join(list(self.dependees(package))) + info = self.session.query( SBoTable.name, SBoTable.version, @@ -59,10 +62,10 @@ class ViewPackage: deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()])) - print(f'\n\nName: {green}{info[0]}{endc}\n' + print(f'Name: {green}{info[0]}{endc}\n' f'Version: {green}{info[1]}{endc}\n' f'Requires: {green}{deps}{endc}\n' - f'Dependees: {green}{" ".join(list(self.dependees(package)))}{endc}\n' + f'Dependees: {green}{dependees}{endc}\n' f'Homepage: {blue}{homepage}{endc}\n' f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}' f'{self.configs.sbo_tar_suffix}{endc}\n' @@ -79,14 +82,20 @@ class ViewPackage: f'Email: {yellow}{email}{endc}\n' f'\nREADME: {cyan}{readme.data.decode()}{endc}') - @staticmethod - def dependees(name): + def dependees(self, name): """ Collecting the dependees. """ - sbos = SBoQueries(name).names() - for sbo in sbos: - requires = SBoQueries(sbo).requires() - if name in requires: - yield sbo + if '--dependees' in self.flags: + print(end='\rCollecting the data... ') + sbos = SBoQueries(name).names() + for sbo in sbos: + requires = SBoQueries(sbo).requires() + if name in requires: + version = SBoQueries(sbo).version() + yield f'{sbo} ({version})' + else: + return '' + + print('\n') @staticmethod def http_request(link): From 22ead694de047df4c1da39d1ddecc43cee896347 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 21:34:17 +0200 Subject: [PATCH 14/39] Fixed for flag --help --- slpkg/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index b3461081..e35e3db5 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -42,15 +42,17 @@ class Argparse: '--skip-installed', '--dependees'] + # Check for correct flag for opt in self.args: if opt.startswith('--'): - if opt not in self.options: + if opt not in self.options and opt != '--help': raise SystemExit(f"\nError: flag '{opt}' does not exist.\n") - for option in self.options: - if option in self.args: - self.args.remove(option) - self.flags.append(option) + # Remove flags from args + for opt in self.options: + if opt in self.args: + self.args.remove(opt) + self.flags.append(opt) def help(self): if len(self.args) == 1 and not self.flags: From 777694d063e8cc3618a74410938b3e0d95ff98a8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 21:51:11 +0200 Subject: [PATCH 15/39] Fixed short menu --- slpkg/views/cli_menu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 6acd6ec9..9070e8a4 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -21,7 +21,8 @@ class Usage: """ Prints the short menu. """ args = ( f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' - f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed, --dependees]\n' + f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, \n' + ' --skip-installed, --dependees]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] \n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-r, remove, -f, find, -w, view, -s, search] \n' From 803cefe2230bef5d2ec6fd98206c424ec8dda5e1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 22:34:55 +0200 Subject: [PATCH 16/39] Fixed for flags --- slpkg/main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index e35e3db5..f2fb7b06 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -45,7 +45,7 @@ class Argparse: # Check for correct flag for opt in self.args: if opt.startswith('--'): - if opt not in self.options and opt != '--help': + if opt not in self.options and opt not in ['--help', '--version']: raise SystemExit(f"\nError: flag '{opt}' does not exist.\n") # Remove flags from args @@ -74,6 +74,9 @@ class Argparse: self.usage.help(1) def upgrade(self): + if [f for f in self.flags if f not in self.options[:-2]]: + self.usage.help(1) + if len(self.args) == 1: self.check.database() @@ -99,7 +102,10 @@ class Argparse: self.usage.help(1) def build(self): - if len(self.args) >= 2 and '--reinstall' not in self.flags: + if [f for f in self.flags if f not in self.options[:-3]]: + self.usage.help(1) + + if len(self.args) >= 2: packages = list(set(self.args[1:])) self.check.database() @@ -112,6 +118,9 @@ class Argparse: self.usage.help(1) def install(self): + if [f for f in self.flags if f not in self.options[:-1]]: + self.usage.help(1) + if len(self.args) >= 2: packages = list(set(self.args[1:])) @@ -154,6 +163,9 @@ class Argparse: self.usage.help(1) def view(self): + if [f for f in self.flags if f not in self.options[5]]: + self.usage.help(1) + if len(self.args) >= 2: packages = list(set(self.args[1:])) From 25fe8a3949ae8ea6bcef61f92a6d887121a1f184 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 22:38:46 +0200 Subject: [PATCH 17/39] Changed for print command --- slpkg/views/view_package.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 12a91636..1ee27c01 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -92,11 +92,10 @@ class ViewPackage: if name in requires: version = SBoQueries(sbo).version() yield f'{sbo} ({version})' + print('\n') else: return '' - print('\n') - @staticmethod def http_request(link): """ Http get request. """ From f5ae68d6ccd81957a5ea937ae2804c0d63cd951a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 21 Dec 2022 23:45:57 +0200 Subject: [PATCH 18/39] Updated the print method --- slpkg/views/view_package.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 1ee27c01..8594ed05 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -30,6 +30,7 @@ class ViewPackage: red = color['red'] endc = color['endc'] + print(end='\rCollecting the data... ') for package in packages: dependees = " ".join(list(self.dependees(package))) @@ -62,7 +63,7 @@ class ViewPackage: deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()])) - print(f'Name: {green}{info[0]}{endc}\n' + print(f'\n\nName: {green}{info[0]}{endc}\n' f'Version: {green}{info[1]}{endc}\n' f'Requires: {green}{deps}{endc}\n' f'Dependees: {green}{dependees}{endc}\n' @@ -85,16 +86,12 @@ class ViewPackage: def dependees(self, name): """ Collecting the dependees. """ if '--dependees' in self.flags: - print(end='\rCollecting the data... ') sbos = SBoQueries(name).names() for sbo in sbos: requires = SBoQueries(sbo).requires() if name in requires: version = SBoQueries(sbo).version() yield f'{sbo} ({version})' - print('\n') - else: - return '' @staticmethod def http_request(link): From e45bba96cbe6ff4f164ebaf05ebaa970d5fb3a44 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 17:11:08 +0200 Subject: [PATCH 19/39] Updated return a row --- slpkg/queries.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/slpkg/queries.py b/slpkg/queries.py index 3bec26ba..7b57110e 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -22,7 +22,8 @@ class SBoQueries: def names(self): """ Returns all the slackbuilds. """ - return list(self._names_grabbing()) + names = self.session.query(SBoTable.name).all() + return [name[0] for name in names] def slackbuild(self): """ Returns a slackbuild. """ @@ -117,9 +118,3 @@ class SBoQueries: if self.configs.os_arch == 'x86_64' and arch64: return arch64 return arch - - def _names_grabbing(self): - """ Generate and returns all the slackbuilds. """ - names = self.session.query(SBoTable.name).all() - for n in names: - yield n[0] From bc386dffec2dff3ababf6ea22614c6393c6353d5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 20:53:37 +0200 Subject: [PATCH 20/39] Added a command dependees --- ChangeLog.txt | 5 ++-- README.rst | 2 +- man/slpkg.1 | 12 ++++---- slpkg/dependees.py | 58 +++++++++++++++++++++++++++++++++++++ slpkg/main.py | 30 +++++++++++++------ slpkg/views/cli_menu.py | 14 ++++----- slpkg/views/view_package.py | 20 ++----------- 7 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 slpkg/dependees.py diff --git a/ChangeLog.txt b/ChangeLog.txt index 30e57cce..021d16ef 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,7 @@ -4.3.9 - 20/12/2022 +4.3.9 - 22/12/2022 Added: - Feature to check the ChangeLog.txt file before update #153 -- Dependees in the view command -- Flag --dependees +- Dependees command BugFixed: - View installed version diff --git a/README.rst b/README.rst index 173ac233..d30b2a05 100644 --- a/README.rst +++ b/README.rst @@ -60,6 +60,7 @@ Usage -f, find Find installed packages. -w, view View packages from the repository. -s, search Search packages from the repository. + -e, dependees Show which packages depend. OPTIONS: --yes Answer Yes to all questions. @@ -67,7 +68,6 @@ Usage --resolve-off Turns off dependency resolving. --reinstall Upgrade packages of the same version. --skip-installed Skip installed packages. - --dependees Show which packages depend. -h, --help Show this message and exit. -v, --version Print version and exit. diff --git a/man/slpkg.1 b/man/slpkg.1 index 67236ceb..f3578969 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .P -slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] --yes --jobs --resolve-off --reinstall --skip-installed, --dependees +slpkg [-h|-v] [update] [upgrade] [check-updates] [clean-logs] [clean-tmp] [-b, build] [-i, install] [-d, download] [-r, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] --yes --jobs --resolve-off --reinstall --skip-installed .SH DESCRIPTION .P Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. @@ -71,6 +71,11 @@ View packages from the repository and get everything in your terminal. .RS Search and match packages from the repository. .RE +.P +-e, dependees +.RS +Show which SlackBuilds depend on. +.RE .SH OPTIONS .P --yes @@ -100,11 +105,6 @@ Note: This option affects only the dependencies. .RE .RE .P ---dependees -.RS -This flag works only with the -w, view command to show which packages depend. -.RE -.P -h | --help .RS Show help information and exit. diff --git a/slpkg/dependees.py b/slpkg/dependees.py new file mode 100644 index 00000000..de5b717e --- /dev/null +++ b/slpkg/dependees.py @@ -0,0 +1,58 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from slpkg.configs import Configs +from slpkg.queries import SBoQueries + + +class Dependees: + + def __init__(self, packages): + self.packages = packages + self.configs = Configs + self.colors = self.configs.colour + + def slackbuilds(self): + """ Collecting the dependees. """ + color = self.colors() + cyan = color['cyan'] + grey = color['grey'] + yellow = color['yellow'] + endc = color['endc'] + + print(f'The list below shows the ' + f'packages that dependees \'{", ".join([p for p in self.packages])}\' SlackBuilds:\n') + + print(end='\rCollecting the data... ') + + dependees = {} + for package in self.packages: + found = [] + sbos = SBoQueries('').names() + + for sbo in sbos: + requires = SBoQueries(sbo).requires() + + if package in requires: + found.append(sbo) + dependees[package] = found + + last = ' └─' + print('\n') + + for key, value in dependees.items(): + print(f'{yellow}{key}{endc}') + print(end=f'\r{last}') + char = ' ├─' + + for i, v in enumerate(value, start=1): + if i == len(value): + char = last + if i == 1: + print(f'{cyan}{v}{endc}') + else: + print(f' {cyan}{v}{endc}') + print(f' {char} {" ".join([r for r in SBoQueries(v).requires()])}') + + print(f'\n{grey}{len(value)} dependees for {key}{endc}\n') diff --git a/slpkg/main.py b/slpkg/main.py index f2fb7b06..135ead8b 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -7,6 +7,7 @@ import sys from slpkg.checks import Check from slpkg.upgrade import Upgrade from slpkg.configs import Configs +from slpkg.dependees import Dependees from slpkg.utilities import Utilities from slpkg.search import SearchPackage from slpkg.views.cli_menu import Usage @@ -162,17 +163,25 @@ class Argparse: raise SystemExit() self.usage.help(1) - def view(self): - if [f for f in self.flags if f not in self.options[5]]: - self.usage.help(1) + def find(self): + if len(self.args) >= 2 and not self.flags: + packages = list(set(self.args[1:])) - if len(self.args) >= 2: + self.check.database() + + find = FindInstalled() + find.find(packages) + raise SystemExit() + self.usage.help(1) + + def view(self): + if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) self.check.database() self.check.exists(packages) - view = ViewPackage(self.flags) + view = ViewPackage() view.package(packages) raise SystemExit() self.usage.help(1) @@ -188,14 +197,15 @@ class Argparse: raise SystemExit() self.usage.help(1) - def find(self): + def dependees(self): if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) self.check.database() + self.check.exists(packages) - find = FindInstalled() - find.find(packages) + dependees = Dependees(packages) + dependees.slackbuilds() raise SystemExit() self.usage.help(1) @@ -253,7 +263,9 @@ def main(): 'find': argparse.find, '-f': argparse.find, 'search': argparse.search, - '-s': argparse.search + '-s': argparse.search, + 'dependees': argparse.dependees, + '-e': argparse.dependees } try: diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 9070e8a4..1343ecdc 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -21,11 +21,11 @@ class Usage: """ Prints the short menu. """ args = ( f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' - f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, \n' - ' --skip-installed, --dependees]\n' + f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, ' + f'--skip-installed]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] \n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-r, remove, -f, find, -w, view, -s, search] \n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download, -r, remove] \n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] \n' " \nIf you need more information please try 'slpkg --help'.") print(args) @@ -49,14 +49,14 @@ class Usage: f' {self.cyan}-r, remove{self.endc} Remove installed packages.', f' {self.cyan}-f, find{self.endc} Find installed packages.', f' {self.cyan}-w, view{self.endc} View packages from the repository.', - f' {self.cyan}-s, search{self.endc} Search packages from the repository.\n', + f' {self.cyan}-s, search{self.endc} Search packages from the repository.', + f' {self.cyan}-e, dependees{self.endc} Show which packages depend.\n', f'{self.bold}OPTIONS:{self.endc}', f' {self.yellow}--yes{self.endc} Answer Yes to all questions.', f' {self.yellow}--jobs{self.endc} Set it for multicore systems.', f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.', f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.', - f' {self.yellow}--skip-installed{self.endc} Skip installed packages.', - f' {self.yellow}--dependees{self.endc} Show which packages depend.\n', + f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n', ' -h, --help Show this message and exit.', ' -v, --version Print version and exit.\n', 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 8594ed05..60e43104 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- -import sys import urllib3 from slpkg.configs import Configs @@ -14,8 +13,7 @@ from slpkg.models.models import session as Session class ViewPackage: """ View the repository packages. """ - def __init__(self, flags): - self.flags = flags + def __init__(self): self.session = Session self.configs = Configs self.colors = self.configs.colour @@ -30,11 +28,8 @@ class ViewPackage: red = color['red'] endc = color['endc'] - print(end='\rCollecting the data... ') for package in packages: - dependees = " ".join(list(self.dependees(package))) - info = self.session.query( SBoTable.name, SBoTable.version, @@ -63,10 +58,9 @@ class ViewPackage: deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()])) - print(f'\n\nName: {green}{info[0]}{endc}\n' + print(f'Name: {green}{info[0]}{endc}\n' f'Version: {green}{info[1]}{endc}\n' f'Requires: {green}{deps}{endc}\n' - f'Dependees: {green}{dependees}{endc}\n' f'Homepage: {blue}{homepage}{endc}\n' f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}' f'{self.configs.sbo_tar_suffix}{endc}\n' @@ -83,16 +77,6 @@ class ViewPackage: f'Email: {yellow}{email}{endc}\n' f'\nREADME: {cyan}{readme.data.decode()}{endc}') - def dependees(self, name): - """ Collecting the dependees. """ - if '--dependees' in self.flags: - sbos = SBoQueries(name).names() - for sbo in sbos: - requires = SBoQueries(sbo).requires() - if name in requires: - version = SBoQueries(sbo).version() - yield f'{sbo} ({version})' - @staticmethod def http_request(link): """ Http get request. """ From b9c3d2e53bde887f37649f2a86f9f852106fb1a2 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 20:57:30 +0200 Subject: [PATCH 21/39] Updated for spaces --- slpkg/dependees.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index de5b717e..52b33a08 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -7,6 +7,7 @@ from slpkg.queries import SBoQueries class Dependees: + """ Show which packages depend. """ def __init__(self, packages): self.packages = packages @@ -49,10 +50,12 @@ class Dependees: for i, v in enumerate(value, start=1): if i == len(value): char = last + if i == 1: print(f'{cyan}{v}{endc}') else: - print(f' {cyan}{v}{endc}') - print(f' {char} {" ".join([r for r in SBoQueries(v).requires()])}') + print(f'{" " * 3}{cyan}{v}{endc}') + + print(f'{" " * 5}{char} {" ".join([r for r in SBoQueries(v).requires()])}') print(f'\n{grey}{len(value)} dependees for {key}{endc}\n') From 3defd8f43f6c1faca8eb595260d2a9922717df51 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 20:59:48 +0200 Subject: [PATCH 22/39] Removed flag --- slpkg/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 135ead8b..7b85cc79 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -40,8 +40,7 @@ class Argparse: '--jobs', '--resolve-off', '--reinstall', - '--skip-installed', - '--dependees'] + '--skip-installed'] # Check for correct flag for opt in self.args: From 89d17cdec009eb7639cb69f29fb5ec9804fcdd78 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 21:13:24 +0200 Subject: [PATCH 23/39] Fixed spaces --- slpkg/dependees.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 52b33a08..10f49bc1 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -23,7 +23,7 @@ class Dependees: endc = color['endc'] print(f'The list below shows the ' - f'packages that dependees \'{", ".join([p for p in self.packages])}\' SlackBuilds:\n') + f'packages that dependees \'{", ".join([p for p in self.packages])}\' files:\n') print(end='\rCollecting the data... ') @@ -56,6 +56,6 @@ class Dependees: else: print(f'{" " * 3}{cyan}{v}{endc}') - print(f'{" " * 5}{char} {" ".join([r for r in SBoQueries(v).requires()])}') + print(f'{" " * 4}{char} {" ".join([r for r in SBoQueries(v).requires()])}') print(f'\n{grey}{len(value)} dependees for {key}{endc}\n') From fdfe2c0f2852cc9c424efd92cf1f0db58cbb46c3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 21:13:41 +0200 Subject: [PATCH 24/39] Update for dependees --- README.rst | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index d30b2a05..720865a0 100644 --- a/README.rst +++ b/README.rst @@ -89,10 +89,10 @@ Usage Total 6 packages will be installed and 0 will be upgraded. - Do you want to continue [y/N]: + Do you want to continue (y/N)?: - $ slpkg remove Flask + $ slpkg remove Flask The following packages will be removed: [ delete ] -> Flask-2.1.2-x86_64-1_SBo @@ -106,7 +106,28 @@ Usage Total 6 packages will be removed. - Do you want to continue [y/N]: + Do you want to continue (y/N)?: + + + $ slpkg -e vlc + The list below shows the packages that dependees 'vlc' files: + + Collecting the data... + + vlc + └─kaffeine + ├─ vlc + obs-studio + ├─ faac luajit rtmpdump x264 jack libfdk-aac mbedtls vlc + vlsub + ├─ vlc + sopcast-player + └─ sopcast vlc + + 4 dependees for vlc + + + Configuration files From 2320da99e7d0f2526dc74b94bd232964d233ea09 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 21:15:32 +0200 Subject: [PATCH 25/39] Updated --- README.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 720865a0..5c99d3ab 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,6 @@ Usage .. code-block:: bash $ slpkg --help - USAGE: slpkg [OPTIONS] [COMMAND] DESCRIPTION: @@ -109,20 +108,20 @@ Usage Do you want to continue (y/N)?: - $ slpkg -e vlc + $ slpkg dependees vlc The list below shows the packages that dependees 'vlc' files: Collecting the data... vlc └─kaffeine - ├─ vlc + ├─ vlc obs-studio - ├─ faac luajit rtmpdump x264 jack libfdk-aac mbedtls vlc + ├─ faac luajit rtmpdump x264 jack libfdk-aac mbedtls vlc vlsub - ├─ vlc + ├─ vlc sopcast-player - └─ sopcast vlc + └─ sopcast vlc 4 dependees for vlc From e313bc4022f1f3546aead0a993b33990feaaa757 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 22:07:04 +0200 Subject: [PATCH 26/39] Added comment --- slpkg/dependees.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 10f49bc1..8c69bd48 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -29,7 +29,7 @@ class Dependees: dependees = {} for package in self.packages: - found = [] + found = [] # Reset list every package sbos = SBoQueries('').names() for sbo in sbos: From 8d52c35411feb55db76b1310cd3683aa59ae86f6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 22:07:42 +0200 Subject: [PATCH 27/39] Updated for loop --- slpkg/dependees.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 8c69bd48..7caa9f3b 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -56,6 +56,6 @@ class Dependees: else: print(f'{" " * 3}{cyan}{v}{endc}') - print(f'{" " * 4}{char} {" ".join([r for r in SBoQueries(v).requires()])}') + print(f'{" " * 4}{char} {" ".join([req for req in SBoQueries(v).requires()])}') print(f'\n{grey}{len(value)} dependees for {key}{endc}\n') From 04122167fe93ecc77a6c0a1104b0bba2030e46b8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 22:10:28 +0200 Subject: [PATCH 28/39] Updated quotes --- slpkg/dependees.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 7caa9f3b..0111d5c4 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -22,8 +22,8 @@ class Dependees: yellow = color['yellow'] endc = color['endc'] - print(f'The list below shows the ' - f'packages that dependees \'{", ".join([p for p in self.packages])}\' files:\n') + print(f"The list below shows the " + f"packages that dependees '{', '.join([p for p in self.packages])}' files:\n") print(end='\rCollecting the data... ') From 38cc9dbff9aed66d79a8d86b6013bab082d48951 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 22:26:59 +0200 Subject: [PATCH 29/39] Added type hints --- slpkg/blacklist.py | 2 +- slpkg/check_updates.py | 2 +- slpkg/checks.py | 2 +- slpkg/checksum.py | 2 +- slpkg/clean_logs.py | 2 +- slpkg/create_data.py | 2 +- slpkg/dependees.py | 2 +- slpkg/dependencies.py | 2 +- slpkg/download_only.py | 2 +- slpkg/main.py | 2 +- slpkg/queries.py | 22 +++++++++++----------- slpkg/remove_packages.py | 2 +- slpkg/search.py | 2 +- slpkg/slackbuild.py | 2 +- slpkg/utilities.py | 4 ++-- slpkg/views/version.py | 10 +++++----- slpkg/views/view_package.py | 4 ++-- slpkg/views/views.py | 4 ++-- 18 files changed, 35 insertions(+), 35 deletions(-) diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 3bb5f1e5..f9e480b0 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -11,7 +11,7 @@ from slpkg.configs import Configs class Blacklist: """ Reads and returns the blacklist. """ - def __init__(self): + def __init__(self) -> list: self.configs = Configs def get(self): diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 8dd62b46..837c1ea1 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -14,7 +14,7 @@ class CheckUpdates: def __init__(self): self.configs = Configs - def check(self): + def check(self) -> bool: """ Checks the ChangeLogs and returns True or False. """ print(end='\rChecking for news in the Changelog.txt file... ') local_date = 0 diff --git a/slpkg/checks.py b/slpkg/checks.py index dd9cf918..5a12ede8 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -38,7 +38,7 @@ class Check: if 'UNSUPPORTED' in sources: raise SystemExit(f"\nPackage '{sbo}' unsupported by arch.\n") - def installed(self, slackbuilds: list): + def installed(self, slackbuilds: list) -> list: """ Checking for installed packages. """ found, not_found = [], [] diff --git a/slpkg/checksum.py b/slpkg/checksum.py index f89919bb..8bf953bf 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -10,7 +10,7 @@ from slpkg.views.views import ViewMessage class Md5sum: """ Checksum the sources. """ - def __init__(self, flags): + def __init__(self, flags: list): self.flags = flags def check(self, path: str, source: str, checksum: str, name: str): diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py index ee2eec8d..5d617602 100644 --- a/slpkg/clean_logs.py +++ b/slpkg/clean_logs.py @@ -10,7 +10,7 @@ from slpkg.models.models import session as Session class CleanLogsDependencies: """ Cleans the logs from packages. """ - def __init__(self, flags): + def __init__(self, flags: list): self.flags = flags self.session = Session diff --git a/slpkg/create_data.py b/slpkg/create_data.py index 0bdeb9f9..46e914fe 100644 --- a/slpkg/create_data.py +++ b/slpkg/create_data.py @@ -58,6 +58,6 @@ class CreateData: @staticmethod def read_file(file: str): - """ Reades the text file. """ + """ Reads the text file. """ with open(file, 'r', encoding='utf-8') as f: return f.readlines() diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 0111d5c4..1156f52f 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -9,7 +9,7 @@ from slpkg.queries import SBoQueries class Dependees: """ Show which packages depend. """ - def __init__(self, packages): + def __init__(self, packages: list): self.packages = packages self.configs = Configs self.colors = self.configs.colour diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py index 8f57cd22..c16c5b1b 100644 --- a/slpkg/dependencies.py +++ b/slpkg/dependencies.py @@ -9,7 +9,7 @@ class Requires: """ Creates a list of dependencies with the right order to install. """ - def __init__(self, name): + def __init__(self, name: str): self.name = name def resolve(self) -> list: diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 77295bfb..333ee0e3 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -12,7 +12,7 @@ from slpkg.models.models import session as Session class Download: """ Download the slackbuilds with the sources only. """ - def __init__(self, flags): + def __init__(self, flags: list): self.flags: list = flags self.configs = Configs self.session = Session diff --git a/slpkg/main.py b/slpkg/main.py index 7b85cc79..413ccb87 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -24,7 +24,7 @@ from slpkg.update_repository import UpdateRepository class Argparse: - def __init__(self, args): + def __init__(self, args: list): self.args = args self.flags = [] self.configs = Configs diff --git a/slpkg/queries.py b/slpkg/queries.py index 7b57110e..1778f250 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -11,7 +11,7 @@ from slpkg.models.models import session as Session class SBoQueries: """ Queries class for the sbo repository. """ - def __init__(self, name): + def __init__(self, name: str): self.name = name self.session = Session self.configs = Configs @@ -20,12 +20,12 @@ class SBoQueries: if self.name in self.black.get(): self.name = '' - def names(self): + def names(self) -> list: """ Returns all the slackbuilds. """ names = self.session.query(SBoTable.name).all() return [name[0] for name in names] - def slackbuild(self): + def slackbuild(self) -> str: """ Returns a slackbuild. """ sbo = self.session.query( SBoTable.name).filter(SBoTable.name == self.name).first() @@ -34,7 +34,7 @@ class SBoQueries: return sbo[0] return '' - def location(self): + def location(self) -> str: """ Returns the category of a slackbuild. """ location = self.session.query( SBoTable.location).filter(SBoTable.name == self.name).first() @@ -43,7 +43,7 @@ class SBoQueries: return location[0] return '' - def sources(self): + def sources(self) -> str: """ Returns the source of a slackbuild. """ source, source64 = self.session.query( SBoTable.download, SBoTable.download64).filter( @@ -53,7 +53,7 @@ class SBoQueries: return self._chose_arch(source, source64) return '' - def requires(self): + def requires(self) -> str: """ Returns the requirements of a slackbuild. """ requires = self.session.query( SBoTable.requires).filter( @@ -67,7 +67,7 @@ class SBoQueries: return requires return '' - def version(self): + def version(self) -> str: """ Returns the version of a slackbuild. """ version = self.session.query( SBoTable.version).filter( @@ -77,7 +77,7 @@ class SBoQueries: return version[0] return '' - def checksum(self): + def checksum(self) -> str: """ Returns the source checkcum. """ md5sum, md5sum64, = [], [] mds5, md5s64 = self.session.query( @@ -93,7 +93,7 @@ class SBoQueries: return self._chose_arch(md5sum, md5sum64) return '' - def description(self): + def description(self) -> str: """ Returns the slackbuild description. """ desc = self.session.query( SBoTable.short_description).filter( @@ -103,7 +103,7 @@ class SBoQueries: return desc[0] return '' - def files(self): + def files(self) -> str: """ Returns the files of a slackbuild. """ files = self.session.query( SBoTable.files).filter( @@ -113,7 +113,7 @@ class SBoQueries: return files[0] return '' - def _chose_arch(self, arch, arch64): + def _chose_arch(self, arch: str, arch64: str) -> str: """ Choosing the right arch. """ if self.configs.os_arch == 'x86_64' and arch64: return arch64 diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index 311f81b0..6556e4f2 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -13,7 +13,7 @@ from slpkg.models.models import session as Session class RemovePackages: """ Removes installed packages. """ - def __init__(self, packages, flags): + def __init__(self, packages: list, flags: list): self.packages = packages self.flags = flags self.session = Session diff --git a/slpkg/search.py b/slpkg/search.py index f3767dcc..4effad2d 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -12,7 +12,7 @@ class SearchPackage: def __init__(self): self.colors = Configs.colour - def package(self, packages): + def package(self, packages: list): """ Searching and print the matched slackbuilds. """ color = self.colors() cyan = color['cyan'] diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index f9cb42a3..b0e44766 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -21,7 +21,7 @@ from slpkg.models.models import session as Session class Slackbuilds: """ Download build and install the SlackBuilds. """ - def __init__(self, slackbuilds, flags, install): + def __init__(self, slackbuilds: list, flags: list, install: bool): self.slackbuilds = slackbuilds self.flags = flags self.install = install diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 5fb5dc4f..eb6db319 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -16,7 +16,7 @@ class Utilities: self.configs = Configs self.black = Blacklist() - def is_installed(self, name: str): + def is_installed(self, name: str) -> str: """ Returns the installed package name. """ for package in os.listdir(self.configs.log_packages): pkg = self.split_installed_pkg(package)[0] @@ -52,7 +52,7 @@ class Utilities: if not os.path.isdir(directory): os.makedirs(directory) - def split_installed_pkg(self, package): + def split_installed_pkg(self, package: str) -> list: """ Split the package by the name, version, arch, build and tag. """ name = '-'.join(package.split('-')[:-3]) version = ''.join(package[len(name):].split('-')[:-2]) diff --git a/slpkg/views/version.py b/slpkg/views/version.py index 5610a0eb..aa9c19cc 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -6,11 +6,11 @@ class Version: """ Print the version. """ def __init__(self): - self.version_info: tuple = (4, 3, 9) - self.version: str = '{0}.{1}.{2}'.format(*self.version_info) - self.license: str = 'MIT License' - self.author: str = 'Dimitris Zlatanidis (dslackw)' - self.homepage: str = 'https://dslackw.gitlab.io/slpkg' + self.version_info = (4, 3, 9) + self.version = '{0}.{1}.{2}'.format(*self.version_info) + self.license = 'MIT License' + self.author = 'Dimitris Zlatanidis (dslackw)' + self.homepage = 'https://dslackw.gitlab.io/slpkg' def view(self): """ Prints the version. """ diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 60e43104..238ba2cf 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -18,7 +18,7 @@ class ViewPackage: self.configs = Configs self.colors = self.configs.colour - def package(self, packages): + def package(self, packages: list): """ View the packages from the repository. """ color = self.colors() green = color['green'] @@ -78,7 +78,7 @@ class ViewPackage: f'\nREADME: {cyan}{readme.data.decode()}{endc}') @staticmethod - def http_request(link): + def http_request(link: str) -> str: """ Http get request. """ http = urllib3.PoolManager() return http.request('GET', link) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index ae8ef184..4d774691 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -14,7 +14,7 @@ from slpkg.models.models import session as Session class ViewMessage: """ Print some messages before. """ - def __init__(self, flags): + def __init__(self, flags: list): self.flags = flags self.configs = Configs self.colors = self.configs.colour @@ -170,7 +170,7 @@ class ViewMessage: print(f'\n{color["grey"]}Total {installed + upgraded} packages ' f'will be removed.{color["endc"]}') - def logs_packages(self, dependencies): + def logs_packages(self, dependencies: list): """ View the logging packages. """ print('The following logs will be removed:\n') color = self.colors() From f23af079bdf8bc4d84021e017ff94af17c10dba3 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 22:35:28 +0200 Subject: [PATCH 30/39] Removed for loop --- slpkg/views/cli_menu.py | 61 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 1343ecdc..dfd3b80b 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -28,40 +28,37 @@ class Usage: f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] \n' " \nIf you need more information please try 'slpkg --help'.") - print(args) - raise SystemExit() + raise SystemExit(args) def help(self, status: int): """ Prints the main menu. """ - args = [ - f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n', - f'{self.bold}DESCRIPTION:{self.endc}', - ' Packaging tool that interacts with the SBo repository.\n', - f'{self.bold}COMMANDS:{self.endc}', - f' {self.red}update{self.endc} Update the package lists.', - f' {self.cyan}upgrade{self.endc} Upgrade all the packages.', - f' {self.cyan}check-updates{self.endc} Check for news on ChangeLog.txt.', - f' {self.cyan}clean-logs{self.endc} Clean dependencies log tracking.', - f' {self.cyan}clean-tmp{self.endc} Delete all the downloaded sources.', - f' {self.cyan}-b, build{self.endc} Build only the packages.', - f' {self.cyan}-i, install{self.endc} Build and install the packages.', - f' {self.cyan}-d, download{self.endc} Download only the scripts and sources.', - f' {self.cyan}-r, remove{self.endc} Remove installed packages.', - f' {self.cyan}-f, find{self.endc} Find installed packages.', - f' {self.cyan}-w, view{self.endc} View packages from the repository.', - f' {self.cyan}-s, search{self.endc} Search packages from the repository.', - f' {self.cyan}-e, dependees{self.endc} Show which packages depend.\n', - f'{self.bold}OPTIONS:{self.endc}', - f' {self.yellow}--yes{self.endc} Answer Yes to all questions.', - f' {self.yellow}--jobs{self.endc} Set it for multicore systems.', - f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.', - f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.', - f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n', - ' -h, --help Show this message and exit.', - ' -v, --version Print version and exit.\n', - 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', - 'If you need more information try to use slpkg manpage.'] + args = ( + f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' + f'\n{self.bold}DESCRIPTION:{self.endc} Packaging tool that interacts with the SBo repository.\n' + f'\n{self.bold}COMMANDS:{self.endc}\n' + f' {self.red}update{self.endc} Update the package lists.\n' + f' {self.cyan}upgrade{self.endc} Upgrade all the packages.\n' + f' {self.cyan}check-updates{self.endc} Check for news on ChangeLog.txt.\n' + f' {self.cyan}clean-logs{self.endc} Clean dependencies log tracking.\n' + f' {self.cyan}clean-tmp{self.endc} Delete all the downloaded sources.\n' + f' {self.cyan}-b, build{self.endc} Build only the packages.\n' + f' {self.cyan}-i, install{self.endc} Build and install the packages.\n' + f' {self.cyan}-d, download{self.endc} Download only the scripts and sources.\n' + f' {self.cyan}-r, remove{self.endc} Remove installed packages.\n' + f' {self.cyan}-f, find{self.endc} Find installed packages.\n' + f' {self.cyan}-w, view{self.endc} View packages from the repository.\n' + f' {self.cyan}-s, search{self.endc} Search packages from the repository.\n' + f' {self.cyan}-e, dependees{self.endc} Show which packages depend.\n\n' + f'{self.bold}OPTIONS:{self.endc}\n' + f' {self.yellow}--yes{self.endc} Answer Yes to all questions.\n' + f' {self.yellow}--jobs{self.endc} Set it for multicore systems.\n' + f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.\n' + f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.\n' + f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n' + '\n -h, --help Show this message and exit.\n' + ' -v, --version Print version and exit.\n' + '\nEdit the configuration file in the /etc/slpkg/slpkg.toml.\n' + 'If you need more information try to use slpkg manpage.') - for opt in args: - print(opt) + print(args) raise SystemExit(status) From 94153d5eca226ae6dca1ab10dfe728c3e4c90eec Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:00:42 +0200 Subject: [PATCH 31/39] Fixed code --- slpkg/blacklist.py | 4 ++-- slpkg/queries.py | 4 ++-- slpkg/update_repository.py | 2 +- tests/test_checks.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index f9e480b0..412b0828 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -11,10 +11,10 @@ from slpkg.configs import Configs class Blacklist: """ Reads and returns the blacklist. """ - def __init__(self) -> list: + def __init__(self): self.configs = Configs - def get(self): + def get(self) -> list: """ Reads the blacklist file. """ file = f'{self.configs.etc_path}/blacklist.toml' if os.path.isfile(file): diff --git a/slpkg/queries.py b/slpkg/queries.py index 1778f250..a856c092 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -78,7 +78,7 @@ class SBoQueries: return '' def checksum(self) -> str: - """ Returns the source checkcum. """ + """ Returns the source checksum. """ md5sum, md5sum64, = [], [] mds5, md5s64 = self.session.query( SBoTable.md5sum, SBoTable.md5sum64).filter( @@ -113,7 +113,7 @@ class SBoQueries: return files[0] return '' - def _chose_arch(self, arch: str, arch64: str) -> str: + def _chose_arch(self, arch: list, arch64: list) -> str: """ Choosing the right arch. """ if self.configs.os_arch == 'x86_64' and arch64: return arch64 diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 80de90de..655488c2 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -24,7 +24,7 @@ class UpdateRepository: def sbo(self): """ Updated the sbo repository. """ - view = ViewMessage('') + view = ViewMessage([]) check_updates = CheckUpdates() if not check_updates.check(): diff --git a/tests/test_checks.py b/tests/test_checks.py index 76402be5..2ca5d7a0 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -11,7 +11,7 @@ class TestPkgInstalled(unittest.TestCase): def test_check_exists(self): self.assertIsNone(self.check.exists(self.packages)) - def tect_check_unsupported(self): + def test_check_unsupported(self): self.assertIsNone(self.check.unsupported(self.packages)) def test_check_installed(self): From 0e89183985347c4f131365c07175b6c1a0130b78 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:20:37 +0200 Subject: [PATCH 32/39] Updated checksum check --- slpkg/queries.py | 17 +++-------------- slpkg/slackbuild.py | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/slpkg/queries.py b/slpkg/queries.py index a856c092..95a513d3 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -79,19 +79,14 @@ class SBoQueries: def checksum(self) -> str: """ Returns the source checksum. """ - md5sum, md5sum64, = [], [] mds5, md5s64 = self.session.query( SBoTable.md5sum, SBoTable.md5sum64).filter( SBoTable.name == self.name).first() - if mds5: - md5sum.append(mds5) - if md5s64: - md5sum64.append(md5s64) + if self.configs.os_arch == 'x86_64' and md5s64: + return md5s64.split() - if md5sum or md5sum64: - return self._chose_arch(md5sum, md5sum64) - return '' + return mds5.split() def description(self) -> str: """ Returns the slackbuild description. """ @@ -112,9 +107,3 @@ class SBoQueries: if files: return files[0] return '' - - def _chose_arch(self, arch: list, arch64: list) -> str: - """ Choosing the right arch. """ - if self.configs.os_arch == 'x86_64' and arch64: - return arch64 - return arch diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index b0e44766..9fc62872 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -208,7 +208,7 @@ class Slackbuilds: checksums = SBoQueries(name).checksum() - for source, checksum in zip(sources.split(), checksums[0].split()): + for source, checksum in zip(sources.split(), checksums): wget.download(path, source) md5sum = Md5sum(self.flags) md5sum.check(path, source, checksum, name) From 619b282a453a06a3b18c1fc620b9663b5ed31b20 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:26:48 +0200 Subject: [PATCH 33/39] Updated for sources --- slpkg/download_only.py | 2 +- slpkg/queries.py | 7 ++++--- slpkg/slackbuild.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 333ee0e3..e30ac419 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -32,5 +32,5 @@ class Download: wget.download(self.configs.download_only, url) sources = SBoQueries(sbo).sources() - for source in sources.split(): + for source in sources: wget.download(self.configs.download_only, source) diff --git a/slpkg/queries.py b/slpkg/queries.py index 95a513d3..32216dd2 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -49,9 +49,10 @@ class SBoQueries: SBoTable.download, SBoTable.download64).filter( SBoTable.name == self.name).first() - if source or source64: - return self._chose_arch(source, source64) - return '' + if self.configs.os_arch == 'x86_64' and source64: + return source64.split() + + return source.split() def requires(self) -> str: """ Returns the requirements of a slackbuild. """ diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 9fc62872..c2ebde21 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -200,7 +200,7 @@ class Slackbuilds: cpus = multiprocessing.cpu_count() os.environ['MAKEFLAGS'] = f'-j {cpus}' - def download_sources(self, name: str, sources: str): + def download_sources(self, name: str, sources: list): """ Download the sources. """ wget = Wget() @@ -208,7 +208,7 @@ class Slackbuilds: checksums = SBoQueries(name).checksum() - for source, checksum in zip(sources.split(), checksums): + for source, checksum in zip(sources, checksums): wget.download(path, source) md5sum = Md5sum(self.flags) md5sum.check(path, source, checksum, name) From 4627fd89c74010a6c409db2c619a65e3f4c761a9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:31:50 +0200 Subject: [PATCH 34/39] Fixed typing --- slpkg/queries.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/queries.py b/slpkg/queries.py index 32216dd2..4ae220e8 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -43,7 +43,7 @@ class SBoQueries: return location[0] return '' - def sources(self) -> str: + def sources(self) -> list: """ Returns the source of a slackbuild. """ source, source64 = self.session.query( SBoTable.download, SBoTable.download64).filter( @@ -78,7 +78,7 @@ class SBoQueries: return version[0] return '' - def checksum(self) -> str: + def checksum(self) -> list: """ Returns the source checksum. """ mds5, md5s64 = self.session.query( SBoTable.md5sum, SBoTable.md5sum64).filter( From 4041c38fb85fc254fad83a6103e68d008f6784fc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:36:29 +0200 Subject: [PATCH 35/39] Update string length --- slpkg/views/cli_menu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index dfd3b80b..3c4b1a59 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -33,7 +33,8 @@ class Usage: def help(self, status: int): """ Prints the main menu. """ args = ( - f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' + f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] ' + f'[{self.cyan}COMMAND{self.endc}] \n' f'\n{self.bold}DESCRIPTION:{self.endc} Packaging tool that interacts with the SBo repository.\n' f'\n{self.bold}COMMANDS:{self.endc}\n' f' {self.red}update{self.endc} Update the package lists.\n' From ed8ee244eb4181e37bd94fecba7d5f14f0f155d7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:36:50 +0200 Subject: [PATCH 36/39] Fixed requirements --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 90355720..4c37dd2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ SQLAlchemy>=1.4.36 -toml>=0.10.2 -setuptools~=60.2.0 +toml>=0.10.2 \ No newline at end of file From b5f07a992b999f6e8698c11d3ce5d32eb74bb672 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:51:41 +0200 Subject: [PATCH 37/39] Fixed and pass text color --- tests/test_colors.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_colors.py b/tests/test_colors.py index 235b0e24..fe9b873a 100644 --- a/tests/test_colors.py +++ b/tests/test_colors.py @@ -9,12 +9,14 @@ class TestColors(unittest.TestCase): self.color = colors() def test_colors(self): - self.assertIn('BOLD', self.color) - self.assertIn('RED', self.color) - self.assertIn('YELLOW', self.color) - self.assertIn('GREEN', self.color) - self.assertIn('BLUE', self.color) - self.assertIn('GREY', self.color) + self.assertIn('bold', self.color) + self.assertIn('red', self.color) + self.assertIn('yellow', self.color) + self.assertIn('cyan', self.color) + self.assertIn('green', self.color) + self.assertIn('blue', self.color) + self.assertIn('grey', self.color) + self.assertIn('endc', self.color) if __name__ == '__main__': From 604cc98b7b3177149d5a4c9dd0a2ed7f1012dc5c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 22 Dec 2022 23:55:45 +0200 Subject: [PATCH 38/39] Pass test queries --- tests/test_queries.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_queries.py b/tests/test_queries.py index a96068aa..bfb1bf93 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -14,17 +14,17 @@ class TestSBoQueries(unittest.TestCase): self.assertEqual('system', self.query.location()) def test_sources(self): - self.assertEqual('https://gitlab.com/dslackw/slpkg/-/archive' - '/4.3.0/slpkg-4.3.0.tar.gz', self.query.sources()) + self.assertEqual(['https://gitlab.com/dslackw/slpkg/-/archive' + '/4.3.7/slpkg-4.3.7.tar.gz'], self.query.sources()) def test_requires(self): - self.assertEqual(['SQLAlchemy'], self.query.requires()) + self.assertEqual(['SQLAlchemy', 'python-toml'], self.query.requires()) def test_version(self): - self.assertEqual('4.3.0', self.query.version()) + self.assertEqual('4.3.7', self.query.version()) def test_checksum(self): - self.assertListEqual(['ab03d0543b74abfce92287db740394c4'], + self.assertListEqual(['5a55fd350004b3e49a060835a7ada3e9'], self.query.checksum()) def test_files(self): From 8c8885aa48e1d564d59755ff6a6a3fec8bd7a456 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 23 Dec 2022 00:08:04 +0200 Subject: [PATCH 39/39] Pass test checks --- tests/test_checks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_checks.py b/tests/test_checks.py index 2ca5d7a0..2d2e496c 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -6,7 +6,7 @@ class TestPkgInstalled(unittest.TestCase): def setUp(self): self.check = Check() - self.packages = ['Flask', 'colored', 'slpkg'] + self.packages = ['fish', 'ranger', 'pycharm'] def test_check_exists(self): self.assertIsNone(self.check.exists(self.packages)) @@ -15,11 +15,10 @@ class TestPkgInstalled(unittest.TestCase): self.assertIsNone(self.check.unsupported(self.packages)) def test_check_installed(self): - self.assertIsNone(self.check.installed(self.packages)) + self.assertListEqual(self.packages, self.check.installed(self.packages)) def test_check_blacklist(self): - self.assertListEqual(self.packages, - self.check.blacklist(self.packages)) + self.assertIsNone(self.check.blacklist(self.packages)) if __name__ == "__main__":