Removed dataclasses

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-12-02 22:30:17 +02:00
parent e6a8db4e12
commit ec320b202c
15 changed files with 89 additions and 86 deletions

View file

@ -10,6 +10,7 @@ from slpkg.configs import Configs
class Blacklist:
''' Reads and returns the blacklist. '''
def __init__(self):
self.etc_path: str = Configs.etc_path

View file

@ -9,6 +9,7 @@ from slpkg.configs import Configs
class CheckUpdates:
''' Check for changes in the ChangeLog file. '''
def __init__(self):
self.sbo_repo_url: str = Configs.sbo_repo_url

View file

@ -3,15 +3,15 @@
import subprocess
from dataclasses import dataclass
from slpkg.configs import Configs
@dataclass
class Wget:
''' Wget donwloader. '''
wget_options: str = Configs.wget_options
def __init__(self):
self.wget_options: str = Configs.wget_options
def download(self, path: str, url: str):
subprocess.call(f'wget {self.wget_options} --directory-prefix={path}'

View file

@ -3,15 +3,17 @@
import os
from dataclasses import dataclass
from slpkg.configs import Configs
@dataclass
class FindInstalled:
log_packages: str = Configs.log_packages
colors: dict = Configs.colour
sbo_repo_tag: str = Configs.sbo_repo_tag
''' Find installed packages. '''
def __init__(self):
self.log_packages: str = Configs.log_packages
self.colors: dict = Configs.colour
self.sbo_repo_tag: str = Configs.sbo_repo_tag
def find(self, packages: list):
matching = []

View file

@ -3,7 +3,6 @@
import sys
from dataclasses import dataclass
from slpkg.checks import Check
from slpkg.upgrade import Upgrade
@ -22,11 +21,10 @@ from slpkg.clean_logs import CleanLogsDependencies
from slpkg.update_repository import UpdateRepository
@dataclass
class Argparse:
args: list
def __init__(self, args):
self.args: list = args
def __post_init__(self):
self.flag()
self.check = Check()

View file

@ -2,22 +2,20 @@
# -*- coding: utf-8 -*-
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.blacklist import Blacklist
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@dataclass
class SBoQueries:
''' Queries class for the sbo repository. '''
name: str
session: str = Session
os_arch: str = Configs.os_arch
def __post_init__(self):
def __init__(self, name):
self.name: str = name
self.session: str = Session
self.os_arch: str = Configs.os_arch
self.black = Blacklist()
if self.name in self.black.get():
self.name = ''

View file

@ -3,7 +3,6 @@
import subprocess
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.views.views import ViewMessage
@ -11,13 +10,14 @@ from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session
@dataclass
class RemovePackages:
''' Removes installed packages. '''
packages: str
flags: list
session: str = Session
removepkg: str = Configs.removepkg
def __init__(self, packages, flags):
self.packages: str = packages
self.flags: list = flags
self.session: str = Session
self.removepkg: str = Configs.removepkg
def remove(self):
''' Removes package with dependencies. '''

View file

@ -2,15 +2,15 @@
# -*- coding: utf-8 -*-
from dataclasses import dataclass
from slpkg.queries import SBoQueries
from slpkg.configs import Configs
@dataclass
class SearchPackage:
colors: dict = Configs.colour
''' Search slackbuilds from the repository. '''
def __init__(self):
self.colors: dict = Configs.colour
def package(self, packages):
color = self.colors()

View file

@ -5,7 +5,6 @@ import os
import subprocess
import multiprocessing
from dataclasses import dataclass
from collections import OrderedDict
from slpkg.downloader import Wget
@ -19,23 +18,24 @@ from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session
@dataclass
class Slackbuilds:
''' Download build and install the SlackBuilds. '''
slackbuilds: str
flags: list
install: bool
session: str = Session
utils: str = Utilities()
build_path: str = Configs.build_path
sbo_repo_tag: str = Configs.sbo_repo_tag
sbo_repo_url: str = Configs.sbo_repo_url
build_path: str = Configs.build_path
tmp_slpkg: str = Configs.tmp_slpkg
tmp_path: str = Configs.tmp_path
sbo_tar_suffix: str = Configs.sbo_tar_suffix
installpkg: str = Configs.installpkg
reinstall: str = Configs.reinstall
def __init__(self, slackbuilds, flags, install):
self.slackbuilds: str = slackbuilds
self.flags: list = flags
self.install: bool = install
self.session: str = Session
self.utils: str = Utilities()
self.build_path: str = Configs.build_path
self.sbo_repo_tag: str = Configs.sbo_repo_tag
self.sbo_repo_url: str = Configs.sbo_repo_url
self.build_path: str = Configs.build_path
self.tmp_slpkg: str = Configs.tmp_slpkg
self.tmp_path: str = Configs.tmp_path
self.sbo_tar_suffix: str = Configs.sbo_tar_suffix
self.installpkg: str = Configs.installpkg
self.reinstall: str = Configs.reinstall
def execute(self):
''' Starting build or install the slackbuilds. '''

View file

@ -5,7 +5,6 @@
import os
from os import path
from dataclasses import dataclass
from slpkg.downloader import Wget
from slpkg.configs import Configs
@ -14,16 +13,17 @@ from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@dataclass
class UpdateRepository:
''' Deletes and install the data. '''
sbo_repo_path: str = Configs.sbo_repo_path
url: str = Configs.sbo_repo_url
sbo_txt: str = Configs.sbo_txt
chglog_txt: str = Configs.chglog_txt
db_path: str = Configs.db_path
database: str = Configs.database
session: str = Session
def __init__(self):
self.sbo_repo_path: str = Configs.sbo_repo_path
self.url: str = Configs.sbo_repo_url
self.sbo_txt: str = Configs.sbo_txt
self.chglog_txt: str = Configs.chglog_txt
self.db_path: str = Configs.db_path
self.database: str = Configs.database
self.session: str = Session
def sbo(self):
print('Updating the package list...\n')

View file

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
import os
from dataclasses import dataclass
from distutils.version import LooseVersion
from slpkg.configs import Configs
@ -10,10 +9,12 @@ from slpkg.queries import SBoQueries
from slpkg.blacklist import Blacklist
@dataclass
class Upgrade:
log_packages: str = Configs.log_packages
sbo_repo_tag: str = Configs.sbo_repo_tag
''' Upgrade the installed packages. '''
def __init__(self):
self.log_packages: str = Configs.log_packages
self.sbo_repo_tag: str = Configs.sbo_repo_tag
def packages(self):
''' Compares version of packages and returns the maximum. '''

View file

@ -6,14 +6,14 @@ import os
import shutil
import tarfile
from dataclasses import dataclass
from slpkg.configs import Configs
@dataclass
class Utilities:
log_packages: str = Configs.log_packages
def __init__(self):
self.log_packages: str = Configs.log_packages
def untar_archive(self, path: str, archive: str, ext_path: str):
''' Untar the file to the build folder. '''

View file

@ -2,19 +2,19 @@
# -*- coding: utf-8 -*-
from dataclasses import dataclass
from slpkg.configs import Configs
@dataclass
class Version:
prog_name: str = Configs.prog_name
version_info: tuple = (4, 3, 3)
version: str = '{0}.{1}.{2}'.format(*version_info)
license: str = 'MIT License'
author: str = 'dslackw'
homepage: str = 'https://dslackw.gitlab.io/slpkg'
''' Print the vesrsion. '''
def __init__(self):
self.prog_name: str = Configs.prog_name
self.version_info: tuple = (4, 3, 3)
self.version: str = '{0}.{1}.{2}'.format(*self.version_info)
self.license: str = 'MIT License'
self.author: str = 'dslackw'
self.homepage: str = 'https://dslackw.gitlab.io/slpkg'
def view(self):
print(f'{self.prog_name} version: {self.version}\n'

View file

@ -3,19 +3,20 @@
import urllib3
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@dataclass
class ViewPackage:
session: str = Session
colors: dict = Configs.colour
sbo_repo_url: str = Configs.sbo_repo_url
sbo_tar_suffix: str = Configs.sbo_tar_suffix
''' View the repository packages. '''
def __init__(self):
self.session: str = Session
self.colors: dict = Configs.colour
self.sbo_repo_url: str = Configs.sbo_repo_url
self.sbo_tar_suffix: str = Configs.sbo_tar_suffix
def package(self, packages):
http = urllib3.PoolManager()

View file

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
import os
from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.queries import SBoQueries
@ -12,16 +11,18 @@ from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session
@dataclass
class ViewMessage:
flags: list
colors: dict = Configs.colour
log_packages: str = Configs.log_packages
sbo_repo_tag: str = Configs.sbo_repo_tag
arch: str = Configs.os_arch
session: str = Session
utils: str = Utilities()
black: list = Blacklist()
''' Print some messages before. '''
def __init__(self, flags):
self.flags: list = flags
self.colors: dict = Configs.colour
self.log_packages: str = Configs.log_packages
self.sbo_repo_tag: str = Configs.sbo_repo_tag
self.arch: str = Configs.os_arch
self.session: str = Session
self.utils: str = Utilities()
self.black: list = Blacklist()
def build_packages(self, slackbuilds: list, dependencies: list):
print('The following packages will be build:\n')