Updated configs

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-12-06 16:31:58 +02:00
parent 74be03c890
commit 77ad114452
7 changed files with 35 additions and 47 deletions

View file

@ -12,10 +12,10 @@ class Blacklist:
''' Reads and returns the blacklist. '''
def __init__(self):
self.etc_path: str = Configs.etc_path
self.configs: str = Configs
def get(self):
file = f'{self.etc_path}/blacklist.toml'
file = f'{self.configs.etc_path}/blacklist.toml'
if os.path.isfile(file):
with open(file, 'rb') as black:
return tomli.load(black)['blacklist']['packages']

View file

@ -12,18 +12,16 @@ class CheckUpdates:
''' Check for changes in the ChangeLog file. '''
def __init__(self):
self.sbo_repo_url: str = Configs.sbo_repo_url
self.sbo_repo_path: str = Configs.sbo_repo_path
self.chglog_txt: str = Configs.chglog_txt
self.configs: str = Configs
def updates(self):
local_date = 0
local_chg_txt = f'{self.sbo_repo_path}/{self.chglog_txt}'
local_chg_txt = (f'{self.configs.sbo_repo_path}/'
f'{self.configs.chglog_txt}')
http = urllib3.PoolManager()
repo = http.request(
'GET', f'{self.sbo_repo_url}/{self.chglog_txt}')
'GET', f'{self.configs.sbo_repo_url}/{self.configs.chglog_txt}')
if os.path.isfile(local_chg_txt):
local_date = int(os.stat(local_chg_txt).st_size)

View file

@ -12,11 +12,7 @@ class Check:
''' Some checks before proceed. '''
def __init__(self):
self.log_packages: str = Configs.log_packages
self.sbo_repo_tag: str = Configs.sbo_repo_tag
self.db_path: str = Configs.db_path
self.database_name: str = Configs.database
self.etc_path: str = Configs.etc_path
self.configs: str = Configs
def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. '''
@ -43,9 +39,9 @@ class Check:
found, not_found = [], []
for sbo in slackbuilds:
for package in os.listdir(self.log_packages):
for package in os.listdir(self.configs.log_packages):
if (package.startswith(f'{sbo}-') and
package.endswith(self.sbo_repo_tag)):
package.endswith(self.configs.sbo_repo_tag)):
found.append(sbo)
for sbo in slackbuilds:
@ -70,12 +66,12 @@ class Check:
if packages:
raise SystemExit(
f'\nThe packages \'{", ".join(packages)}\' is blacklisted.\n'
f'Please edit the blacklist.toml file in {self.etc_path} '
'folder.\n')
f'Please edit the blacklist.toml file in '
f'{self.configs.etc_path} folder.\n')
def database(self):
''' Checking for empty table '''
db = f'{self.db_path}/{self.database_name}'
db = f'{self.configs.db_path}/{self.configs.database}'
if not SBoQueries('').names() or not os.path.isfile(db):
raise SystemExit('\nYou need to update the package lists first.\n'
'Please run slpkg update.\n')

View file

@ -11,9 +11,7 @@ class CreateData:
''' Reads the SLACKBUILDS.TXT file and inserts them into the database. '''
def __init__(self):
self.db_path: str = Configs.db_path
self.sbo_txt: str = Configs.sbo_txt
self.sbo_repo_path: str = Configs.sbo_repo_path
self.configs: str = Configs
self.session: str = Session
def insert_sbo_table(self):
@ -30,7 +28,8 @@ class CreateData:
'SLACKBUILD SHORT DESCRIPTION:'
]
sbo_file = self.read_file(f'{self.sbo_repo_path}/SLACKBUILDS.TXT')
sbo_file = self.read_file(
f'{self.configs.sbo_repo_path}/SLACKBUILDS.TXT')
cache = [] # init cache

View file

@ -12,12 +12,10 @@ from slpkg.models.models import session as Session
class Download:
''' Download the slackbuilds with the sources only. '''
def __init__(self):
self.flags: list
def __init__(self, flags):
self.flags: list = flags
self.configs: str = Configs
self.session: str = Session
self.download_only = Configs.download_only
self.sbo_repo_url: str = Configs.sbo_repo_url
self.sbo_tar_suffix: str = Configs.sbo_tar_suffix
def packages(self, slackbuilds: list):
@ -27,12 +25,12 @@ class Download:
wget = Wget()
for sbo in slackbuilds:
file = f'{sbo}{self.sbo_tar_suffix}'
file = f'{sbo}{self.configs.sbo_tar_suffix}'
location = SBoQueries(sbo).location()
url = f'{self.sbo_repo_url}/{location}/{file}'
url = f'{self.configs.sbo_repo_url}/{location}/{file}'
wget.download(self.download_only, url)
wget.download(self.configs.download_only, url)
sources = SBoQueries(sbo).sources()
for source in sources.split():
wget.download(self.download_only, source)
wget.download(self.configs.download_only, source)

View file

@ -15,9 +15,8 @@ class ViewPackage:
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
self.configs: str = Configs
self.colors: dict = self.configs.colour
def package(self, packages):
http = urllib3.PoolManager()
@ -44,10 +43,10 @@ class ViewPackage:
).filter(SBoTable.name == package).first()
readme = http.request(
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README')
'GET', f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/README')
info_file = http.request(
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info')
'GET', f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info')
maintainer, email, homepage = '', '', ''
for line in info_file.data.decode().splitlines():
@ -64,16 +63,16 @@ class ViewPackage:
f'Version: {GREEN}{info[1]}{ENDC}\n'
f'Requires: {GREEN}{deps}{ENDC}\n'
f'Homepage: {BLUE}{homepage}{ENDC}\n'
f'Download SlackBuild: {BLUE}{self.sbo_repo_url}/{info[9]}/{info[0]}{self.sbo_tar_suffix}{ENDC}\n'
f'Download SlackBuild: {BLUE}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{self.configs.sbo_tar_suffix}{ENDC}\n'
f'Download sources: {BLUE}{info[3]}{ENDC}\n'
f'Download_x86_64 sources: {BLUE}{info[4]}{ENDC}\n'
f'Md5sum: {YELLOW}{info[5]}{ENDC}\n'
f'Md5sum_x86_64: {YELLOW}{info[6]}{ENDC}\n'
f'Files: {GREEN}{info[7]}{ENDC}\n'
f'Description: {GREEN}{info[8]}{ENDC}\n'
f'Slackware: {CYAN}{self.sbo_repo_url.split("/")[-1]}{ENDC}\n'
f'Slackware: {CYAN}{self.configs.sbo_repo_url.split("/")[-1]}{ENDC}\n'
f'Category: {RED}{info[9]}{ENDC}\n'
f'SBo url: {BLUE}{self.sbo_repo_url}/{info[9]}/{info[0]}{ENDC}\n'
f'SBo url: {BLUE}{self.configs.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}')

View file

@ -16,10 +16,8 @@ class ViewMessage:
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.configs: str = Configs
self.colors: dict = self.configs.colour
self.session: str = Session
self.utils: str = Utilities()
self.black: list = Blacklist()
@ -119,7 +117,7 @@ class ViewMessage:
install, set_color = 'upgrade', color['YELLOW']
if installed and 'noarch' in installed:
self.arch = 'noarch'
self.configs.os_arch = 'noarch'
if installed:
@ -128,7 +126,7 @@ class ViewMessage:
print(f'[{set_color} {install} {color["ENDC"]}] -> '
f'{sbo}-{version} {set_color}'
f'({installed.split(self.arch)[0][:-1].split("-")[-1]})'
f'({installed.split(self.configs.os_arch)[0][:-1].split("-")[-1]})'
f'{color["ENDC"]}')
else:
print(f'[{color["CYAN"]} install {color["ENDC"]}] -> '
@ -136,13 +134,13 @@ class ViewMessage:
def _view_installed_packages(self, name: str):
''' View and creates list with packages for remove. '''
installed = os.listdir(self.log_packages)
installed = os.listdir(self.configs.log_packages)
color = self.colors()
for package in installed:
black = package.split('-')[0]
if (package.startswith(f'{name}-') and
self.sbo_repo_tag in package and
self.configs.sbo_repo_tag in package and
black not in self.black.get()):
self.installed_packages.append(package)
print(f'[{color["RED"]} delete {color["ENDC"]}] -> {package}')