mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Updated for json
This commit is contained in:
parent
fc363692a4
commit
e347f1913f
1 changed files with 7 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
|||
#!/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
|
||||
|
@ -32,30 +34,22 @@ class SearchPackage(Configs):
|
|||
if self.repository == '*':
|
||||
self.search_to_all_repositories()
|
||||
else:
|
||||
self.search_to_the_repository()
|
||||
json_file: Path = Path(f'{self.repos.repositories_path}/{self.repository}', self.repos.json_file)
|
||||
self.repo_data: dict = self.utils.read_json_file(json_file)
|
||||
self.search_for_the_packages(self.repository)
|
||||
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
print(f'The list below shows the repo '
|
||||
f'packages that contains \'{", ".join([p for p in self.packages])}\':\n')
|
||||
|
||||
self.summary_of_searching()
|
||||
|
||||
def search_to_all_repositories(self) -> None:
|
||||
for repo, item in self.repos.repositories.items():
|
||||
if item['enable']: # Check if the repository is enabled
|
||||
if self.utils.is_binary_repo(repo):
|
||||
self.repo_data: dict = BinQueries(repo).repository_data()
|
||||
else:
|
||||
self.repo_data: dict = SBoQueries(repo).repository_data()
|
||||
json_file: Path = Path(f'{self.repos.repositories_path}/{repo}', self.repos.json_file)
|
||||
self.repo_data: dict = self.utils.read_json_file(json_file)
|
||||
self.search_for_the_packages(repo)
|
||||
|
||||
def search_to_the_repository(self) -> None:
|
||||
if self.is_binary:
|
||||
self.repo_data: dict = BinQueries(self.repository).repository_data()
|
||||
else:
|
||||
self.repo_data: dict = SBoQueries(self.repository).repository_data()
|
||||
self.search_for_the_packages(self.repository)
|
||||
|
||||
def search_for_the_packages(self, repo: str) -> None:
|
||||
for package in self.packages:
|
||||
for name, data_pkg in self.repo_data.items():
|
||||
|
|
Loading…
Reference in a new issue