Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2023-03-03 17:27:24 +02:00
commit f775a31fc9
25 changed files with 166 additions and 163 deletions

View file

@ -1,3 +1,7 @@
4.5.5 - 02/03/2023
Fixed:
- Genarator type to list return
4.5.4 - 05/02/2023 4.5.4 - 05/02/2023
Updated: Updated:
- Message for configs - Message for configs

View file

@ -31,8 +31,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-4.5.4.tar.gz $ tar xvf slpkg-4.5.5.tar.gz
$ cd slpkg-4.5.4 $ cd slpkg-4.5.5
$ ./install.sh $ ./install.sh
Screenshots Screenshots
@ -115,7 +115,7 @@ Repositories
Two repositories are supported, please read the config file. Two repositories are supported, please read the config file.
- `slackbuilds.org <https://slackbuilds.org>`_ repository - `slackbuilds <https://slackbuilds.org>`_ repository
- `ponce <https://cgit.ponce.cc/slackbuilds/>`_ repository - `ponce <https://cgit.ponce.cc/slackbuilds/>`_ repository

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = slpkg name = slpkg
version = 4.5.4 version = 4.5.5
license_file = LICENSE license_file = LICENSE
author = Dimitris Zlatanidis author = Dimitris Zlatanidis
author_email = d.zlatanidis@gmail.com author_email = d.zlatanidis@gmail.com

View file

@ -22,7 +22,7 @@ class Blacklist(Configs):
file_toml = Path(self.etc_path, 'blacklist.toml') file_toml = Path(self.etc_path, 'blacklist.toml')
if self.ponce_repo: 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] ponce_blacks: list = [sbo[0] for sbo in sbos]
if file_toml.is_file(): if file_toml.is_file():

View file

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pathlib import Path from pathlib import Path
from typing import NoReturn
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.queries import SBoQueries from slpkg.queries import SBoQueries
@ -18,7 +17,7 @@ class Check(Configs, Utilities):
super(Utilities, self).__init__() super(Utilities, self).__init__()
@staticmethod @staticmethod
def exists(slackbuilds: list) -> NoReturn: def exists(slackbuilds: list) -> None:
""" Checking if the slackbuild exists in the repository. """ """ Checking if the slackbuild exists in the repository. """
not_packages: list = [] not_packages: list = []
@ -31,7 +30,7 @@ class Check(Configs, Utilities):
'does not exists.\n') 'does not exists.\n')
@staticmethod @staticmethod
def unsupported(slackbuilds: list) -> NoReturn: def unsupported(slackbuilds: list) -> None:
""" Checking for unsupported slackbuilds. """ """ Checking for unsupported slackbuilds. """
for sbo in slackbuilds: for sbo in slackbuilds:
sources = SBoQueries(sbo).sources() sources = SBoQueries(sbo).sources()
@ -44,7 +43,7 @@ class Check(Configs, Utilities):
found, not_found = [], [] found, not_found = [], []
for sbo in slackbuilds: for sbo in slackbuilds:
package: str = self.is_installed(sbo, file_pattern) package: str = self.is_package_installed(sbo, file_pattern)
if package: if package:
pkg: str = self.split_installed_pkg(package)[0] pkg: str = self.split_installed_pkg(package)[0]
found.append(pkg) found.append(pkg)
@ -57,7 +56,7 @@ class Check(Configs, Utilities):
return found return found
def blacklist(self, slackbuilds: list) -> NoReturn: def blacklist(self, slackbuilds: list) -> None:
""" Checking if the packages are blacklisted. """ """ Checking if the packages are blacklisted. """
packages: list = [] packages: list = []
black = Blacklist() black = Blacklist()
@ -70,9 +69,9 @@ class Check(Configs, Utilities):
raise SystemExit( raise SystemExit(
f'\nThe packages \'{", ".join(packages)}\' is blacklisted.\n' f'\nThe packages \'{", ".join(packages)}\' is blacklisted.\n'
f'Please edit the blacklist.toml file in ' f'Please edit the blacklist.toml file in '
f'{self.configs.etc_path} folder.\n') f'{self.etc_path} folder.\n')
def database(self) -> NoReturn: def database(self) -> None:
""" Checking for empty table """ """ Checking for empty table """
db = Path(self.db_path, self.database_name) db = Path(self.db_path, self.database_name)
if not SBoQueries('').sbos() or not db.is_file(): if not SBoQueries('').sbos() or not db.is_file():

View file

@ -16,7 +16,7 @@ class CleanLogsDependencies:
def clean(self) -> None: def clean(self) -> None:
""" Deletes the log table from the database. """ """ Deletes the log table from the database. """
dependencies: list = self.session.query( dependencies: list = self.session.query(
LogsDependencies.name, LogsDependencies.requires).all() LogsDependencies.name, LogsDependencies.requires).all() # type: ignore
if dependencies: if dependencies:
view = ViewMessage(self.flags) view = ViewMessage(self.flags)

View file

@ -11,7 +11,7 @@ from dataclasses import dataclass
class LoadConfigs: class LoadConfigs:
@staticmethod @staticmethod
def file(path: str, file: str) -> dict: def file(path: str, file: str) -> dict: # type: ignore
try: try:
""" Load the configs from the file. """ """ Load the configs from the file. """
config_path_file = Path(path, f'{file}.toml') config_path_file = Path(path, f'{file}.toml')
@ -35,14 +35,14 @@ class Configs:
# All necessary paths. # All necessary paths.
tmp_path: str = '/tmp/' tmp_path: str = '/tmp/'
tmp_slpkg: str = Path(tmp_path, prog_name) tmp_slpkg: str = Path(tmp_path, prog_name) # type: ignore
build_path: str = Path('tmp', prog_name, 'build') build_path: str = Path('tmp', prog_name, 'build') # type: ignore
download_only_path: str = Path(tmp_slpkg, '') download_only_path: str = Path(tmp_slpkg, '') # type: ignore
lib_path: str = Path('/var/lib/', prog_name) lib_path: str = Path('/var/lib/', prog_name) # type: ignore
etc_path: str = Path('/etc/', prog_name) etc_path: str = Path('/etc/', prog_name) # type: ignore
db_path: str = Path(lib_path, 'database') db_path: str = Path(lib_path, 'database') # type: ignore
sbo_repo_path: str = Path(lib_path, 'repository') sbo_repo_path: str = Path(lib_path, 'repository') # type: ignore
log_packages: str = Path('/var', 'log', 'packages') log_packages: str = Path('/var', 'log', 'packages') # type: ignore
# Database name. # Database name.
database_name: str = f'database.{prog_name}' database_name: str = f'database.{prog_name}'
@ -59,7 +59,7 @@ class Configs:
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/' slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/'
slack_chglog_txt: str = 'ChangeLog.txt' 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. # Slackware commands.
installpkg: str = 'upgradepkg --install-new' installpkg: str = 'upgradepkg --install-new'
@ -70,7 +70,7 @@ class Configs:
colors: bool = True colors: bool = True
# Dialog utility. # Dialog utility.
dialog: bool = True dialog: bool = True # type: ignore
# Downloader command. Wget and curl. # Downloader command. Wget and curl.
downloader: str = 'wget' downloader: str = 'wget'

View file

@ -79,7 +79,7 @@ class Dependees(Configs, Utilities):
def find_requires(self, sbo: str) -> Generator[str, None, None]: def find_requires(self, sbo: str) -> Generator[str, None, None]:
""" Find requires that slackbuild dependees. """ """ 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: for req in requires:
if [r for r in req[1].split() if r == sbo]: if [r for r in req[1].split() if r == sbo]:
yield req yield req

View file

@ -13,11 +13,10 @@ class Requires:
def resolve(self) -> list: def resolve(self) -> list:
""" Resolve the dependencies. """ """ Resolve the dependencies. """
requires = SBoQueries(self.name).requires() requires: list[str] = SBoQueries(self.name).requires() # type: ignore
for req in requires: for req in requires:
if req: if req:
sub = SBoQueries(req).requires() sub: list[str] = SBoQueries(req).requires() # type: ignore
for s in sub: for s in sub:
requires.append(s) requires.append(s)

View file

@ -25,7 +25,7 @@ class DialogBox(Configs):
list_height: int, choices: list, packages: list): list_height: int, choices: list, packages: list):
""" Display a checklist box. """ """ Display a checklist box. """
if self.dialog: 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) list_height=list_height, choices=choices)
else: else:
code: bool = False code: bool = False
@ -36,7 +36,7 @@ class DialogBox(Configs):
def mixedform(self, text: str, title: str, elements: list, height: int, width: int): def mixedform(self, text: str, title: str, elements: list, height: int, width: int):
""" Display a mixedform box. """ """ Display a mixedform box. """
if self.dialog: 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) height=height, width=width, help_button=True)
else: else:
code: bool = False code: bool = False

View file

@ -5,7 +5,7 @@ import os
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from urllib.parse import unquote from urllib.parse import unquote
from typing import Union, NoReturn from typing import Union
from multiprocessing import Process from multiprocessing import Process
from slpkg.configs import Configs from slpkg.configs import Configs
@ -19,14 +19,14 @@ class Downloader(Configs, Utilities):
def __init__(self, path: Union[str, Path], url: str, flags: list): def __init__(self, path: Union[str, Path], url: str, flags: list):
super(Configs, self).__init__() super(Configs, self).__init__()
super(Utilities, self).__init__() super(Utilities, self).__init__()
self.path: str = path self.path = path
self.url: str = url self.url: str = url
self.flags: list = flags self.flags: list = flags
self.color = self.colour() self.color = self.colour()
self.progress = ProgressBar() self.progress = ProgressBar()
self.output: int = 0 self.output = 0
self.stderr = None self.stderr = None
self.stdout = None self.stdout = None
@ -41,7 +41,7 @@ class Downloader(Configs, Utilities):
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_no_silent: list = ['-n', '--no-silent']
def transfer_tools(self) -> NoReturn: def transfer_tools(self) -> None:
""" Downloader tools. """ Downloader tools.
wget, curl and lftp works with SBo repository. wget, curl and lftp works with SBo repository.
@ -77,12 +77,14 @@ class Downloader(Configs, Utilities):
if self.output != 0: if self.output != 0:
raise SystemExit(self.output) raise SystemExit(self.output)
def check_if_downloaded(self) -> NoReturn: def check_if_downloaded(self) -> None:
""" Checks if the file downloaded. """ """ Checks if the file downloaded. """
if 'ponce' not in self.url: if 'ponce' not in self.url:
url: str = unquote(self.url) url: str = unquote(self.url)
file: str = url.split('/')[-1] file: str = url.split('/')[-1]
path_file = Path(self.path, file) path_file = Path(self.path, file)
if not path_file.exists(): if not path_file.exists():
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' " raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
f"to download.\n") f"to download.\n")

View file

@ -24,7 +24,7 @@ class FindInstalled(Configs, Utilities):
""" Find the packages. """ """ Find the packages. """
matching: list = [] matching: list = []
installed: list = self.all_installed(pattern) installed: list = list(self.all_installed(pattern))
print(f'The list below shows the installed packages ' print(f'The list below shows the installed packages '
f'that contains \'{", ".join([p for p in packages])}\' files:\n') f'that contains \'{", ".join([p for p in packages])}\' files:\n')

View file

@ -16,7 +16,7 @@ class FormConfigs(Configs):
self.load_configs = LoadConfigs() self.load_configs = LoadConfigs()
self.dialogbox = DialogBox() self.dialogbox = DialogBox()
self.orig_configs = None self.orig_configs: list = []
self.config_file = Path(self.etc_path, f'{self.prog_name}.toml') self.config_file = Path(self.etc_path, f'{self.prog_name}.toml')
def edit(self) -> None: def edit(self) -> None:

View file

@ -3,7 +3,6 @@
import os import os
import sys import sys
from typing import NoReturn
from slpkg.checks import Check from slpkg.checks import Check
from slpkg.upgrade import Upgrade from slpkg.upgrade import Upgrade
@ -33,7 +32,7 @@ class Argparse(Configs):
def __init__(self, args: list): def __init__(self, args: list):
self.args: list = args self.args: list = args
self.flags: list = [] self.flags: list = []
self.directory = None self.directory = self.tmp_slpkg
self.file_pattern: str = f'*{self.sbo_repo_tag}' self.file_pattern: str = f'*{self.sbo_repo_tag}'
self.dialogbox = DialogBox() self.dialogbox = DialogBox()
self.utils = Utilities() self.utils = Utilities()
@ -208,23 +207,23 @@ class Argparse(Configs):
] ]
} }
self.commands['-h']: dict = self.commands['--help'] self.commands['-h'] = self.commands['--help']
self.commands['-v']: dict = self.commands['--version'] self.commands['-v'] = self.commands['--version']
self.commands['-u']: dict = self.commands['update'] self.commands['-u'] = self.commands['update']
self.commands['-U']: dict = self.commands['upgrade'] self.commands['-U'] = self.commands['upgrade']
self.commands['-c']: dict = self.commands['check-updates'] self.commands['-c'] = self.commands['check-updates']
self.commands['-g']: dict = self.commands['configs'] self.commands['-g'] = self.commands['configs']
self.commands['-L']: dict = self.commands['clean-logs'] self.commands['-L'] = self.commands['clean-logs']
self.commands['-D']: dict = self.commands['clean-tmp'] self.commands['-D'] = self.commands['clean-tmp']
self.commands['-b']: dict = self.commands['build'] self.commands['-b'] = self.commands['build']
self.commands['-i']: dict = self.commands['install'] self.commands['-i'] = self.commands['install']
self.commands['-d']: dict = self.commands['download'] self.commands['-d'] = self.commands['download']
self.commands['-R']: dict = self.commands['remove'] self.commands['-R'] = self.commands['remove']
self.commands['-f']: dict = self.commands['find'] self.commands['-f'] = self.commands['find']
self.commands['-w']: dict = self.commands['view'] self.commands['-w'] = self.commands['view']
self.commands['-s']: dict = self.commands['search'] self.commands['-s'] = self.commands['search']
self.commands['-e']: dict = self.commands['dependees'] self.commands['-e'] = self.commands['dependees']
self.commands['-t']: dict = self.commands['tracking'] self.commands['-t'] = self.commands['tracking']
self.split_options() self.split_options()
self.split_options_from_args() self.split_options_from_args()
@ -259,19 +258,19 @@ class Argparse(Configs):
for arg in self.args: for arg in self.args:
if arg.startswith(self.flag_directory): if arg.startswith(self.flag_directory):
self.directory = arg.split('=')[1] 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): if arg.startswith(self.flag_short_directory):
self.directory = arg.split('=')[1] 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): if arg.startswith(self.flag_file_pattern):
self.file_pattern = arg.split('=')[1] 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): if arg.startswith(self.flag_short_file_pattern):
self.file_pattern = arg.split('=')[1] 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: def move_options(self) -> None:
""" Move options to the flags and removes from the arguments. """ """ Move options to the flags and removes from the arguments. """
@ -280,7 +279,7 @@ class Argparse(Configs):
self.args.remove(opt) self.args.remove(opt)
self.flags.append(opt) self.flags.append(opt)
def is_dialog_enabled(self) -> NoReturn: def is_dialog_enabled(self) -> None:
""" Checking if the dialog box is enabled. """ """ Checking if the dialog box is enabled. """
if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or
not self.dialogbox.dialog and 'configs' in self.args): not self.dialogbox.dialog and 'configs' in self.args):
@ -311,7 +310,7 @@ class Argparse(Configs):
if method == 'find' and self.file_pattern: if method == 'find' and self.file_pattern:
pattern: str = 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']: if method in ['remove', 'find']:
@ -329,7 +328,7 @@ class Argparse(Configs):
if pkg == package: if pkg == package:
repo_ver: str = SBoQueries(package).version() 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] inst_ver: str = self.utils.split_installed_pkg(inst_pkg)[1]
choices += [(package, f'{inst_ver} -> {repo_ver}', True)] choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
@ -364,21 +363,21 @@ class Argparse(Configs):
self.usage.help(0) self.usage.help(0)
self.usage.help(1) self.usage.help(1)
def version(self) -> NoReturn: def version(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
version = Version() version = Version()
version.view() version.view()
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def update(self) -> NoReturn: def update(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
update = UpdateRepository(self.flags) update = UpdateRepository(self.flags)
update.repository() update.repository()
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def upgrade(self) -> NoReturn: def upgrade(self) -> None:
command = Argparse.upgrade.__name__ command = Argparse.upgrade.__name__
if len(self.args) == 1: if len(self.args) == 1:
@ -398,7 +397,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def check_updates(self) -> NoReturn: def check_updates(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
self.check.database() self.check.database()
@ -407,13 +406,13 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def edit_configs(self) -> NoReturn: def edit_configs(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
self.form_configs.edit() self.form_configs.edit()
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def clean_logs(self) -> NoReturn: def clean_logs(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
self.check.database() self.check.database()
@ -422,7 +421,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def clean_tmp(self) -> NoReturn: def clean_tmp(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
self.utils.remove_folder_if_exists(path=self.tmp_path, folder=self.prog_name) 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) self.usage.help(1)
def build(self) -> NoReturn: def build(self) -> None:
command = Argparse.build.__name__ command = Argparse.build.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -450,7 +449,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def install(self) -> NoReturn: def install(self) -> None:
command = Argparse.install.__name__ command = Argparse.install.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -468,7 +467,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def download(self) -> NoReturn: def download(self) -> None:
command = Argparse.download.__name__ command = Argparse.download.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -484,7 +483,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def remove(self) -> NoReturn: def remove(self) -> None:
command = Argparse.remove.__name__ command = Argparse.remove.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -501,7 +500,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def find(self) -> NoReturn: def find(self) -> None:
command = Argparse.find.__name__ command = Argparse.find.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -517,7 +516,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def view(self) -> NoReturn: def view(self) -> None:
command = Argparse.view.__name__ command = Argparse.view.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -534,7 +533,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def search(self) -> NoReturn: def search(self) -> None:
command = Argparse.search.__name__ command = Argparse.search.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -550,7 +549,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def dependees(self) -> NoReturn: def dependees(self) -> None:
command = Argparse.dependees.__name__ command = Argparse.dependees.__name__
if len(self.args) >= 2: if len(self.args) >= 2:
@ -567,7 +566,7 @@ class Argparse(Configs):
raise SystemExit() raise SystemExit()
self.usage.help(1) self.usage.help(1)
def tracking(self) -> NoReturn: def tracking(self) -> None:
command = Argparse.tracking.__name__ command = Argparse.tracking.__name__
if len(self.args) >= 2: if len(self.args) >= 2:

View file

@ -25,25 +25,25 @@ class SBoTable(Base):
__tablename__ = 'sbotable' __tablename__ = 'sbotable'
id: int = Column(Integer, primary_key=True) id: int = Column(Integer, primary_key=True) # type: ignore
name: str = Column(Text) name: str = Column(Text) # type: ignore
location: str = Column(Text) location: str = Column(Text) # type: ignore
files: str = Column(Text) files: str = Column(Text) # type: ignore
version: str = Column(Text) version: str = Column(Text) # type: ignore
download: str = Column(Text) download: str = Column(Text) # type: ignore
download64: str = Column(Text) download64: str = Column(Text) # type: ignore
md5sum: str = Column(Text) md5sum: str = Column(Text) # type: ignore
md5sum64: str = Column(Text) md5sum64: str = Column(Text) # type: ignore
requires: str = Column(Text) requires: str = Column(Text) # type: ignore
short_description: str = Column(Text) short_description: str = Column(Text) # type: ignore
class PonceTable(Base): class PonceTable(Base):
__tablename__ = 'poncetable' __tablename__ = 'poncetable'
id: int = Column(Integer, primary_key=True) id: int = Column(Integer, primary_key=True) # type: ignore
name: str = Column(Text) name: str = Column(Text) # type: ignore
@dataclass @dataclass
@ -52,9 +52,9 @@ class LogsDependencies(Base):
__tablename__ = 'logsdependencies' __tablename__ = 'logsdependencies'
id: int = Column(Integer, primary_key=True) id: int = Column(Integer, primary_key=True) # type: ignore
name: str = Column(Text) name: str = Column(Text) # type: ignore
requires: str = Column(Text) requires: str = Column(Text) # type: ignore
Base.metadata.create_all(engine) Base.metadata.create_all(engine)

View file

@ -23,13 +23,13 @@ class SBoQueries(Configs):
def sbos(self) -> list: def sbos(self) -> list:
""" Returns all the slackbuilds. """ """ 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] return [sbo[0] for sbo in sbos]
def slackbuild(self) -> str: def slackbuild(self) -> str:
""" Returns a slackbuild. """ """ Returns a slackbuild. """
sbo: tuple = self.session.query( 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: if sbo:
return sbo[0] return sbo[0]
@ -38,7 +38,7 @@ class SBoQueries(Configs):
def location(self) -> str: def location(self) -> str:
""" Returns the category of a slackbuild. """ """ Returns the category of a slackbuild. """
location: tuple = self.session.query( 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: if location:
return location[0] return location[0]
@ -47,7 +47,7 @@ class SBoQueries(Configs):
def sources(self) -> list: def sources(self) -> list:
""" Returns the source of a slackbuild. """ """ Returns the source of a slackbuild. """
source, source64 = self.session.query( source, source64 = self.session.query(
SBoTable.download, SBoTable.download64).filter( SBoTable.download, SBoTable.download64).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if self.os_arch == 'x86_64' and source64: if self.os_arch == 'x86_64' and source64:
@ -57,8 +57,8 @@ class SBoQueries(Configs):
def requires(self) -> Union[str, list]: def requires(self) -> Union[str, list]:
""" Returns the requirements of a slackbuild. """ """ Returns the requirements of a slackbuild. """
requires: tuple = self.session.query( requires: tuple = self.session.query( # type: ignore
SBoTable.requires).filter( SBoTable.requires).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if requires: if requires:
@ -72,7 +72,7 @@ class SBoQueries(Configs):
def version(self) -> str: def version(self) -> str:
""" Returns the version of a slackbuild. """ """ Returns the version of a slackbuild. """
version: tuple = self.session.query( version: tuple = self.session.query(
SBoTable.version).filter( SBoTable.version).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if version: if version:
@ -82,7 +82,7 @@ class SBoQueries(Configs):
def checksum(self) -> list: def checksum(self) -> list:
""" Returns the source checksum. """ """ Returns the source checksum. """
mds5, md5s64 = self.session.query( mds5, md5s64 = self.session.query(
SBoTable.md5sum, SBoTable.md5sum64).filter( SBoTable.md5sum, SBoTable.md5sum64).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if self.os_arch == 'x86_64' and md5s64: if self.os_arch == 'x86_64' and md5s64:
@ -93,7 +93,7 @@ class SBoQueries(Configs):
def description(self) -> str: def description(self) -> str:
""" Returns the slackbuild description. """ """ Returns the slackbuild description. """
desc: tuple = self.session.query( desc: tuple = self.session.query(
SBoTable.short_description).filter( SBoTable.short_description).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if desc: if desc:
@ -103,7 +103,7 @@ class SBoQueries(Configs):
def files(self) -> str: def files(self) -> str:
""" Returns the files of a slackbuild. """ """ Returns the files of a slackbuild. """
files: tuple = self.session.query( files: tuple = self.session.query(
SBoTable.files).filter( SBoTable.files).filter( # type: ignore
SBoTable.name == self.name).first() SBoTable.name == self.name).first()
if files: if files:

View file

@ -3,7 +3,6 @@
import time import time
import subprocess import subprocess
from typing import NoReturn
from multiprocessing import Process from multiprocessing import Process
from slpkg.configs import Configs from slpkg.configs import Configs
@ -85,7 +84,7 @@ class RemovePackages(Configs):
LogsDependencies.name == pkg).delete() LogsDependencies.name == pkg).delete()
self.session.commit() self.session.commit()
def multi_process(self, command: str, package: str) -> None: def multi_process(self, command: str, package: str):
""" Starting multiprocessing remove process. """ """ Starting multiprocessing remove process. """
if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags): if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags):
@ -108,8 +107,8 @@ class RemovePackages(Configs):
if not p1.is_alive(): if not p1.is_alive():
if p1.exitcode != 0: if p1.exitcode != 0:
done = f' {self.bred} Failed{self.endc}' 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='') print(f'{self.endc}{done}', end='')
p2.terminate() p2.terminate()
@ -124,14 +123,14 @@ class RemovePackages(Configs):
self.print_error() self.print_error()
def process(self, command: str) -> NoReturn: def process(self, command: str) -> None:
""" Processes execution. """ """ Processes execution. """
self.output = subprocess.call(command, shell=True, self.output = subprocess.call(command, shell=True,
stderr=self.stderr, stdout=self.stdout) stderr=self.stderr, stdout=self.stdout)
if self.output != 0: if self.output != 0:
raise SystemExit(self.output) raise SystemExit(self.output)
def print_error(self) -> NoReturn: def print_error(self) -> None:
""" Stop the process and print the error message. """ """ Stop the process and print the error message. """
if self.output != 0: if self.output != 0:
raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n") raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n")

View file

@ -4,9 +4,9 @@
import os import os
import time import time
import subprocess import subprocess
from typing import NoReturn
from pathlib import Path from pathlib import Path
from typing import Literal
from collections import OrderedDict from collections import OrderedDict
from multiprocessing import Process, cpu_count from multiprocessing import Process, cpu_count
@ -46,7 +46,7 @@ class Slackbuilds(Configs):
self.output: int = 0 self.output: int = 0
self.stderr = None self.stderr = None
self.stdout = None self.stdout = None
self.process_message = None self.process_message: str = ''
self.bold: str = self.color['bold'] self.bold: str = self.color['bold']
self.cyan: str = self.color['cyan'] self.cyan: str = self.color['cyan']
self.red: str = self.color['red'] self.red: str = self.color['red']
@ -90,7 +90,7 @@ class Slackbuilds(Configs):
# Checks if the package was installed and skipped. # Checks if the package was installed and skipped.
if (self.utils.is_option(self.flag_skip_installed, self.flags) and 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 continue
self.dependencies.append(dep) self.dependencies.append(dep)
@ -123,9 +123,9 @@ class Slackbuilds(Configs):
self.view_message.question() 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. """ """ 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.utils.is_package_upgradeable(sbo, self.file_pattern) or
self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags)) 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): if not self.utils.is_option(self.flag_resolve_off, self.flags):
self.logging_installed_dependencies(sbo) self.logging_installed_dependencies(sbo)
else: 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] version: str = self.utils.split_installed_pkg(package)[1]
self.view_message.view_skipping_packages(sbo, version) self.view_message.view_skipping_packages(sbo, version)
@ -195,7 +195,7 @@ class Slackbuilds(Configs):
def logging_installed_dependencies(self, name: str) -> None: def logging_installed_dependencies(self, name: str) -> None:
""" Logging installed dependencies and used for remove. """ """ 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() LogsDependencies.name == name).first()
requires: list = Requires(name).resolve() requires: list = Requires(name).resolve()
@ -218,7 +218,7 @@ class Slackbuilds(Configs):
execute: str = self.installpkg execute: str = self.installpkg
if (self.utils.is_option(self.flag_reinstall, self.flags) and 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 execute: str = self.reinstall
message: str = f'{self.cyan}Installing{self.endc}' message: str = f'{self.cyan}Installing{self.endc}'
@ -303,7 +303,7 @@ class Slackbuilds(Configs):
if p1.exitcode != 0: if p1.exitcode != 0:
done: str = f' {self.bred} Failed{self.endc}' 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='') print(f'{self.endc}{done}', end='')
p2.terminate() p2.terminate()
@ -318,14 +318,14 @@ class Slackbuilds(Configs):
self.print_error() self.print_error()
def process(self, command: str) -> NoReturn: def process(self, command: str) -> None:
""" Processes execution. """ """ Processes execution. """
self.output = subprocess.call(command, shell=True, self.output = subprocess.call(command, shell=True,
stderr=self.stderr, stdout=self.stdout) stderr=self.stderr, stdout=self.stdout)
if self.output != 0: if self.output != 0:
raise SystemExit(self.output) raise SystemExit(self.output)
def print_error(self) -> NoReturn: def print_error(self) -> None:
""" Stop the process and print the error message. """ """ Stop the process and print the error message. """
if self.output != 0: if self.output != 0:
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n") raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n")
@ -346,7 +346,7 @@ class Slackbuilds(Configs):
if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package, self.file_pattern): if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package, self.file_pattern):
status: bool = True 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 status: bool = True
if self.mode == 'install' and self.utils.is_package_upgradeable(package, self.file_pattern): if self.mode == 'install' and self.utils.is_package_upgradeable(package, self.file_pattern):

View file

@ -26,7 +26,7 @@ class Upgrade(Configs, Utilities):
black: list = self.black.packages() black: list = self.black.packages()
upgrade, requires = [], [] upgrade, requires = [], []
installed: list = self.all_installed(self.file_pattern) installed: list = list(self.all_installed(self.file_pattern))
for pkg in installed: for pkg in installed:
inst_pkg_name: str = self.split_installed_pkg(pkg)[0] inst_pkg_name: str = self.split_installed_pkg(pkg)[0]

View file

@ -5,6 +5,7 @@ import time
import shutil import shutil
import tarfile import tarfile
from pathlib import Path from pathlib import Path
from typing import Generator, Any
from distutils.version import LooseVersion from distutils.version import LooseVersion
from slpkg.configs import Configs from slpkg.configs import Configs
@ -24,7 +25,7 @@ class Utilities:
self.cyan: str = self.color['cyan'] self.cyan: str = self.color['cyan']
self.endc: str = self.color['endc'] 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. """ """ Returns the installed package name. """
installed: list = list(self.all_installed(pattern)) installed: list = list(self.all_installed(pattern))
@ -36,7 +37,7 @@ class Utilities:
return '' 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. """ """ Return all installed SBo packages from /val/log/packages folder. """
var_log_packages = Path(self.configs.log_packages) var_log_packages = Path(self.configs.log_packages)
@ -91,9 +92,9 @@ class Utilities:
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]', time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
time.gmtime(elapsed_time))) 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. """ """ 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: if installed:
installed_version = self.split_installed_pkg(installed)[1] installed_version = self.split_installed_pkg(installed)[1]
repository_version = SBoQueries(package).version() repository_version = SBoQueries(package).version()
@ -101,6 +102,6 @@ class Utilities:
return LooseVersion(repository_version) > LooseVersion(installed_version) return LooseVersion(repository_version) > LooseVersion(installed_version)
@staticmethod @staticmethod
def is_option(flag: list, flags: list) -> True: def is_option(flag: list, flags: list) -> Any:
""" Checking for flags. """ """ Checking for flags. """
return [f for f in flag if f in flags] return [f for f in flag if f in flags]

View file

@ -44,21 +44,21 @@ class Help(Configs):
'tracking': "Tracking the packages dependencies." 'tracking': "Tracking the packages dependencies."
} }
help_commands['-u']: dict = help_commands['update'] help_commands['-u'] = help_commands['update']
help_commands['-U']: dict = help_commands['upgrade'] help_commands['-U'] = help_commands['upgrade']
help_commands['-c']: dict = help_commands['check-updates'] help_commands['-c'] = help_commands['check-updates']
help_commands['-g']: dict = help_commands['configs'] help_commands['-g'] = help_commands['configs']
help_commands['-L']: dict = help_commands['clean-logs'] help_commands['-L'] = help_commands['clean-logs']
help_commands['-D']: dict = help_commands['clean-tmp'] help_commands['-D'] = help_commands['clean-tmp']
help_commands['-b']: dict = help_commands['build'] help_commands['-b'] = help_commands['build']
help_commands['-i']: dict = help_commands['install'] help_commands['-i'] = help_commands['install']
help_commands['-d']: dict = help_commands['download'] help_commands['-d'] = help_commands['download']
help_commands['-r']: dict = help_commands['remove'] help_commands['-r'] = help_commands['remove']
help_commands['-f']: dict = help_commands['find'] help_commands['-f'] = help_commands['find']
help_commands['-w']: dict = help_commands['view'] help_commands['-w'] = help_commands['view']
help_commands['-s']: dict = help_commands['search'] help_commands['-s'] = help_commands['search']
help_commands['-e']: dict = help_commands['dependees'] help_commands['-e'] = help_commands['dependees']
help_commands['-t']: dict = help_commands['tracking'] help_commands['-t'] = help_commands['tracking']
print(f'\n{self.bold}{self.green}Help: {self.endc}{help_commands[self.command]}\n') 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}") print(f"{self.bold}COMMAND{self.endc}: {self.cyan}{self.command}{self.endc}")

View file

@ -5,7 +5,7 @@ class Version:
""" Print the version. """ """ Print the version. """
def __init__(self): def __init__(self):
self.version_info: tuple = (4, 5, 4) self.version_info: tuple = (4, 5, 5)
self.version: str = '{0}.{1}.{2}'.format(*self.version_info) self.version: str = '{0}.{1}.{2}'.format(*self.version_info)
self.license: str = 'MIT License' self.license: str = 'MIT License'
self.author: str = 'Dimitris Zlatanidis (dslackw)' self.author: str = 'Dimitris Zlatanidis (dslackw)'

View file

@ -34,16 +34,16 @@ class ViewPackage(Configs, Utilities):
for package in packages: for package in packages:
info: list = self.session.query( info: list = self.session.query(
SBoTable.name, SBoTable.name, # type: ignore
SBoTable.version, SBoTable.version, # type: ignore
SBoTable.requires, SBoTable.requires, # type: ignore
SBoTable.download, SBoTable.download, # type: ignore
SBoTable.download64, SBoTable.download64, # type: ignore
SBoTable.md5sum, SBoTable.md5sum, # type: ignore
SBoTable.md5sum64, SBoTable.md5sum64, # type: ignore
SBoTable.files, SBoTable.files, # type: ignore
SBoTable.short_description, SBoTable.short_description, # type: ignore
SBoTable.location SBoTable.location # type: ignore
).filter(SBoTable.name == package).first() ).filter(SBoTable.name == package).first()
readme = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/README') 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') info_file = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/{info[0]}.info')
maintainer, email, homepage = '', '', '' 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'): if line.startswith('HOMEPAGE'):
homepage: str = line[10:-1].strip() homepage: str = line[10:-1].strip()
if line.startswith('MAINTAINER'): 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'SBo url: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}{endc}\n'
f'Maintainer: {yellow}{maintainer}{endc}\n' f'Maintainer: {yellow}{maintainer}{endc}\n'
f'Email: {yellow}{email}{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 @staticmethod
def http_request(link: str) -> str: def http_request(link: str) -> str:

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
from typing import Any, NoReturn from typing import Any
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.views.ascii import Ascii from slpkg.views.ascii import Ascii
@ -121,7 +121,7 @@ class ViewMessage(Configs):
slackbuilds.append(pkg) slackbuilds.append(pkg)
requires = self.session.query( requires = self.session.query(
LogsDependencies.requires).filter( LogsDependencies.requires).filter( # type: ignore
LogsDependencies.name == pkg).first() LogsDependencies.name == pkg).first()
if requires: if requires:
@ -153,7 +153,7 @@ class ViewMessage(Configs):
""" View and creates list with packages for remove. """ """ View and creates list with packages for remove. """
installed = self.utils.all_installed(self.file_pattern) 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: for package in installed:
pkg: str = self.utils.split_installed_pkg(package)[0] pkg: str = self.utils.split_installed_pkg(package)[0]
if pkg == name: if pkg == name:
@ -189,7 +189,7 @@ class ViewMessage(Configs):
install = upgrade = remove = 0 install = upgrade = remove = 0
for sbo in slackbuilds: 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: if not installed:
install += 1 install += 1
@ -229,7 +229,7 @@ class ViewMessage(Configs):
print('Note: After cleaning you should remove them one by one.') print('Note: After cleaning you should remove them one by one.')
def question(self) -> NoReturn: def question(self) -> None:
""" Manage to proceed. """ """ Manage to proceed. """
if not self.utils.is_option(self.flag_yes, self.flags): if not self.utils.is_option(self.flag_yes, self.flags):
answer: str = input('\nDo you want to continue? [y/N] ') answer: str = input('\nDo you want to continue? [y/N] ')

View file

@ -13,7 +13,7 @@ class TestUtilities(unittest.TestCase):
self.package = 'fish-3.6.0-x86_64-1_SBo' self.package = 'fish-3.6.0-x86_64-1_SBo'
def test_ins_installed(self): 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): def test_split_name(self):
self.assertEqual('fish', self.utils.split_installed_pkg(self.package)[0]) self.assertEqual('fish', self.utils.split_installed_pkg(self.package)[0])