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
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.views.asciibox import AsciiBox
|
from slpkg.views.asciibox import AsciiBox
|
||||||
|
@ -40,12 +38,10 @@ class SearchPackage(Configs):
|
||||||
self.summary_of_searching()
|
self.summary_of_searching()
|
||||||
|
|
||||||
def search_to_all_repositories(self) -> None:
|
def search_to_all_repositories(self) -> None:
|
||||||
print('\rDatabase loading... ', end='')
|
all_data: dict = self.utils.load_data(self.repository)
|
||||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
for name, repo in all_data.items():
|
||||||
for repo, item in self.repos.repositories.items():
|
self.repo_data: dict = repo
|
||||||
if item['enable']: # Check if the repository is enabled
|
self.search_for_the_packages(name)
|
||||||
self.repo_data: dict = self.utils.load_data(repo, message=False)
|
|
||||||
self.search_for_the_packages(repo)
|
|
||||||
|
|
||||||
def search_for_the_packages(self, repo: str) -> None:
|
def search_for_the_packages(self, repo: str) -> None:
|
||||||
for package in self.packages:
|
for package in self.packages:
|
||||||
|
|
|
@ -9,7 +9,7 @@ import json
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Generator, Union
|
from typing import Generator
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.blacklist import Blacklist
|
from slpkg.blacklist import Blacklist
|
||||||
|
@ -121,7 +121,6 @@ class Utilities(Configs):
|
||||||
|
|
||||||
def process(self, command: str, stderr=None, stdout=None) -> None:
|
def process(self, command: str, stderr=None, stdout=None) -> None:
|
||||||
""" Handle the processes. """
|
""" Handle the processes. """
|
||||||
output: Union = 0
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.run(f'{command}', shell=True, stderr=stderr, stdout=stdout)
|
output = subprocess.run(f'{command}', shell=True, stderr=stderr, stdout=stdout)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -206,10 +205,15 @@ class Utilities(Configs):
|
||||||
matching_packages: list = [pkg for pkg in packages if re.search(pattern, pkg)]
|
matching_packages: list = [pkg for pkg in packages if re.search(pattern, pkg)]
|
||||||
return matching_packages
|
return matching_packages
|
||||||
|
|
||||||
def load_data(self, repository: str, message=True) -> dict:
|
def load_data(self, repository: str) -> dict:
|
||||||
if repository != '*':
|
print('\rDatabase loading... ', end='')
|
||||||
if message:
|
data: dict = {}
|
||||||
print('\rDatabase loading... ', end='')
|
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)
|
json_data_file: Path = Path(f'{self.repos.repositories_path}/{repository}', self.repos.json_file)
|
||||||
|
|
||||||
if not json_data_file.is_file():
|
if not json_data_file.is_file():
|
||||||
|
@ -219,9 +223,28 @@ class Utilities(Configs):
|
||||||
|
|
||||||
data: dict = self.read_json_file(json_data_file)
|
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.
|
# Remove blacklist packages from keys.
|
||||||
for pkg in blacklist_packages:
|
for pkg in blacklist_packages:
|
||||||
if pkg in data.keys():
|
if pkg in data.keys():
|
||||||
|
@ -235,7 +258,5 @@ class Utilities(Configs):
|
||||||
deps.remove(blk)
|
deps.remove(blk)
|
||||||
data[pkg]['requires'] = deps
|
data[pkg]['requires'] = deps
|
||||||
|
|
||||||
if message:
|
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
return data
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue