diff --git a/configs/slpkg.toml b/configs/slpkg.toml index 5c29b540..87c4e265 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -15,7 +15,7 @@ sbo_repo_path = "/var/lib/slpkg/repository" # The name of the database. Default name is 'database.slpkg'. - database = "database.slpkg" + database_name = "database.slpkg" # Slackbuilds.org repository url. sbo_repo_url = "http://slackbuilds.org/slackbuilds/15.0" diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 89015751..5cc5a87c 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -7,15 +7,15 @@ from pathlib import Path from slpkg.configs import Configs -class Blacklist: +class Blacklist(Configs): """ Reads and returns the blacklist. """ def __init__(self): - self.configs = Configs + super(Configs, self).__init__() def get(self) -> list: """ Reads the blacklist file. """ - file = Path(self.configs.etc_path, 'blacklist.toml') + file = Path(self.etc_path, 'blacklist.toml') if file.is_file(): with open(file, 'rb') as black: return tomli.load(black)['blacklist']['packages'] diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 3baec66c..7c26af87 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -10,13 +10,12 @@ from slpkg.configs import Configs from slpkg.progress_bar import ProgressBar -class CheckUpdates: +class CheckUpdates(Configs): """ Check for changes in the ChangeLog file. """ def __init__(self): - self.configs = Configs - self.colors = self.configs.colour - self.color = self.colors() + super(Configs, self).__init__() + self.color = self.colour() self.green = self.color['green'] self.yellow = self.color['yellow'] self.endc = self.color['endc'] @@ -26,12 +25,10 @@ class CheckUpdates: """ Checks the ChangeLogs and returns True or False. """ local_date = 0 - local_chg_txt = Path(self.configs.sbo_repo_path, - self.configs.sbo_chglog_txt) + local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt) http = urllib3.PoolManager() - repo = http.request( - 'GET', f'{self.configs.sbo_repo_url}/{self.configs.sbo_chglog_txt}') + repo = http.request('GET', f'{self.sbo_repo_url}/{self.sbo_chglog_txt}') if local_chg_txt.is_file(): local_date = int(os.stat(local_chg_txt).st_size) diff --git a/slpkg/checks.py b/slpkg/checks.py index 1a9ed173..06d9af99 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -9,12 +9,12 @@ from slpkg.blacklist import Blacklist from slpkg.utilities import Utilities -class Check: +class Check(Configs, Utilities): """ Some checks before proceed. """ def __init__(self): - self.configs = Configs - self.utils = Utilities() + super(Configs, self).__init__() + super(Utilities, self).__init__() @staticmethod def exists(slackbuilds: list): @@ -43,9 +43,9 @@ class Check: found, not_found = [], [] for sbo in slackbuilds: - package = self.utils.is_installed(sbo) + package = self.is_installed(sbo) if package: - pkg = self.utils.split_installed_pkg(package)[0] + pkg = self.split_installed_pkg(package)[0] found.append(pkg) else: not_found.append(sbo) @@ -73,7 +73,7 @@ class Check: def database(self): """ Checking for empty table """ - db = Path(self.configs.db_path, self.configs.database) + db = Path(self.db_path, self.database_name) if not SBoQueries('').sbos() or not db.is_file(): raise SystemExit('\nYou need to update the package lists first.\n' 'Please run slpkg update.\n') diff --git a/slpkg/checksum.py b/slpkg/checksum.py index eee7e36c..377ad58d 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -27,7 +27,7 @@ class Md5sum: checksum = "".join(checksum) if file_check != checksum: - self.ascii.checksum_error_box(name, checksum, file_check) + self.ascii.draw_checksum_error_box(name, checksum, file_check) view = ViewMessage(self.flags) view.question() diff --git a/slpkg/configs.py b/slpkg/configs.py index c31e4865..100302bb 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -45,7 +45,7 @@ class Configs: log_packages: str = Path('/var', 'log', 'packages') # Database name - database: str = f'database.{prog_name}' + database_name: str = f'database.{prog_name}' # SBo repository configs sbo_repo_url: str = 'http://slackbuilds.org/slackbuilds/15.0' @@ -87,7 +87,7 @@ class Configs: sbo_repo_path: str = config['sbo_repo_path'] # Database name - database: str = config['database'] + database_name: str = config['database_name'] # SBo repository details sbo_repo_url: str = config['sbo_repo_url'] diff --git a/slpkg/create_data.py b/slpkg/create_data.py index 80f06848..69e9b8c4 100644 --- a/slpkg/create_data.py +++ b/slpkg/create_data.py @@ -9,11 +9,11 @@ from slpkg.models.models import SBoTable from slpkg.models.models import session as Session -class CreateData: +class CreateData(Configs): """ Reads the SLACKBUILDS.TXT file and inserts them into the database. """ def __init__(self): - self.configs = Configs + super(Configs, self).__init__() self.session = Session def insert_sbo_table(self): @@ -30,7 +30,7 @@ class CreateData: 'SLACKBUILD REQUIRES:', 'SLACKBUILD SHORT DESCRIPTION:' ] - path = Path(self.configs.sbo_repo_path, self.configs.sbo_txt) + path = Path(self.sbo_repo_path, self.sbo_txt) sbo_file = self.read_file(path) cache = [] # init cache diff --git a/slpkg/models/models.py b/slpkg/models/models.py index 22b098a5..2e3279ec 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -11,7 +11,7 @@ from sqlalchemy import create_engine, Column, Integer, Text from slpkg.configs import Configs -DATABASE_URI = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database) +DATABASE_URI = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database_name) engine = create_engine(DATABASE_URI) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index c9e7d604..31155cc2 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -14,7 +14,7 @@ from slpkg.models.models import LogsDependencies from slpkg.models.models import session as Session -class ViewMessage: +class ViewMessage(Configs): """ Print some messages before. """ def __init__(self, flags: list): @@ -25,10 +25,8 @@ class ViewMessage: self.session = Session self.utils = Utilities() self.black = Blacklist() - self.dialog = DialogBox() - self.configs = Configs - self.colors = self.configs.colour - self.color = self.colors() + self.dialogbox = DialogBox() + self.color = self.colour() self.yellow = self.color['yellow'] self.cyan = self.color['cyan'] self.red = self.color['red'] @@ -177,7 +175,7 @@ class ViewMessage: text = f'There are {len(choices)} dependencies:' - code, tags = self.dialog.checklist(text, title, height, width, list_height, choices, dependencies) + code, tags = self.dialogbox.checklist(text, title, height, width, list_height, choices, dependencies) if not code: return dependencies @@ -211,7 +209,7 @@ class ViewMessage: elif option == 'build': print(f'{self.grey}Total {len(slackbuilds)} packages ' - f'will be build in {self.configs.tmp_path} folder.{self.endc}') + f'will be build in {self.tmp_path} folder.{self.endc}') elif option == 'remove': print(f'{self.grey}Total {remove} packages ' @@ -219,7 +217,7 @@ class ViewMessage: elif option == 'download': print(f'{self.grey}{len(slackbuilds)} packages ' - f'will be downloaded in {self.configs.download_only} folder.{self.endc}') + f'will be downloaded in {self.download_only} folder.{self.endc}') def logs_packages(self, dependencies: list): """ View the logging packages. """