From 11853cebf745a58e39dd59a9a3431c34dd757bd6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 25 Jun 2015 06:07:01 +0300 Subject: [PATCH] Fix avoid add null packages --- slpkg/blacklist.py | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index a5e19edc..13cf6674 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -101,42 +101,34 @@ class BlackList(object): # blacklist packages by repository priority if (pr[0] == repo and pr[1].startswith("*") and pr[1].endswith("*")): - black.append(self.__add(1, repo, pkg, pr[1][1:-1])) + if pr[1][1:-1] in pkg: + black.append(self.__add(repo, pkg)) elif pr[0] == repo and pr[1].endswith("*"): - black.append(self.__add(2, repo, pkg, pr[1][:-1])) + if pkg.startswith(pr[1][:-1]): + black.append(self.__add(repo, pkg)) elif pr[0] == repo and pr[1].startswith("*"): - black.append(self.__add(3, repo, pkg, pr[1][1:])) + if pkg.endswith(pr[1][1:]): + black.append(self.__add(repo, pkg)) elif pr[0] == repo and "*" not in pr[1]: - if repo == "sbo": - black.append(pr[1]) - else: - black.append(split_package(pkg)[0]) + black.append(self.__add(repo, pkg)) # normal blacklist packages if bl.startswith("*") and bl.endswith("*"): - black.append(self.__add(1, repo, pkg, bl[1:-1])) + if bl[1:-1] in pkg: + black.append(self.__add(repo, pkg)) elif bl.endswith("*"): - black.append(self.__add(2, repo, pkg, bl[:-1])) + if pkg.startswith(bl[:-1]): + black.append(self.__add(repo, pkg)) elif bl.startswith("*"): - black.append(self.__add(3, repo, pkg, bl[1:])) + if pkg.endswith(bl[1:]): + black.append(self.__add(repo, pkg)) if bl not in black and "*" not in bl: black.append(bl) return black - def __add(self, mode, repo, pkg, bl): + def __add(self, repo, pkg): """Split packages by repository """ - if mode == 1: - if repo == "sbo" and bl in pkg: - return pkg - elif bl in pkg: - return split_package(pkg)[0] - if mode == 2: - if repo == "sbo" and pkg.startswith(bl): - return pkg - elif pkg.startswith(bl): - return split_package(pkg)[0] - if mode == 3: - if repo == "sbo" and pkg.endswith(bl): - return pkg - elif pkg.endswith(bl): - return split_package(pkg)[0] + if repo == "sbo": + return pkg + else: + return split_package(pkg)[0]