Updated metadata -> configs

This commit is contained in:
Dimitris Zlatanidis 2022-06-18 21:35:23 +03:00
parent 1e5bcb6a9f
commit db54079167
18 changed files with 52 additions and 52 deletions

View file

@ -21,8 +21,8 @@ setup(
author='dslackw',
url='https://dslackw.gitlab.io/slpkg/',
package_data={'': ['LICENSE.txt', 'README.rst', 'ChangeLog.txt']},
data_files=[('/etc/slpkg', ['config/slpkg.json']),
('/etc/slpkg', ['config/blacklist.json']),
data_files=[('/etc/slpkg', ['configs/slpkg.json']),
('/etc/slpkg', ['configs/blacklist.json']),
('/var/lib/slpkg/database', []),
('/var/lib/slpkg/repository', []),
('/tmp/slpkg/build', [])],

View file

@ -5,12 +5,12 @@
import os
import json
from dataclasses import dataclass
from metadata import Metadata
from configs import Configs
@dataclass
class Blacklist:
etc_path: str = Metadata.etc_path
etc_path: str = Configs.etc_path
def get(self):
file = f'{self.etc_path}/blacklist.json'

View file

@ -4,15 +4,15 @@
import os
from dataclasses import dataclass
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.queries import SBoQueries
from slpkg.blacklist import Blacklist
@dataclass
class Check:
log_packages: str = Metadata.log_packages
repo_tag: str = Metadata.repo_tag
log_packages: str = Configs.log_packages
repo_tag: str = Configs.repo_tag
def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. '''

View file

@ -5,7 +5,7 @@
import hashlib
from dataclasses import dataclass
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.views.views import ViewMessage
@ -13,7 +13,7 @@ from slpkg.views.views import ViewMessage
class Md5sum:
''' Checksum the sources. '''
flags: str
build_path: str = Metadata.build_path
build_path: str = Configs.build_path
def check(self, source: str, checksum: str, name: str):
path = f'{self.build_path}/{name}'

View file

@ -1,11 +1,11 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from slpkg.metadata import Metadata
from slpkg.configs import Configs
def usage(status: int):
args = [f'Usage: {Metadata.prog_name} [OPTIONS] [packages]\n',
args = [f'Usage: {Configs.prog_name} [OPTIONS] [packages]\n',
' Packaging tool that interacts with the SBo repository.\n',
'Options:',
' update Update the data packages.',

View file

@ -7,7 +7,7 @@ from dataclasses import dataclass
@dataclass
class Metadata:
class Configs:
# Programme name
prog_name: str = 'slpkg'

View file

@ -4,7 +4,7 @@
from dataclasses import dataclass
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
@ -12,9 +12,9 @@ from slpkg.models.models import session as Session
@dataclass
class CreateData:
db_path: str = Metadata.db_path
sbo_txt: str = Metadata.sbo_txt
sbo_repo_path: str = Metadata.sbo_repo_path
db_path: str = Configs.db_path
sbo_txt: str = Configs.sbo_txt
sbo_repo_path: str = Configs.sbo_repo_path
session: str = Session
def insert_sbo_table(self):

View file

@ -4,12 +4,12 @@
import subprocess
from dataclasses import dataclass
from slpkg.metadata import Metadata
from slpkg.configs import Configs
@dataclass
class Wget:
wget_options: str = Metadata.wget_options
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

@ -6,7 +6,7 @@ import sys
from dataclasses import dataclass
from slpkg.cli_menu import usage
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.slackbuild import Slackbuilds
from slpkg.remove_packages import RemovePackages
from slpkg.update_repository import UpdateRepository
@ -50,7 +50,7 @@ class Argparse:
usage(0)
if self.args[0] in ['--version', '-v']:
print(f'{Metadata.prog_nama}: {Version.version}')
print(f'{Configs.name}: {Version.version}')
raise SystemExit()
if self.args[0] == 'clean-logs':

View file

@ -1,15 +1,15 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from dataclasses import dataclass
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine, Column, Integer, Text
db_path = Metadata.db_path
database = Metadata.database
db_path = Configs.db_path
database = Configs.database
DATABASE_URI = f"sqlite:///{db_path}/{database}"
engine = create_engine(DATABASE_URI)

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
from dataclasses import dataclass
@ -14,7 +14,7 @@ class SBoQueries:
''' Queries class for the sbo repository. '''
name: str
session: str = Session
os_arch: str = Metadata.os_arch
os_arch: str = Configs.os_arch
def __post_init__(self):
self.black = Blacklist()

View file

@ -4,7 +4,7 @@
import os
import subprocess
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from dataclasses import dataclass
from slpkg.blacklist import Blacklist
@ -20,10 +20,10 @@ class RemovePackages:
flags: list
session: str = Session
black: list = Blacklist()
log_packages: str = Metadata.log_packages
repo_tag: str = Metadata.repo_tag
removepkg: str = Metadata.removepkg
color: str = Metadata.colour
log_packages: str = Configs.log_packages
repo_tag: str = Configs.repo_tag
removepkg: str = Configs.removepkg
color: str = Configs.colour
def remove(self):
''' Remove package with dependencies. '''

View file

@ -9,7 +9,7 @@ from dataclasses import dataclass
from slpkg.downloader import Wget
from slpkg.checksum import Md5sum
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.queries import SBoQueries
from slpkg.utilities import Utilities
from slpkg.dependencies import Requires
@ -26,17 +26,17 @@ class Slackbuilds:
install: bool
session: str = Session
utils: str = Utilities()
build_path: str = Metadata.build_path
sbo_url: str = Metadata.sbo_url
build_path: str = Metadata.build_path
tmp_slpkg: str = Metadata.tmp_slpkg
tmp_path: str = Metadata.tmp_path
tar_suffix: str = Metadata.tar_suffix
os_arch: str = Metadata.os_arch
repo_tag: str = Metadata.repo_tag
pkg_suffix: str = Metadata.pkg_suffix
installpkg: str = Metadata.installpkg
reinstall: str = Metadata.reinstall
build_path: str = Configs.build_path
sbo_url: str = Configs.sbo_url
build_path: str = Configs.build_path
tmp_slpkg: str = Configs.tmp_slpkg
tmp_path: str = Configs.tmp_path
tar_suffix: str = Configs.tar_suffix
os_arch: str = Configs.os_arch
repo_tag: str = Configs.repo_tag
pkg_suffix: str = Configs.pkg_suffix
installpkg: str = Configs.installpkg
reinstall: str = Configs.reinstall
def execute(self):
''' Starting build or install the slackbuilds. '''

View file

@ -6,7 +6,7 @@ import os
from os import path
from slpkg.create_data import CreateData
from slpkg.downloader import Wget
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session
from dataclasses import dataclass
@ -15,11 +15,11 @@ from dataclasses import dataclass
@dataclass
class UpdateRepository:
''' Deletes and install the data. '''
sbo_repo_path: str = Metadata.sbo_repo_path
url: str = Metadata.sbo_url
sbo_txt: str = Metadata.sbo_txt
db_path: str = Metadata.db_path
database: str = Metadata.database
sbo_repo_path: str = Configs.sbo_repo_path
url: str = Configs.sbo_url
sbo_txt: str = Configs.sbo_txt
db_path: str = Configs.db_path
database: str = Configs.database
session: str = Session
def sbo(self):

View file

@ -6,12 +6,12 @@ import os
import re
import tarfile
from dataclasses import dataclass
from metadata import Metadata
from slpkg.configs import Configs
@dataclass
class Utilities:
log_packages: str = Metadata.log_packages
log_packages: str = Configs.log_packages
def build_tag(self, path: str, name: str):
''' Opens the .SlackBuild file and reads the BUILD TAG. '''

View file

@ -3,13 +3,13 @@
from dataclasses import dataclass
from slpkg.queries import SBoQueries
from slpkg.metadata import Metadata
from slpkg.configs import Configs
from utilities import Utilities
@dataclass
class ViewMessage:
colors: str = Metadata.colour
colors: str = Configs.colour
utils: str = Utilities()
def build_packages(self, slackbuilds: list, dependencies: list):