From e18cda64e730a4e663c81b34a4d9739a4aa61791 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 4 May 2024 18:29:14 +0300 Subject: [PATCH] Updated for process message Signed-off-by: Dimitris Zlatanidis --- slpkg/install_data.py | 23 +++++++++++------------ slpkg/update_repositories.py | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 5b381fa1..cc0dae57 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -11,6 +11,7 @@ from slpkg.utilities import Utilities from slpkg.views.asciibox import AsciiBox from slpkg.repositories import Repositories from slpkg.multi_process import MultiProcess +from slpkg.views.view_process import ViewProcess class InstallData(Configs): @@ -18,12 +19,13 @@ class InstallData(Configs): """ Installs data to the repositories path. """ - def __init__(self): + def __init__(self, flags: list): super(Configs, self).__init__() self.utils = Utilities() self.repos = Repositories() self.ascii = AsciiBox() self.multi_process = MultiProcess() + self.view_process = ViewProcess(flags) def write_repo_info(self, changelog_file: Path, info: dict) -> None: """ Reads the first date of the changelog file.""" @@ -48,11 +50,6 @@ class InstallData(Configs): self.repos.repos_information.write_text(json.dumps(repo_info, indent=4), encoding='utf-8') - def view_done_message(self) -> None: - """ Prints the done message. - """ - print(f'{self.bgreen}{self.ascii.done}{self.endc}\n') - def install_sbo_data(self, repo: str) -> None: # pylint: disable=[R0914] """ Reads the SLACKBUILDS.TXT FILE and creates a json data file. @@ -62,8 +59,8 @@ class InstallData(Configs): No Longer Returned: None. """ - print(f"Updating the database for '{self.cyan}{repo}{self.endc}'... ", - end='', flush=True) + print() + self.view_process.message(f'Updating the database for {repo}') data: dict = {} cache: list = [] @@ -143,15 +140,16 @@ class InstallData(Configs): data_file: Path = Path(self.repos.repositories[repo]['path'], self.repos.data_json) data_file.write_text(json.dumps(data, indent=4), encoding='utf-8') - self.view_done_message() + self.view_process.done() + print() def install_binary_data(self, repo: str) -> None: # pylint: disable=[R0912,R0914,R0915] """ Installs the data for binary repositories. Args: repo (str): Description """ - print(f"\nUpdating the database for '{self.cyan}{repo}{self.endc}'... ", - end='', flush=True) + print() + self.view_process.message(f'Updating the database for {repo}') slack_repos: list = [self.repos.slack_patches_repo_name, self.repos.slack_extra_repo_name] @@ -275,4 +273,5 @@ class InstallData(Configs): data_file: Path = Path(self.repos.repositories[repo]['path'], self.repos.data_json) data_file.write_text(json.dumps(data, indent=4), encoding='utf-8') - self.view_done_message() + self.view_process.done() + print() diff --git a/slpkg/update_repositories.py b/slpkg/update_repositories.py index 8cb5072f..9d1fb6ff 100644 --- a/slpkg/update_repositories.py +++ b/slpkg/update_repositories.py @@ -31,7 +31,7 @@ class UpdateRepositories(Configs): # pylint: disable=[R0902] self.multi_process = MultiProcess(flags) self.repos = Repositories() self.utils = Utilities() - self.data = InstallData() + self.data = InstallData(flags) self.generate = SBoGenerate() self.check_updates = CheckUpdates(flags, repository) self.download = Downloader(flags)