diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index f39f70d5..f6d72721 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -5,6 +5,8 @@ import tomli from pathlib import Path from slpkg.configs import Configs +from slpkg.models.models import PonceTable +from slpkg.models.models import session as Session class Blacklist(Configs): @@ -12,14 +14,25 @@ class Blacklist(Configs): def __init__(self): super(Configs, self).__init__() + self.session = Session - def get(self) -> list: + def get(self) -> None: """ Reads the blacklist file. """ - file = Path(self.etc_path, 'blacklist.toml') - if file.is_file(): + toml_blacks, ponce_blacks = [], [] + file_toml = Path(self.etc_path, 'blacklist.toml') + + if self.ponce_repo: + sbos = self.session.query(PonceTable.name).all() + ponce_blacks = [sbo[0] for sbo in sbos] + + if file_toml.is_file(): try: - with open(file, 'rb') as black: - return tomli.load(black)['blacklist']['packages'] + with open(file_toml, 'rb') as black: + toml_blacks = tomli.load(black)['blacklist']['packages'] except tomli.TOMLDecodeError as error: raise SystemExit(f"\nValueError: {error}: in the configuration file " "'/etc/slpkg/blacklist.toml'\n") + + return toml_blacks + ponce_blacks + + diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 6ff53696..6b7e07a2 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -19,11 +19,11 @@ class UpdateRepository(Configs): def __init__(self, flags: list): super(Configs, self).__init__() - self.flags = flags + self.flags: list = flags self.session = Session self.progress = ProgressBar() self.color = self.colour() - self.endc = self.color['endc'] + self.endc: str = self.color['endc'] def sbo(self): """ Updated the sbo repository. """ @@ -39,9 +39,9 @@ class UpdateRepository(Configs): self.delete_sbo_data() self.delete_ponce_data() - slackbuilds_txt = f'{self.sbo_repo_url}/{self.sbo_txt}' - changelog_txt = f'{self.sbo_repo_url}/{self.sbo_chglog_txt}' - slack_changelog_txt = f'{self.slack_current_mirror}/{self.slack_chglog_txt}' + slackbuilds_txt: str = f'{self.sbo_repo_url}/{self.sbo_txt}' + changelog_txt: str = f'{self.sbo_repo_url}/{self.sbo_chglog_txt}' + slack_changelog_txt: str = f'{self.slack_current_mirror}/{self.slack_chglog_txt}' down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags) down_slackbuilds.download()