mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-05 08:46:20 +01:00
Updated load all repos
This commit is contained in:
parent
ed36ae2f43
commit
ebf211e185
2 changed files with 37 additions and 20 deletions
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
|
@ -40,12 +38,10 @@ class SearchPackage(Configs):
|
|||
self.summary_of_searching()
|
||||
|
||||
def search_to_all_repositories(self) -> None:
|
||||
print('\rDatabase loading... ', end='')
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
for repo, item in self.repos.repositories.items():
|
||||
if item['enable']: # Check if the repository is enabled
|
||||
self.repo_data: dict = self.utils.load_data(repo, message=False)
|
||||
self.search_for_the_packages(repo)
|
||||
all_data: dict = self.utils.load_data(self.repository)
|
||||
for name, repo in all_data.items():
|
||||
self.repo_data: dict = repo
|
||||
self.search_for_the_packages(name)
|
||||
|
||||
def search_for_the_packages(self, repo: str) -> None:
|
||||
for package in self.packages:
|
||||
|
|
|
@ -9,7 +9,7 @@ import json
|
|||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Generator, Union
|
||||
from typing import Generator
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
@ -121,7 +121,6 @@ class Utilities(Configs):
|
|||
|
||||
def process(self, command: str, stderr=None, stdout=None) -> None:
|
||||
""" Handle the processes. """
|
||||
output: Union = 0
|
||||
try:
|
||||
output = subprocess.run(f'{command}', shell=True, stderr=stderr, stdout=stdout)
|
||||
except KeyboardInterrupt:
|
||||
|
@ -206,10 +205,15 @@ class Utilities(Configs):
|
|||
matching_packages: list = [pkg for pkg in packages if re.search(pattern, pkg)]
|
||||
return matching_packages
|
||||
|
||||
def load_data(self, repository: str, message=True) -> dict:
|
||||
if repository != '*':
|
||||
if message:
|
||||
print('\rDatabase loading... ', end='')
|
||||
def load_data(self, repository: str) -> dict:
|
||||
print('\rDatabase loading... ', end='')
|
||||
data: dict = {}
|
||||
if repository == '*':
|
||||
for repo, item in self.repos.repositories.items():
|
||||
if item['enable']: # Check if the repository is enabled
|
||||
json_data_file: Path = Path(f'{self.repos.repositories_path}/{repo}', self.repos.json_file)
|
||||
data[repo] = self.read_json_file(json_data_file)
|
||||
else:
|
||||
json_data_file: Path = Path(f'{self.repos.repositories_path}/{repository}', self.repos.json_file)
|
||||
|
||||
if not json_data_file.is_file():
|
||||
|
@ -219,9 +223,28 @@ class Utilities(Configs):
|
|||
|
||||
data: dict = self.read_json_file(json_data_file)
|
||||
|
||||
blacklist_packages: list = self.ignore_packages(list(data.keys()))
|
||||
blacklist: tuple = self.black.packages()
|
||||
|
||||
if blacklist_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
|
||||
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():
|
||||
|
@ -235,7 +258,5 @@ class Utilities(Configs):
|
|||
deps.remove(blk)
|
||||
data[pkg]['requires'] = deps
|
||||
|
||||
if message:
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
|
||||
return data
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
return data
|
||||
|
|
Loading…
Add table
Reference in a new issue