Updated for checks

This commit is contained in:
Dimitris Zlatanidis 2023-03-15 20:28:56 +02:00
parent 1844b33cf6
commit cbc81396c5
2 changed files with 4 additions and 5 deletions

View file

@ -21,14 +21,14 @@ class Blacklist(Configs):
self.cyan: str = self.color['cyan'] self.cyan: str = self.color['cyan']
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.blacklist_file_toml = Path(self.etc_path, 'blacklist.toml')
def packages(self) -> list: def packages(self) -> list:
""" Reads the blacklist file. """ """ Reads the blacklist file. """
file_toml = Path(self.etc_path, 'blacklist.toml')
if file_toml.is_file(): if self.blacklist_file_toml.is_file():
try: try:
with open(file_toml, 'rb') as black: with open(self.blacklist_file_toml, 'rb') as black:
return tomli.load(black)['BLACKLIST']['PACKAGES'] return tomli.load(black)['BLACKLIST']['PACKAGES']
except (tomli.TOMLDecodeError, KeyError) as error: except (tomli.TOMLDecodeError, KeyError) as error:
raise SystemExit(f"\n[{self.bred}Error{self.endc}]: {error}: in the configuration file " raise SystemExit(f"\n[{self.bred}Error{self.endc}]: {error}: in the configuration file "

View file

@ -79,8 +79,7 @@ class Check(Configs):
if packages: if packages:
raise SystemExit( raise SystemExit(
f"\nThe packages '{self.cyan}{', '.join(packages)}{self.endc}' is blacklisted.\n" f"\nThe packages '{self.cyan}{', '.join(packages)}{self.endc}' is blacklisted.\n"
f"Please edit the blacklist.toml file in " f"Please edit the '{self.black.blacklist_file_toml}' file.\n")
f"{self.etc_path} folder.\n")
def is_empty_database(self) -> None: def is_empty_database(self) -> None:
""" Checking for empty table """ """ Checking for empty table """