Updated blacklist prints

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-05-12 20:15:12 +03:00
parent 71e530d66d
commit 86957fb9e6

View file

@ -67,30 +67,33 @@ class BlackList(Utils):
def black_listed(self): def black_listed(self):
"""Print blacklist packages """Print blacklist packages
""" """
print("Packages in the blacklist:\n") print("Packages in the blacklist:")
for black in list(self.black_filter()): for black in list(self.black_filter()):
if black: if black:
print(f"{self.green}{black}{self.endc}") print(f"{self.green}{black}{self.endc}")
print()
def black_add(self, pkgs): def black_add(self, pkgs):
"""Add blacklist packages if not exist """Add blacklist packages if not exist
""" """
blacklist = list(self.black_filter()) blacklist = list(self.black_filter())
pkgs = set(pkgs) pkgs = set(pkgs)
print("Add packages in the blacklist:\n") print("Add packages in the blacklist:")
with open(self.blackfile, "a") as black_conf: with open(self.blackfile, "a") as black_conf:
for pkg in pkgs: for pkg in pkgs:
if pkg not in blacklist: if pkg not in blacklist:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n") black_conf.write(pkg + "\n")
print()
def black_remove(self, pkgs): def black_remove(self, pkgs):
"""Remove packages from blacklist """Remove packages from blacklist
""" """
print("Remove packages from the blacklist:\n") print("Remove packages from the blacklist:")
with open(self.blackfile, "w") as remove: with open(self.blackfile, "w") as remove:
for line in self.black_conf.splitlines(): for line in self.black_conf.splitlines():
if line not in pkgs: if line not in pkgs:
remove.write(line + "\n") remove.write(line + "\n")
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
print()