From 5bf9460182c9074dede6c195d10f91101f41b940 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 20:47:52 +0200 Subject: [PATCH 01/13] Fixed readme --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 8f72c9e8..19cccfc1 100644 --- a/README.rst +++ b/README.rst @@ -115,7 +115,7 @@ Repositories Two repositories are supported, please read the config file. -- `slackbuilds.org `_ repository +- `slackbuilds `_ repository - `ponce `_ repository From da1803bf050387539b081c4adf48d9fd10a9c378 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 22:06:25 +0200 Subject: [PATCH 02/13] Removed NoReturn --- slpkg/checks.py | 9 ++++----- slpkg/downloader.py | 6 +++--- slpkg/main.py | 35 +++++++++++++++++------------------ slpkg/remove_packages.py | 5 ++--- slpkg/slackbuild.py | 5 ++--- slpkg/views/views.py | 4 ++-- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/slpkg/checks.py b/slpkg/checks.py index 6cd924cb..992e0ada 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from pathlib import Path -from typing import NoReturn from slpkg.configs import Configs from slpkg.queries import SBoQueries @@ -18,7 +17,7 @@ class Check(Configs, Utilities): super(Utilities, self).__init__() @staticmethod - def exists(slackbuilds: list) -> NoReturn: + def exists(slackbuilds: list) -> None: """ Checking if the slackbuild exists in the repository. """ not_packages: list = [] @@ -31,7 +30,7 @@ class Check(Configs, Utilities): 'does not exists.\n') @staticmethod - def unsupported(slackbuilds: list) -> NoReturn: + def unsupported(slackbuilds: list) -> None: """ Checking for unsupported slackbuilds. """ for sbo in slackbuilds: sources = SBoQueries(sbo).sources() @@ -57,7 +56,7 @@ class Check(Configs, Utilities): return found - def blacklist(self, slackbuilds: list) -> NoReturn: + def blacklist(self, slackbuilds: list) -> None: """ Checking if the packages are blacklisted. """ packages: list = [] black = Blacklist() @@ -72,7 +71,7 @@ class Check(Configs, Utilities): f'Please edit the blacklist.toml file in ' f'{self.configs.etc_path} folder.\n') - def database(self) -> NoReturn: + def database(self) -> None: """ Checking for empty table """ db = Path(self.db_path, self.database_name) if not SBoQueries('').sbos() or not db.is_file(): diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 8a3ec430..0ea6d228 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -5,7 +5,7 @@ import os import subprocess from pathlib import Path from urllib.parse import unquote -from typing import Union, NoReturn +from typing import Union from multiprocessing import Process from slpkg.configs import Configs @@ -41,7 +41,7 @@ class Downloader(Configs, Utilities): self.bred: str = f'{self.bold}{self.red}' self.flag_no_silent: list = ['-n', '--no-silent'] - def transfer_tools(self) -> NoReturn: + def transfer_tools(self) -> None: """ Downloader tools. wget, curl and lftp works with SBo repository. @@ -77,7 +77,7 @@ class Downloader(Configs, Utilities): if self.output != 0: raise SystemExit(self.output) - def check_if_downloaded(self) -> NoReturn: + def check_if_downloaded(self) -> None: """ Checks if the file downloaded. """ if 'ponce' not in self.url: url: str = unquote(self.url) diff --git a/slpkg/main.py b/slpkg/main.py index 3aa242c0..84d2ac6c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -3,7 +3,6 @@ import os import sys -from typing import NoReturn from slpkg.checks import Check from slpkg.upgrade import Upgrade @@ -280,7 +279,7 @@ class Argparse(Configs): self.args.remove(opt) self.flags.append(opt) - def is_dialog_enabled(self) -> NoReturn: + def is_dialog_enabled(self) -> None: """ Checking if the dialog box is enabled. """ if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or not self.dialogbox.dialog and 'configs' in self.args): @@ -364,21 +363,21 @@ class Argparse(Configs): self.usage.help(0) self.usage.help(1) - def version(self) -> NoReturn: + def version(self) -> None: if len(self.args) == 1: version = Version() version.view() raise SystemExit() self.usage.help(1) - def update(self) -> NoReturn: + def update(self) -> None: if len(self.args) == 1: update = UpdateRepository(self.flags) update.repository() raise SystemExit() self.usage.help(1) - def upgrade(self) -> NoReturn: + def upgrade(self) -> None: command = Argparse.upgrade.__name__ if len(self.args) == 1: @@ -398,7 +397,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def check_updates(self) -> NoReturn: + def check_updates(self) -> None: if len(self.args) == 1: self.check.database() @@ -407,13 +406,13 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def edit_configs(self) -> NoReturn: + def edit_configs(self) -> None: if len(self.args) == 1: self.form_configs.edit() raise SystemExit() self.usage.help(1) - def clean_logs(self) -> NoReturn: + def clean_logs(self) -> None: if len(self.args) == 1: self.check.database() @@ -422,7 +421,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def clean_tmp(self) -> NoReturn: + def clean_tmp(self) -> None: if len(self.args) == 1: self.utils.remove_folder_if_exists(path=self.tmp_path, folder=self.prog_name) @@ -432,7 +431,7 @@ class Argparse(Configs): self.usage.help(1) - def build(self) -> NoReturn: + def build(self) -> None: command = Argparse.build.__name__ if len(self.args) >= 2: @@ -450,7 +449,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def install(self) -> NoReturn: + def install(self) -> None: command = Argparse.install.__name__ if len(self.args) >= 2: @@ -468,7 +467,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def download(self) -> NoReturn: + def download(self) -> None: command = Argparse.download.__name__ if len(self.args) >= 2: @@ -484,7 +483,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def remove(self) -> NoReturn: + def remove(self) -> None: command = Argparse.remove.__name__ if len(self.args) >= 2: @@ -501,7 +500,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def find(self) -> NoReturn: + def find(self) -> None: command = Argparse.find.__name__ if len(self.args) >= 2: @@ -517,7 +516,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def view(self) -> NoReturn: + def view(self) -> None: command = Argparse.view.__name__ if len(self.args) >= 2: @@ -534,7 +533,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def search(self) -> NoReturn: + def search(self) -> None: command = Argparse.search.__name__ if len(self.args) >= 2: @@ -550,7 +549,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def dependees(self) -> NoReturn: + def dependees(self) -> None: command = Argparse.dependees.__name__ if len(self.args) >= 2: @@ -567,7 +566,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def tracking(self) -> NoReturn: + def tracking(self) -> None: command = Argparse.tracking.__name__ if len(self.args) >= 2: diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index f131320a..cd3cef7b 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -3,7 +3,6 @@ import time import subprocess -from typing import NoReturn from multiprocessing import Process from slpkg.configs import Configs @@ -124,14 +123,14 @@ class RemovePackages(Configs): self.print_error() - def process(self, command: str) -> NoReturn: + def process(self, command: str) -> None: """ Processes execution. """ self.output = subprocess.call(command, shell=True, stderr=self.stderr, stdout=self.stdout) if self.output != 0: raise SystemExit(self.output) - def print_error(self) -> NoReturn: + def print_error(self) -> None: """ Stop the process and print the error message. """ if self.output != 0: raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n") diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 4c04cc8a..7adf831a 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -4,7 +4,6 @@ import os import time import subprocess -from typing import NoReturn from pathlib import Path from collections import OrderedDict @@ -318,14 +317,14 @@ class Slackbuilds(Configs): self.print_error() - def process(self, command: str) -> NoReturn: + def process(self, command: str) -> None: """ Processes execution. """ self.output = subprocess.call(command, shell=True, stderr=self.stderr, stdout=self.stdout) if self.output != 0: raise SystemExit(self.output) - def print_error(self) -> NoReturn: + def print_error(self) -> None: """ Stop the process and print the error message. """ if self.output != 0: raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n") diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 62fbe309..9623629a 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import os -from typing import Any, NoReturn +from typing import Any from slpkg.configs import Configs from slpkg.views.ascii import Ascii @@ -229,7 +229,7 @@ class ViewMessage(Configs): print('Note: After cleaning you should remove them one by one.') - def question(self) -> NoReturn: + def question(self) -> None: """ Manage to proceed. """ if not self.utils.is_option(self.flag_yes, self.flags): answer: str = input('\nDo you want to continue? [y/N] ') From 961d9de6fed258942eb507d8830ceb9ac7a5860a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 22:09:00 +0200 Subject: [PATCH 03/13] Fixed for folder --- slpkg/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/checks.py b/slpkg/checks.py index 992e0ada..4407fe79 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -69,7 +69,7 @@ class Check(Configs, Utilities): raise SystemExit( f'\nThe packages \'{", ".join(packages)}\' is blacklisted.\n' f'Please edit the blacklist.toml file in ' - f'{self.configs.etc_path} folder.\n') + f'{self.etc_path} folder.\n') def database(self) -> None: """ Checking for empty table """ From 66c3fe542f5554f27d1c3536a2f77ae64e5b469d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 22:59:36 +0200 Subject: [PATCH 04/13] Updated for type --- slpkg/clean_logs.py | 2 +- slpkg/configs.py | 22 +++++++++++----------- slpkg/views/views.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py index eea3e7f1..b3882ee6 100644 --- a/slpkg/clean_logs.py +++ b/slpkg/clean_logs.py @@ -16,7 +16,7 @@ class CleanLogsDependencies: def clean(self) -> None: """ Deletes the log table from the database. """ dependencies: list = self.session.query( - LogsDependencies.name, LogsDependencies.requires).all() + LogsDependencies.name, LogsDependencies.requires).all() # type: ignore if dependencies: view = ViewMessage(self.flags) diff --git a/slpkg/configs.py b/slpkg/configs.py index 33833737..a761c890 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -11,7 +11,7 @@ from dataclasses import dataclass class LoadConfigs: @staticmethod - def file(path: str, file: str) -> dict: + def file(path: str, file: str) -> dict: # type: ignore try: """ Load the configs from the file. """ config_path_file = Path(path, f'{file}.toml') @@ -35,14 +35,14 @@ class Configs: # All necessary paths. tmp_path: str = '/tmp/' - tmp_slpkg: str = Path(tmp_path, prog_name) - build_path: str = Path('tmp', prog_name, 'build') - download_only_path: str = Path(tmp_slpkg, '') - lib_path: str = Path('/var/lib/', prog_name) - etc_path: str = Path('/etc/', prog_name) - db_path: str = Path(lib_path, 'database') - sbo_repo_path: str = Path(lib_path, 'repository') - log_packages: str = Path('/var', 'log', 'packages') + tmp_slpkg: str = Path(tmp_path, prog_name) # type: ignore + build_path: str = Path('tmp', prog_name, 'build') # type: ignore + download_only_path: str = Path(tmp_slpkg, '') # type: ignore + lib_path: str = Path('/var/lib/', prog_name) # type: ignore + etc_path: str = Path('/etc/', prog_name) # type: ignore + db_path: str = Path(lib_path, 'database') # type: ignore + sbo_repo_path: str = Path(lib_path, 'repository') # type: ignore + log_packages: str = Path('/var', 'log', 'packages') # type: ignore # Database name. database_name: str = f'database.{prog_name}' @@ -59,7 +59,7 @@ class Configs: ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/' slack_chglog_txt: str = 'ChangeLog.txt' - slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/') + slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/') # type: ignore # Slackware commands. installpkg: str = 'upgradepkg --install-new' @@ -70,7 +70,7 @@ class Configs: colors: bool = True # Dialog utility. - dialog: bool = True + dialog: bool = True # type: ignore # Downloader command. Wget and curl. downloader: str = 'wget' diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 9623629a..9a27a13d 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -121,7 +121,7 @@ class ViewMessage(Configs): slackbuilds.append(pkg) requires = self.session.query( - LogsDependencies.requires).filter( + LogsDependencies.requires).filter( # type: ignore LogsDependencies.name == pkg).first() if requires: From b2fdf0d32e463589cdbcb1be4b08d6a4f5b9c41b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:01:45 +0200 Subject: [PATCH 05/13] Updated for type hinting --- slpkg/dependees.py | 2 +- slpkg/dependencies.py | 5 ++-- slpkg/dialog_box.py | 4 ++-- slpkg/downloader.py | 4 ++-- slpkg/find_installed.py | 2 +- slpkg/form_configs.py | 2 +- slpkg/main.py | 46 ++++++++++++++++++------------------ slpkg/queries.py | 20 ++++++++-------- slpkg/remove_packages.py | 4 ++-- slpkg/slackbuild.py | 9 +++---- slpkg/upgrade.py | 2 +- slpkg/utilities.py | 7 +++--- slpkg/views/help_commands.py | 30 +++++++++++------------ slpkg/views/view_package.py | 24 +++++++++---------- 14 files changed, 81 insertions(+), 80 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index b1127990..38c3edf9 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -79,7 +79,7 @@ class Dependees(Configs, Utilities): def find_requires(self, sbo: str) -> Generator[str, None, None]: """ Find requires that slackbuild dependees. """ - requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() + requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() # type: ignore for req in requires: if [r for r in req[1].split() if r == sbo]: yield req diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py index 754fafd5..3c0fe374 100644 --- a/slpkg/dependencies.py +++ b/slpkg/dependencies.py @@ -13,11 +13,10 @@ class Requires: def resolve(self) -> list: """ Resolve the dependencies. """ - requires = SBoQueries(self.name).requires() - + requires: list[str] = SBoQueries(self.name).requires() # type: ignore for req in requires: if req: - sub = SBoQueries(req).requires() + sub: list[str] = SBoQueries(req).requires() # type: ignore for s in sub: requires.append(s) diff --git a/slpkg/dialog_box.py b/slpkg/dialog_box.py index 5b5fc043..05113684 100644 --- a/slpkg/dialog_box.py +++ b/slpkg/dialog_box.py @@ -25,7 +25,7 @@ class DialogBox(Configs): list_height: int, choices: list, packages: list): """ Display a checklist box. """ if self.dialog: - code, tags = self.d.checklist(text, title=title, height=height, width=width, + code, tags = self.d.checklist(text, title=title, height=height, width=width, # type: ignore list_height=list_height, choices=choices) else: code: bool = False @@ -36,7 +36,7 @@ class DialogBox(Configs): def mixedform(self, text: str, title: str, elements: list, height: int, width: int): """ Display a mixedform box. """ if self.dialog: - code, tags = self.d.mixedform(text=text, title=title, elements=elements, + code, tags = self.d.mixedform(text=text, title=title, elements=elements, # type: ignore height=height, width=width, help_button=True) else: code: bool = False diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 0ea6d228..d5747ada 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -19,14 +19,14 @@ class Downloader(Configs, Utilities): def __init__(self, path: Union[str, Path], url: str, flags: list): super(Configs, self).__init__() super(Utilities, self).__init__() - self.path: str = path + self.path = path self.url: str = url self.flags: list = flags self.color = self.colour() self.progress = ProgressBar() - self.output: int = 0 + self.output = 0 self.stderr = None self.stdout = None diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index 43ac0e2f..dcc34de4 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -24,7 +24,7 @@ class FindInstalled(Configs, Utilities): """ Find the packages. """ matching: list = [] - installed: list = self.all_installed(pattern) + installed: list = list(self.all_installed(pattern)) print(f'The list below shows the installed packages ' f'that contains \'{", ".join([p for p in packages])}\' files:\n') diff --git a/slpkg/form_configs.py b/slpkg/form_configs.py index 4afecafe..19f7b895 100644 --- a/slpkg/form_configs.py +++ b/slpkg/form_configs.py @@ -16,7 +16,7 @@ class FormConfigs(Configs): self.load_configs = LoadConfigs() self.dialogbox = DialogBox() - self.orig_configs = None + self.orig_configs: list = [] self.config_file = Path(self.etc_path, f'{self.prog_name}.toml') def edit(self) -> None: diff --git a/slpkg/main.py b/slpkg/main.py index 84d2ac6c..9fc695fa 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -32,7 +32,7 @@ class Argparse(Configs): def __init__(self, args: list): self.args: list = args self.flags: list = [] - self.directory = None + self.directory = self.tmp_slpkg self.file_pattern: str = f'*{self.sbo_repo_tag}' self.dialogbox = DialogBox() self.utils = Utilities() @@ -207,23 +207,23 @@ class Argparse(Configs): ] } - self.commands['-h']: dict = self.commands['--help'] - self.commands['-v']: dict = self.commands['--version'] - self.commands['-u']: dict = self.commands['update'] - self.commands['-U']: dict = self.commands['upgrade'] - self.commands['-c']: dict = self.commands['check-updates'] - self.commands['-g']: dict = self.commands['configs'] - self.commands['-L']: dict = self.commands['clean-logs'] - self.commands['-D']: dict = self.commands['clean-tmp'] - self.commands['-b']: dict = self.commands['build'] - self.commands['-i']: dict = self.commands['install'] - self.commands['-d']: dict = self.commands['download'] - self.commands['-R']: dict = self.commands['remove'] - self.commands['-f']: dict = self.commands['find'] - self.commands['-w']: dict = self.commands['view'] - self.commands['-s']: dict = self.commands['search'] - self.commands['-e']: dict = self.commands['dependees'] - self.commands['-t']: dict = self.commands['tracking'] + self.commands['-h'] = self.commands['--help'] + self.commands['-v'] = self.commands['--version'] + self.commands['-u'] = self.commands['update'] + self.commands['-U'] = self.commands['upgrade'] + self.commands['-c'] = self.commands['check-updates'] + self.commands['-g'] = self.commands['configs'] + self.commands['-L'] = self.commands['clean-logs'] + self.commands['-D'] = self.commands['clean-tmp'] + self.commands['-b'] = self.commands['build'] + self.commands['-i'] = self.commands['install'] + self.commands['-d'] = self.commands['download'] + self.commands['-R'] = self.commands['remove'] + self.commands['-f'] = self.commands['find'] + self.commands['-w'] = self.commands['view'] + self.commands['-s'] = self.commands['search'] + self.commands['-e'] = self.commands['dependees'] + self.commands['-t'] = self.commands['tracking'] self.split_options() self.split_options_from_args() @@ -258,19 +258,19 @@ class Argparse(Configs): for arg in self.args: if arg.startswith(self.flag_directory): self.directory = arg.split('=')[1] - self.args[self.args.index(arg)]: list = self.flag_directory + self.args[self.args.index(arg)] = self.flag_directory if arg.startswith(self.flag_short_directory): self.directory = arg.split('=')[1] - self.args[self.args.index(arg)]: list = self.flag_short_directory + self.args[self.args.index(arg)] = self.flag_short_directory if arg.startswith(self.flag_file_pattern): self.file_pattern = arg.split('=')[1] - self.args[self.args.index(arg)]: list = self.flag_file_pattern + self.args[self.args.index(arg)] = self.flag_file_pattern if arg.startswith(self.flag_short_file_pattern): self.file_pattern = arg.split('=')[1] - self.args[self.args.index(arg)]: list = self.flag_short_file_pattern + self.args[self.args.index(arg)] = self.flag_short_file_pattern def move_options(self) -> None: """ Move options to the flags and removes from the arguments. """ @@ -310,7 +310,7 @@ class Argparse(Configs): if method == 'find' and self.file_pattern: pattern: str = self.file_pattern - installed: list = self.utils.all_installed(pattern) + installed: list = list(self.utils.all_installed(pattern)) if method in ['remove', 'find']: diff --git a/slpkg/queries.py b/slpkg/queries.py index c1c1fd0b..3b495ab6 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -23,13 +23,13 @@ class SBoQueries(Configs): def sbos(self) -> list: """ Returns all the slackbuilds. """ - sbos: tuple = self.session.query(SBoTable.name).all() + sbos: tuple = self.session.query(SBoTable.name).all() # type: ignore return [sbo[0] for sbo in sbos] def slackbuild(self) -> str: """ Returns a slackbuild. """ sbo: tuple = self.session.query( - SBoTable.name).filter(SBoTable.name == self.name).first() + SBoTable.name).filter(SBoTable.name == self.name).first() # type: ignore if sbo: return sbo[0] @@ -38,7 +38,7 @@ class SBoQueries(Configs): def location(self) -> str: """ Returns the category of a slackbuild. """ location: tuple = self.session.query( - SBoTable.location).filter(SBoTable.name == self.name).first() + SBoTable.location).filter(SBoTable.name == self.name).first() # type: ignore if location: return location[0] @@ -47,7 +47,7 @@ class SBoQueries(Configs): def sources(self) -> list: """ Returns the source of a slackbuild. """ source, source64 = self.session.query( - SBoTable.download, SBoTable.download64).filter( + SBoTable.download, SBoTable.download64).filter( # type: ignore SBoTable.name == self.name).first() if self.os_arch == 'x86_64' and source64: @@ -57,8 +57,8 @@ class SBoQueries(Configs): def requires(self) -> Union[str, list]: """ Returns the requirements of a slackbuild. """ - requires: tuple = self.session.query( - SBoTable.requires).filter( + requires: tuple = self.session.query( # type: ignore + SBoTable.requires).filter( # type: ignore SBoTable.name == self.name).first() if requires: @@ -72,7 +72,7 @@ class SBoQueries(Configs): def version(self) -> str: """ Returns the version of a slackbuild. """ version: tuple = self.session.query( - SBoTable.version).filter( + SBoTable.version).filter( # type: ignore SBoTable.name == self.name).first() if version: @@ -82,7 +82,7 @@ class SBoQueries(Configs): def checksum(self) -> list: """ Returns the source checksum. """ mds5, md5s64 = self.session.query( - SBoTable.md5sum, SBoTable.md5sum64).filter( + SBoTable.md5sum, SBoTable.md5sum64).filter( # type: ignore SBoTable.name == self.name).first() if self.os_arch == 'x86_64' and md5s64: @@ -93,7 +93,7 @@ class SBoQueries(Configs): def description(self) -> str: """ Returns the slackbuild description. """ desc: tuple = self.session.query( - SBoTable.short_description).filter( + SBoTable.short_description).filter( # type: ignore SBoTable.name == self.name).first() if desc: @@ -103,7 +103,7 @@ class SBoQueries(Configs): def files(self) -> str: """ Returns the files of a slackbuild. """ files: tuple = self.session.query( - SBoTable.files).filter( + SBoTable.files).filter( # type: ignore SBoTable.name == self.name).first() if files: diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index cd3cef7b..d7ead076 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -107,8 +107,8 @@ class RemovePackages(Configs): if not p1.is_alive(): if p1.exitcode != 0: - done = f' {self.bred} Failed{self.endc}' - self.output = p1.exitcode + done: str = f' {self.bred} Failed{self.endc}' + self.output: int = p1.exitcode # type: ignore print(f'{self.endc}{done}', end='') p2.terminate() diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 7adf831a..ee62ca2d 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -6,6 +6,7 @@ import time import subprocess from pathlib import Path +from typing import Literal from collections import OrderedDict from multiprocessing import Process, cpu_count @@ -45,7 +46,7 @@ class Slackbuilds(Configs): self.output: int = 0 self.stderr = None self.stdout = None - self.process_message = None + self.process_message: str = '' self.bold: str = self.color['bold'] self.cyan: str = self.color['cyan'] self.red: str = self.color['red'] @@ -122,7 +123,7 @@ class Slackbuilds(Configs): self.view_message.question() - def is_for_skipped(self, sbo) -> None: + def is_for_skipped(self, sbo) -> Literal[True]: """ Condition to check if slackbuild is for skipped. """ return (not self.utils.is_installed(sbo, self.file_pattern) or self.utils.is_package_upgradeable(sbo, self.file_pattern) or @@ -194,7 +195,7 @@ class Slackbuilds(Configs): def logging_installed_dependencies(self, name: str) -> None: """ Logging installed dependencies and used for remove. """ - exist = self.session.query(LogsDependencies.name).filter( + exist = self.session.query(LogsDependencies.name).filter( # type: ignore LogsDependencies.name == name).first() requires: list = Requires(name).resolve() @@ -302,7 +303,7 @@ class Slackbuilds(Configs): if p1.exitcode != 0: done: str = f' {self.bred} Failed{self.endc}' - self.output = p1.exitcode + self.output: int = p1.exitcode # type: ignore print(f'{self.endc}{done}', end='') p2.terminate() diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index d29d6c42..a53bb382 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -26,7 +26,7 @@ class Upgrade(Configs, Utilities): black: list = self.black.packages() upgrade, requires = [], [] - installed: list = self.all_installed(self.file_pattern) + installed: list = list(self.all_installed(self.file_pattern)) for pkg in installed: inst_pkg_name: str = self.split_installed_pkg(pkg)[0] diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 87cc212d..4e0995f4 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -5,6 +5,7 @@ import time import shutil import tarfile from pathlib import Path +from typing import Generator, Any from distutils.version import LooseVersion from slpkg.configs import Configs @@ -36,7 +37,7 @@ class Utilities: return '' - def all_installed(self, pattern: str) -> list: + def all_installed(self, pattern: str) -> Generator: """ Return all installed SBo packages from /val/log/packages folder. """ var_log_packages = Path(self.configs.log_packages) @@ -91,7 +92,7 @@ class Utilities: time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]', time.gmtime(elapsed_time))) - def is_package_upgradeable(self, package: str, file_pattern: str) -> bool: + def is_package_upgradeable(self, package: str, file_pattern: str) -> Any: """ Checks if the package is installed and if it is upgradeable, returns true. """ installed = self.is_installed(package, file_pattern) if installed: @@ -101,6 +102,6 @@ class Utilities: return LooseVersion(repository_version) > LooseVersion(installed_version) @staticmethod - def is_option(flag: list, flags: list) -> True: + def is_option(flag: list, flags: list) -> Any: """ Checking for flags. """ return [f for f in flag if f in flags] diff --git a/slpkg/views/help_commands.py b/slpkg/views/help_commands.py index c76cd38d..a940d2c8 100644 --- a/slpkg/views/help_commands.py +++ b/slpkg/views/help_commands.py @@ -44,21 +44,21 @@ class Help(Configs): 'tracking': "Tracking the packages dependencies." } - help_commands['-u']: dict = help_commands['update'] - help_commands['-U']: dict = help_commands['upgrade'] - help_commands['-c']: dict = help_commands['check-updates'] - help_commands['-g']: dict = help_commands['configs'] - help_commands['-L']: dict = help_commands['clean-logs'] - help_commands['-D']: dict = help_commands['clean-tmp'] - help_commands['-b']: dict = help_commands['build'] - help_commands['-i']: dict = help_commands['install'] - help_commands['-d']: dict = help_commands['download'] - help_commands['-r']: dict = help_commands['remove'] - help_commands['-f']: dict = help_commands['find'] - help_commands['-w']: dict = help_commands['view'] - help_commands['-s']: dict = help_commands['search'] - help_commands['-e']: dict = help_commands['dependees'] - help_commands['-t']: dict = help_commands['tracking'] + help_commands['-u'] = help_commands['update'] + help_commands['-U'] = help_commands['upgrade'] + help_commands['-c'] = help_commands['check-updates'] + help_commands['-g'] = help_commands['configs'] + help_commands['-L'] = help_commands['clean-logs'] + help_commands['-D'] = help_commands['clean-tmp'] + help_commands['-b'] = help_commands['build'] + help_commands['-i'] = help_commands['install'] + help_commands['-d'] = help_commands['download'] + help_commands['-r'] = help_commands['remove'] + help_commands['-f'] = help_commands['find'] + help_commands['-w'] = help_commands['view'] + help_commands['-s'] = help_commands['search'] + help_commands['-e'] = help_commands['dependees'] + help_commands['-t'] = help_commands['tracking'] print(f'\n{self.bold}{self.green}Help: {self.endc}{help_commands[self.command]}\n') print(f"{self.bold}COMMAND{self.endc}: {self.cyan}{self.command}{self.endc}") diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 9db86c79..b2a0485c 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -34,16 +34,16 @@ class ViewPackage(Configs, Utilities): for package in packages: info: list = self.session.query( - SBoTable.name, - SBoTable.version, - SBoTable.requires, - SBoTable.download, - SBoTable.download64, - SBoTable.md5sum, - SBoTable.md5sum64, - SBoTable.files, - SBoTable.short_description, - SBoTable.location + SBoTable.name, # type: ignore + SBoTable.version, # type: ignore + SBoTable.requires, # type: ignore + SBoTable.download, # type: ignore + SBoTable.download64, # type: ignore + SBoTable.md5sum, # type: ignore + SBoTable.md5sum64, # type: ignore + SBoTable.files, # type: ignore + SBoTable.short_description, # type: ignore + SBoTable.location # type: ignore ).filter(SBoTable.name == package).first() readme = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/README') @@ -51,7 +51,7 @@ class ViewPackage(Configs, Utilities): info_file = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/{info[0]}.info') maintainer, email, homepage = '', '', '' - for line in info_file.data.decode().splitlines(): + for line in info_file.data.decode().splitlines(): # type: ignore if line.startswith('HOMEPAGE'): homepage: str = line[10:-1].strip() if line.startswith('MAINTAINER'): @@ -82,7 +82,7 @@ class ViewPackage(Configs, Utilities): f'SBo url: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}{endc}\n' f'Maintainer: {yellow}{maintainer}{endc}\n' f'Email: {yellow}{email}{endc}\n' - f'\nREADME: {cyan}{readme.data.decode()}{endc}') + f'\nREADME: {cyan}{readme.data.decode()}{endc}') # type: ignore @staticmethod def http_request(link: str) -> str: From c8628861710fbf46faeb9774cc8aa653de525779 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:03:25 +0200 Subject: [PATCH 06/13] Fixed for type --- slpkg/remove_packages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index d7ead076..63df9f80 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -84,7 +84,7 @@ class RemovePackages(Configs): LogsDependencies.name == pkg).delete() self.session.commit() - def multi_process(self, command: str, package: str) -> None: + def multi_process(self, command: str, package: str): """ Starting multiprocessing remove process. """ if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags): From 99d86730cf7f84a6486d0c4922f5486462992301 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:05:14 +0200 Subject: [PATCH 07/13] Fixed ignore type --- slpkg/blacklist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 154a68a0..42c118b0 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -22,7 +22,7 @@ class Blacklist(Configs): file_toml = Path(self.etc_path, 'blacklist.toml') if self.ponce_repo: - sbos: list = self.session.query(PonceTable.name).all() + sbos: list = self.session.query(PonceTable.name).all() # type: ignore ponce_blacks: list = [sbo[0] for sbo in sbos] if file_toml.is_file(): From 2b590c5ab2298da695529cc76db6ce930b457c4b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:08:06 +0200 Subject: [PATCH 08/13] Fixed type --- slpkg/models/models.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/slpkg/models/models.py b/slpkg/models/models.py index c60e98f4..799cd193 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -25,25 +25,25 @@ class SBoTable(Base): __tablename__ = 'sbotable' - id: int = Column(Integer, primary_key=True) - name: str = Column(Text) - location: str = Column(Text) - files: str = Column(Text) - version: str = Column(Text) - download: str = Column(Text) - download64: str = Column(Text) - md5sum: str = Column(Text) - md5sum64: str = Column(Text) - requires: str = Column(Text) - short_description: str = Column(Text) + id: int = Column(Integer, primary_key=True) # type: ignore + name: str = Column(Text) # type: ignore + location: str = Column(Text) # type: ignore + files: str = Column(Text) # type: ignore + version: str = Column(Text) # type: ignore + download: str = Column(Text) # type: ignore + download64: str = Column(Text) # type: ignore + md5sum: str = Column(Text) # type: ignore + md5sum64: str = Column(Text) # type: ignore + requires: str = Column(Text) # type: ignore + short_description: str = Column(Text) # type: ignore class PonceTable(Base): __tablename__ = 'poncetable' - id: int = Column(Integer, primary_key=True) - name: str = Column(Text) + id: int = Column(Integer, primary_key=True) # type: ignore + name: str = Column(Text) # type: ignore @dataclass @@ -52,9 +52,9 @@ class LogsDependencies(Base): __tablename__ = 'logsdependencies' - id: int = Column(Integer, primary_key=True) - name: str = Column(Text) - requires: str = Column(Text) + id: int = Column(Integer, primary_key=True) # type: ignore + name: str = Column(Text) # type: ignore + requires: str = Column(Text) # type: ignore Base.metadata.create_all(engine) From ea4c2c162261dead1e04a51d0da795f5d692210c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:09:38 +0200 Subject: [PATCH 09/13] Updated changelog --- ChangeLog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 763505d7..edc5bc6f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +4.5.5 - 02/03/2023 +Fixed: +- Genarator type to list return + 4.5.4 - 05/02/2023 Updated: - Message for configs From d57971cb4bf5099fb2bc949d0c1d70771bda5138 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 2 Mar 2023 23:11:34 +0200 Subject: [PATCH 10/13] Updated for version 4.5.5 --- 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 19cccfc1..c20e388b 100644 --- a/README.rst +++ b/README.rst @@ -31,8 +31,8 @@ Install from the official third-party `SBo repository Date: Thu, 2 Mar 2023 23:34:42 +0200 Subject: [PATCH 11/13] Updated for code style --- slpkg/downloader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slpkg/downloader.py b/slpkg/downloader.py index d5747ada..733e38ed 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -80,9 +80,11 @@ class Downloader(Configs, Utilities): def check_if_downloaded(self) -> None: """ Checks if the file downloaded. """ if 'ponce' not in self.url: + url: str = unquote(self.url) file: str = url.split('/')[-1] path_file = Path(self.path, file) + if not path_file.exists(): raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' " f"to download.\n") From 49317a628dc79cf76e53ab6ba2fe169142d35652 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 3 Mar 2023 08:05:20 +0200 Subject: [PATCH 12/13] Renamed method --- slpkg/checks.py | 2 +- slpkg/main.py | 2 +- slpkg/slackbuild.py | 10 +++++----- slpkg/utilities.py | 4 ++-- slpkg/views/views.py | 4 ++-- tests/test_utilities.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/slpkg/checks.py b/slpkg/checks.py index 4407fe79..51835ed7 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -43,7 +43,7 @@ class Check(Configs, Utilities): found, not_found = [], [] for sbo in slackbuilds: - package: str = self.is_installed(sbo, file_pattern) + package: str = self.is_package_installed(sbo, file_pattern) if package: pkg: str = self.split_installed_pkg(package)[0] found.append(pkg) diff --git a/slpkg/main.py b/slpkg/main.py index 9fc695fa..2cd1b00d 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -328,7 +328,7 @@ class Argparse(Configs): if pkg == package: repo_ver: str = SBoQueries(package).version() - inst_pkg: str = self.utils.is_installed(package, self.file_pattern) + inst_pkg: str = self.utils.is_package_installed(package, self.file_pattern) inst_ver: str = self.utils.split_installed_pkg(inst_pkg)[1] choices += [(package, f'{inst_ver} -> {repo_ver}', True)] diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index ee62ca2d..b45ca887 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -90,7 +90,7 @@ class Slackbuilds(Configs): # Checks if the package was installed and skipped. if (self.utils.is_option(self.flag_skip_installed, self.flags) and - self.utils.is_installed(dep, self.file_pattern)): + self.utils.is_package_installed(dep, self.file_pattern)): continue self.dependencies.append(dep) @@ -125,7 +125,7 @@ class Slackbuilds(Configs): def is_for_skipped(self, sbo) -> Literal[True]: """ Condition to check if slackbuild is for skipped. """ - return (not self.utils.is_installed(sbo, self.file_pattern) or + return (not self.utils.is_package_installed(sbo, self.file_pattern) or self.utils.is_package_upgradeable(sbo, self.file_pattern) or self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags)) @@ -175,7 +175,7 @@ class Slackbuilds(Configs): if not self.utils.is_option(self.flag_resolve_off, self.flags): self.logging_installed_dependencies(sbo) else: - package: str = self.utils.is_installed(sbo, self.file_pattern) + package: str = self.utils.is_package_installed(sbo, self.file_pattern) version: str = self.utils.split_installed_pkg(package)[1] self.view_message.view_skipping_packages(sbo, version) @@ -218,7 +218,7 @@ class Slackbuilds(Configs): execute: str = self.installpkg if (self.utils.is_option(self.flag_reinstall, self.flags) and - self.utils.is_installed(pkg, self.file_pattern)): + self.utils.is_package_installed(pkg, self.file_pattern)): execute: str = self.reinstall message: str = f'{self.cyan}Installing{self.endc}' @@ -346,7 +346,7 @@ class Slackbuilds(Configs): if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package, self.file_pattern): status: bool = True - if self.mode == 'install' and not self.utils.is_installed(package, self.file_pattern): + if self.mode == 'install' and not self.utils.is_package_installed(package, self.file_pattern): status: bool = True if self.mode == 'install' and self.utils.is_package_upgradeable(package, self.file_pattern): diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 4e0995f4..4f9779fb 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -25,7 +25,7 @@ class Utilities: self.cyan: str = self.color['cyan'] self.endc: str = self.color['endc'] - def is_installed(self, name: str, pattern: str) -> str: + def is_package_installed(self, name: str, pattern: str) -> str: """ Returns the installed package name. """ installed: list = list(self.all_installed(pattern)) @@ -94,7 +94,7 @@ class Utilities: def is_package_upgradeable(self, package: str, file_pattern: str) -> Any: """ Checks if the package is installed and if it is upgradeable, returns true. """ - installed = self.is_installed(package, file_pattern) + installed = self.is_package_installed(package, file_pattern) if installed: installed_version = self.split_installed_pkg(installed)[1] repository_version = SBoQueries(package).version() diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 9a27a13d..388ed18e 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -153,7 +153,7 @@ class ViewMessage(Configs): """ View and creates list with packages for remove. """ installed = self.utils.all_installed(self.file_pattern) - if self.utils.is_installed(name, self.file_pattern): + if self.utils.is_package_installed(name, self.file_pattern): for package in installed: pkg: str = self.utils.split_installed_pkg(package)[0] if pkg == name: @@ -189,7 +189,7 @@ class ViewMessage(Configs): install = upgrade = remove = 0 for sbo in slackbuilds: - installed: str = self.utils.is_installed(sbo, self.file_pattern) + installed: str = self.utils.is_package_installed(sbo, self.file_pattern) if not installed: install += 1 diff --git a/tests/test_utilities.py b/tests/test_utilities.py index c6ff853e..f592c8fa 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -13,7 +13,7 @@ class TestUtilities(unittest.TestCase): self.package = 'fish-3.6.0-x86_64-1_SBo' def test_ins_installed(self): - self.assertEqual(self.package, self.utils.is_installed('fish', self.file_pattern)) + self.assertEqual(self.package, self.utils.is_package_installed('fish', self.file_pattern)) def test_split_name(self): self.assertEqual('fish', self.utils.split_installed_pkg(self.package)[0]) From 43341cab90369009a55c5878b562fabcec31c2d9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 3 Mar 2023 17:26:38 +0200 Subject: [PATCH 13/13] Updated for coding style --- slpkg/dependees.py | 2 +- slpkg/dependencies.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 38c3edf9..00d77177 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -79,7 +79,7 @@ class Dependees(Configs, Utilities): def find_requires(self, sbo: str) -> Generator[str, None, None]: """ Find requires that slackbuild dependees. """ - requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() # type: ignore + requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() # type: ignore for req in requires: if [r for r in req[1].split() if r == sbo]: yield req diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py index 3c0fe374..c83d958b 100644 --- a/slpkg/dependencies.py +++ b/slpkg/dependencies.py @@ -13,10 +13,10 @@ class Requires: def resolve(self) -> list: """ Resolve the dependencies. """ - requires: list[str] = SBoQueries(self.name).requires() # type: ignore + requires: list[str] = SBoQueries(self.name).requires() # type: ignore for req in requires: if req: - sub: list[str] = SBoQueries(req).requires() # type: ignore + sub: list[str] = SBoQueries(req).requires() # type: ignore for s in sub: requires.append(s)