Refactor method for blacklist

This commit is contained in:
Dimitris Zlatanidis 2023-03-01 00:23:28 +02:00
parent 9e6ce38274
commit 0db7acdc86
6 changed files with 7 additions and 7 deletions

View file

@ -16,7 +16,7 @@ class Blacklist(Configs):
super(Configs, self).__init__()
self.session = Session
def get(self) -> None:
def packages(self) -> None:
""" Reads the blacklist file. """
toml_blacks, ponce_blacks = [], []
file_toml = Path(self.etc_path, 'blacklist.toml')

View file

@ -61,7 +61,7 @@ class Check(Configs, Utilities):
packages = []
black = Blacklist()
for package in black.get():
for package in black.packages():
if package in slackbuilds:
packages.append(package)

View file

@ -16,7 +16,7 @@ class SBoQueries(Configs):
self.session = Session
self.black = Blacklist()
if self.name in self.black.get():
if self.name in self.black.packages():
self.name: str = ''
def sbos(self) -> list:
@ -62,7 +62,7 @@ class SBoQueries(Configs):
if requires:
requires = requires[0].split()
for req in requires:
if req in self.black.get():
if req in self.black.packages():
requires.remove(req)
return requires
return ''

View file

@ -20,7 +20,7 @@ class Upgrade(Configs, Utilities):
def packages(self):
""" Compares version of packages and returns the maximum. """
repo_packages = SBoQueries('').sbos()
black = self.black.get()
black = self.black.packages()
upgrade, requires = [], []
installed = self.all_installed(self.file_pattern)

View file

@ -42,7 +42,7 @@ class Utilities:
for file in var_log_packages.glob(pattern):
package_name = self.split_installed_pkg(file.name)[0]
if package_name not in self.black.get():
if package_name not in self.black.packages():
yield file.name
@staticmethod

View file

@ -6,7 +6,7 @@ class TestBlacklist(unittest.TestCase):
def test_blacklist(self):
black = Blacklist()
self.assertListEqual(['%README%'], black.get())
self.assertListEqual(['%README%'], black.packages())
if __name__ == '__main__':