Updated for load data

This commit is contained in:
Dimitris Zlatanidis 2024-03-18 12:24:15 +02:00
parent 01d74a23b2
commit 597e6491d8

View file

@ -224,39 +224,46 @@ class Utilities(Configs):
data: dict = self.read_json_file(json_data_file)
blacklist: tuple = self.black.packages()
if blacklist:
if repository == '*':
# Remove blacklist packages from keys.
for name, repo in data.items():
blacklist_packages: list = self.ignore_packages(list(data[name].keys()))
for pkg in blacklist_packages:
if pkg in data[name].keys():
del data[name][pkg]
# Remove blacklist packages from dependencies (values).
for name, repo in data.items():
blacklist_packages: list = self.ignore_packages(list(data[name].keys()))
for pkg, dep in repo.items():
deps = dep['requires']
for blk in blacklist_packages:
if blk in deps:
deps.remove(blk)
data[name][pkg]['requires'] = deps
self._remove_blacklist_from_all_repos(data)
else:
blacklist_packages: list = self.ignore_packages(list(data.keys()))
# Remove blacklist packages from keys.
for pkg in blacklist_packages:
if pkg in data.keys():
del data[pkg]
# Remove blacklist packages from dependencies (values).
for pkg, dep in data.items():
deps = dep['requires']
for blk in blacklist_packages:
if blk in deps:
deps.remove(blk)
data[pkg]['requires'] = deps
self._remove_blacklist_from_a_repo(data)
print(f'{self.yellow}{self.ascii.done}{self.endc}')
return data
def _remove_blacklist_from_all_repos(self, data: dict) -> dict:
# Remove blacklist packages from keys.
for name, repo in data.items():
blacklist_packages: list = self.ignore_packages(list(data[name].keys()))
for pkg in blacklist_packages:
if pkg in data[name].keys():
del data[name][pkg]
# Remove blacklist packages from dependencies (values).
for name, repo in data.items():
blacklist_packages: list = self.ignore_packages(list(data[name].keys()))
for pkg, dep in repo.items():
deps: list = dep['requires']
for blk in blacklist_packages:
if blk in deps:
deps.remove(blk)
data[name][pkg]['requires'] = deps
return data
def _remove_blacklist_from_a_repo(self, data: dict) -> dict:
blacklist_packages: list = self.ignore_packages(list(data.keys()))
# Remove blacklist packages from keys.
for pkg in blacklist_packages:
if pkg in data.keys():
del data[pkg]
# Remove blacklist packages from dependencies (values).
for pkg, dep in data.items():
deps: list = dep['requires']
for blk in blacklist_packages:
if blk in deps:
deps.remove(blk)
data[pkg]['requires'] = deps
return data