Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-12-09 20:03:47 +02:00
commit c70043d352
8 changed files with 36 additions and 28 deletions

View file

@ -1,3 +1,7 @@
4.3.7 - 09/12/2022
Updated:
- Merge method is_installed in utilities
4.3.6 - 08/12/2022
Fixed:
- Remove packages

View file

@ -30,8 +30,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash
$ tar xvf slpkg-4.3.6.tar.gz
$ cd slpkg-4.3.6
$ tar xvf slpkg-4.3.7.tar.gz
$ cd slpkg-4.3.7
$ ./install.sh

View file

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

View file

@ -6,6 +6,7 @@ import os
from slpkg.configs import Configs
from slpkg.queries import SBoQueries
from slpkg.blacklist import Blacklist
from slpkg.utilities import Utilities
class Check:
@ -36,15 +37,14 @@ class Check:
if 'UNSUPPORTED' in sources:
raise SystemExit(f"\nPackage '{sbo}' unsupported by arch.\n")
def installed(self, slackbuilds: list):
@staticmethod
def installed(slackbuilds: list):
""" Checking for installed packages. """
found, not_found = [], []
utils = Utilities()
for sbo in slackbuilds:
for package in os.listdir(self.configs.log_packages):
pkg = '-'.join(package.split('-')[:-3])
if sbo == pkg and package.endswith(self.configs.sbo_repo_tag):
found.append(sbo)
found.append((utils.is_installed(sbo)))
for sbo in slackbuilds:
if sbo not in found:

View file

@ -25,14 +25,14 @@ class Argparse:
def __init__(self, args):
self.args = args
self.flags = []
self.configs = Configs
self.usage = Usage()
self.check = Check()
if len(self.args) == 0:
self.usage.help_short()
self.flags = []
self.check = Check()
self.configs = Configs
self.check.blacklist(self.args)
self.options = ['--yes',

View file

@ -8,17 +8,20 @@ import tarfile
from slpkg.configs import Configs
from slpkg.blacklist import Blacklist
class Utilities:
def __init__(self):
self.configs = Configs
self.black = Blacklist()
def is_installed(self, package: str):
""" Returns True if a package is installed. """
for pkg in os.listdir(self.configs.log_packages):
if package in pkg:
def is_installed(self, name: str):
""" Returns the installed package name. """
for package in os.listdir(self.configs.log_packages):
pkg = '-'.join(package.split('-')[:-3])
if pkg == name and self.configs.sbo_repo_tag in package and pkg not in self.black.get():
return pkg
@staticmethod

View file

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

View file

@ -68,7 +68,7 @@ class ViewMessage:
print('The following packages will be removed:\n')
slackbuilds, dependencies, deps = [], [], []
for pkg in packages:
self._view_installed_packages(pkg)
self._view_removed(pkg)
slackbuilds.append(pkg)
requires = self.session.query(
@ -83,7 +83,7 @@ class ViewMessage:
for i in range(0, len(deps)):
for dep in deps[i][0].split():
self._view_installed_packages(dep)
self._view_removed(dep)
dependencies.append(dep)
self._view_total(slackbuilds, dependencies, option='remove')
@ -94,7 +94,7 @@ class ViewMessage:
""" View packages for download only. """
color = self.colors()
if self.utils.is_installed(f'{sbo}-'):
if self.utils.is_installed(sbo):
print(f'[{color["yellow"]} download {color["endc"]}] -> '
f'{sbo}-{version}')
else:
@ -105,7 +105,7 @@ class ViewMessage:
""" View packages for build. """
color = self.colors()
if self.utils.is_installed(f'{sbo}-'):
if self.utils.is_installed(sbo):
print(f'[{color["yellow"]} build {color["endc"]}] -> '
f'{sbo}-{version}')
else:
@ -116,7 +116,7 @@ class ViewMessage:
""" View the packages for install. """
color = self.colors()
installed = self.utils.is_installed(f'{sbo}-')
installed = self.utils.is_installed(sbo)
install, set_color = 'install', color['red']
if '--reinstall' in self.flags:
@ -138,16 +138,17 @@ class ViewMessage:
print(f'[{color["cyan"]} install {color["endc"]}] -> '
f'{sbo}-{version}')
def _view_installed_packages(self, name: str):
def _view_removed(self, name: str):
""" View and creates list with packages for remove. """
installed = os.listdir(self.configs.log_packages)
color = self.colors()
for package in installed:
pkg = '-'.join(package.split('-')[:-3])
if pkg == name and self.configs.sbo_repo_tag in package and pkg not in self.black.get():
self.installed_packages.append(package)
print(f'[{color["red"]} delete {color["endc"]}] -> {package}')
if self.utils.is_installed(name):
for package in installed:
pkg = '-'.join(package.split('-')[:-3])
if pkg == name:
self.installed_packages.append(package)
print(f'[{color["red"]} delete {color["endc"]}] -> {package}')
def _view_total(self, slackbuilds: list, dependencies: list, option: str):
""" View the status of the packages action. """
@ -157,7 +158,7 @@ class ViewMessage:
installed = upgraded = 0
for sbo in slackbuilds:
if self.utils.is_installed(f'{sbo}-'):
if self.utils.is_installed(sbo):
upgraded += 1
else:
installed += 1