refactor: set new default of margin to 0 in Logger.print_dialog()

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-08-31 17:22:10 +02:00
parent ea6eef984f
commit a9a23304c7
9 changed files with 6 additions and 33 deletions

View File

@@ -234,8 +234,6 @@ def display_moonraker_info(moonraker_list: List[Moonraker]) -> bool:
"The following Klipper instances will be installed:", "The following Klipper instances will be installed:",
*[f"● klipper-{m.suffix}" for m in moonraker_list], *[f"● klipper-{m.suffix}" for m in moonraker_list],
], ],
padding_top=0,
padding_bottom=0,
) )
_input: bool = get_confirm("Proceed with installation?") _input: bool = get_confirm("Proceed with installation?")
return _input return _input

View File

@@ -103,7 +103,6 @@ def check_user_groups() -> None:
"INFO:", "INFO:",
"Relog required for group assignments to take effect!", "Relog required for group assignments to take effect!",
], ],
padding_bottom=0,
) )
if not get_confirm(f"Add user '{CURRENT_USER}' to group(s) now?"): if not get_confirm(f"Add user '{CURRENT_USER}' to group(s) now?"):

View File

@@ -68,8 +68,6 @@ def install_klipperscreen() -> None:
"KlipperScreens update manager configuration for Moonraker " "KlipperScreens update manager configuration for Moonraker "
"will not be added to any moonraker.conf.", "will not be added to any moonraker.conf.",
], ],
padding_top=0,
padding_bottom=0,
) )
if not get_confirm( if not get_confirm(
"Continue KlipperScreen installation?", "Continue KlipperScreen installation?",

View File

@@ -63,8 +63,6 @@ def install_octoeverywhere() -> None:
"It is safe to run the installer again to link your " "It is safe to run the installer again to link your "
"printer or repair any issues.", "printer or repair any issues.",
], ],
padding_top=0,
padding_bottom=0,
) )
if not get_confirm("Re-run OctoEverywhere installation?"): if not get_confirm("Re-run OctoEverywhere installation?"):
Logger.print_info("Exiting OctoEverywhere for Klipper installation ...") Logger.print_info("Exiting OctoEverywhere for Klipper installation ...")
@@ -85,8 +83,6 @@ def install_octoeverywhere() -> None:
"\n\n", "\n\n",
"The setup will apply the same names to OctoEverywhere!", "The setup will apply the same names to OctoEverywhere!",
], ],
padding_top=0,
padding_bottom=0,
) )
if not get_confirm( if not get_confirm(

View File

@@ -24,8 +24,6 @@ def print_moonraker_not_found_dialog() -> None:
"another machine in your network. Otherwise Mainsail will NOT work " "another machine in your network. Otherwise Mainsail will NOT work "
"correctly.", "correctly.",
], ],
padding_top=0,
padding_bottom=0,
) )
@@ -36,8 +34,6 @@ def print_client_already_installed_dialog(name: str) -> None:
f"{name} seems to be already installed!", f"{name} seems to be already installed!",
f"If you continue, your current {name} installation will be overwritten.", f"If you continue, your current {name} installation will be overwritten.",
], ],
padding_top=0,
padding_bottom=0,
) )
@@ -57,8 +53,6 @@ def print_client_port_select_dialog(
"The following ports were found to be in use already:", "The following ports were found to be in use already:",
*[f"{port}" for port in ports_in_use], *[f"{port}" for port in ports_in_use],
], ],
padding_top=0,
padding_bottom=0,
) )
@@ -77,8 +71,6 @@ def print_install_client_config_dialog(client: BaseWebClient) -> None:
"If you already use these macros skip this step. Otherwise you should " "If you already use these macros skip this step. Otherwise you should "
"consider to answer with 'Y' to download the recommended macros.", "consider to answer with 'Y' to download the recommended macros.",
], ],
padding_top=0,
padding_bottom=0,
) )

View File

@@ -92,8 +92,8 @@ class Logger:
center_content: bool = False, center_content: bool = False,
custom_title: str | None = None, custom_title: str | None = None,
custom_color: DialogCustomColor | None = None, custom_color: DialogCustomColor | None = None,
padding_top: int = 1, margin_top: int = 0,
padding_bottom: int = 1, margin_bottom: int = 0,
) -> None: ) -> None:
""" """
Prints a dialog with the given title and content. Prints a dialog with the given title and content.
@@ -106,8 +106,8 @@ class Logger:
:param center_content: Whether to center the content or not. :param center_content: Whether to center the content or not.
:param custom_title: A custom title for the dialog. :param custom_title: A custom title for the dialog.
:param custom_color: A custom color for the dialog. :param custom_color: A custom color for the dialog.
:param padding_top: The number of empty lines to print before the dialog. :param margin_top: The number of empty lines to print before the dialog.
:param padding_bottom: The number of empty lines to print after the dialog. :param margin_bottom: The number of empty lines to print after the dialog.
""" """
dialog_color = Logger._get_dialog_color(title, custom_color) dialog_color = Logger._get_dialog_color(title, custom_color)
dialog_title = Logger._get_dialog_title(title, custom_title) dialog_title = Logger._get_dialog_title(title, custom_title)
@@ -116,12 +116,12 @@ class Logger:
top = Logger._format_top_border(dialog_color) top = Logger._format_top_border(dialog_color)
bottom = Logger._format_bottom_border() bottom = Logger._format_bottom_border()
print("\n" * padding_top) print("\n" * margin_top)
print( print(
f"{top}{dialog_title_formatted}{dialog_content}{bottom}", f"{top}{dialog_title_formatted}{dialog_content}{bottom}",
end="", end="",
) )
print("\n" * padding_bottom) print("\n" * margin_bottom)
@staticmethod @staticmethod
def _get_dialog_title( def _get_dialog_title(

View File

@@ -281,8 +281,6 @@ class UpdateMenu(BaseMenu):
DialogType.CUSTOM, DialogType.CUSTOM,
["The following packages will be upgraded:", "\n\n", pkgs], ["The following packages will be upgraded:", "\n\n", pkgs],
custom_title="UPGRADABLE SYSTEM UPDATES", custom_title="UPGRADABLE SYSTEM UPDATES",
padding_top=0,
padding_bottom=0,
) )
if not get_confirm("Continue?"): if not get_confirm("Continue?"):
return return

View File

@@ -49,8 +49,6 @@ class TelegramBotExtension(BaseExtension):
"Moonraker Telegram Bot requires Moonraker to be installed. " "Moonraker Telegram Bot requires Moonraker to be installed. "
"Please install Moonraker first!", "Please install Moonraker first!",
], ],
padding_top=0,
padding_bottom=0,
) )
return return
@@ -65,8 +63,6 @@ class TelegramBotExtension(BaseExtension):
"\n\n", "\n\n",
"The setup will apply the same names to Telegram Bot!", "The setup will apply the same names to Telegram Bot!",
], ],
padding_top=0,
padding_bottom=0,
) )
if not get_confirm( if not get_confirm(
"Continue Moonraker Telegram Bot installation?", "Continue Moonraker Telegram Bot installation?",

View File

@@ -35,8 +35,6 @@ def change_system_hostname() -> None:
"browser.", "browser.",
], ],
custom_title="CHANGE SYSTEM HOSTNAME", custom_title="CHANGE SYSTEM HOSTNAME",
padding_top=0,
padding_bottom=0,
) )
if not get_confirm("Do you want to change the hostname?", default_choice=False): if not get_confirm("Do you want to change the hostname?", default_choice=False):
return return
@@ -50,8 +48,6 @@ def change_system_hostname() -> None:
"● Any special characters", "● Any special characters",
"● No leading or trailing '-'", "● No leading or trailing '-'",
], ],
padding_top=0,
padding_bottom=0,
) )
hostname = get_string_input( hostname = get_string_input(
"Enter the new hostname", "Enter the new hostname",