From cde0c6ee140bd108849bff40467d8f18ffc332ef Mon Sep 17 00:00:00 2001 From: Dmitrii Agibov Date: Fri, 2 Sep 2022 09:24:58 +0100 Subject: MLIA-602 Fix output formatting issue Apply the same formatting rules for each section in the output of the command "backend status" Change-Id: I253c513f99826ef1eb916285ca4c2cc1840633ac --- src/mlia/tools/metadata/common.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mlia/tools/metadata/common.py b/src/mlia/tools/metadata/common.py index c17a738..924e870 100644 --- a/src/mlia/tools/metadata/common.py +++ b/src/mlia/tools/metadata/common.py @@ -255,20 +255,28 @@ class DefaultInstallationManager(InstallationManager, InstallationFiltersMixin): def show_env_details(self) -> None: """Print current state of the execution environment.""" if installed := self.already_installed(): - logger.info("Installed backends:\n") - - for installation in installed: - logger.info(" - %s", installation.name) + self._print_installation_list("Installed backends:", installed) if could_be_installed := self.ready_for_installation(): - logger.info("Following backends could be installed:") - - for installation in could_be_installed: - logger.info(" - %s", installation.name) + self._print_installation_list( + "Following backends could be installed:", + could_be_installed, + new_section=bool(installed), + ) if not installed and not could_be_installed: logger.info("No backends installed") + @staticmethod + def _print_installation_list( + header: str, installations: List[Installation], new_section: bool = False + ) -> None: + """Print list of the installations.""" + logger.info("%s%s\n", "\n" if new_section else "", header) + + for installation in installations: + logger.info(" - %s", installation.name) + def _install( self, installation: Installation, -- cgit v1.2.1