From 603bcc33b08c1f7aa72fd60589eea71706968def Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sun, 11 May 2025 19:13:56 +0200 Subject: [PATCH] fix: black --- src/rougail/output_console/__init__.py | 58 +++++++++++++++++--------- src/rougail/output_console/i18n.py | 4 +- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/rougail/output_console/__init__.py b/src/rougail/output_console/__init__.py index d255582..dcc9cab 100644 --- a/src/rougail/output_console/__init__.py +++ b/src/rougail/output_console/__init__.py @@ -96,7 +96,9 @@ class RougailOutputConsole: except PropertiesOptionError: options_with_error.append(option) if options: - self.errors.append(_("The following variables are mandatory but have no value:")) + self.errors.append( + _("The following variables are mandatory but have no value:") + ) self.errors.append(options) elif options_with_error: self.errors.append( @@ -120,13 +122,15 @@ class RougailOutputConsole: if errors: self.display_errors(errors) return False - old_path_in_description = self.config.information.get('path_in_description', True) - self.config.information.set('path_in_description', False) + old_path_in_description = self.config.information.get( + "path_in_description", True + ) + self.config.information.set("path_in_description", False) self.parse_options( self.config, self.root, ) - self.config.information.set('path_in_description', old_path_in_description) + self.config.information.set("path_in_description", old_path_in_description) self.header() self.end() return True @@ -183,20 +187,20 @@ class RougailOutputConsole: leader_obj.add_variable(follower) def header(self): - header_variable = '' + header_variable = "" if self.variable_default_enable: - header_variable += _('Variable') + '\n' + header_variable += _("Variable") + "\n" if self.variable_advanced_enable: header_variable += f'[{self.variable_advanced_color}]{_("Undocumented variable")}[/{self.variable_advanced_color}]\n' if self.variable_advanced_and_modified_enable: header_variable += f'[{self.variable_advanced_and_modified_color}]{_("Undocumented but modified variable")}[/{self.variable_advanced_and_modified_color}]\n' if self.variable_hidden_enable: header_variable += f'[{self.variable_hidden_color}]{_("Unmodifiable variable")}[/{self.variable_hidden_color}]\n' - header_value = '' + header_value = "" if self.value_unmodified_enable: header_value = f'[{self.value_unmodified_color}]{_("Default value")}[/{self.value_unmodified_color}]\n' if self.value_modified_enable: - header_value += _("Modified value") + '\n' + header_value += _("Modified value") + "\n" if self.value_default_enable: header_value += f'([{self.value_default_color}]{_("Original default value")}[/{self.value_default_color}])\n' header = Table.grid(padding=1, collapse_padding=True) @@ -224,7 +228,8 @@ class RougailOutputConsole: self, warnings: list, ) -> None: - tree = Tree(f"[bold][bright_yellow]:bell: {_('WARNINGS')}[/bright_yellow][/bold]", + tree = Tree( + f"[bold][bright_yellow]:bell: {_('WARNINGS')}[/bright_yellow][/bold]", guide_style="bold bright_yellow", ) for warning in warnings: @@ -250,7 +255,15 @@ class RougailOutputConsole: class OutputFamily: def __init__( - self, family, parent, root, _yaml, key_is_description, *, is_leader: bool = False, no_icon: bool = False + self, + family, + parent, + root, + _yaml, + key_is_description, + *, + is_leader: bool = False, + no_icon: bool = False, ) -> None: if parent is None: tree = Tree @@ -258,7 +271,7 @@ class OutputFamily: tree = parent.add if is_leader: self.tree = tree( - ":notebook: " + _('{0}:').format(family), + ":notebook: " + _("{0}:").format(family), guide_style="bold bright_blue", ) elif no_icon: @@ -349,9 +362,11 @@ class OutputFamily: default_value = None follower_index = option.index() if follower_index is not None: - loaded_from = option.information.get(f'loaded_from_{follower_index}', None) + loaded_from = option.information.get( + f"loaded_from_{follower_index}", None + ) else: - loaded_from = option.information.get('loaded_from', None) + loaded_from = option.information.get("loaded_from", None) if variable_color is None: self.root.variable_default_enable = True if value is undefined: @@ -376,7 +391,7 @@ class OutputFamily: ) if isinstance(value, list): subtree = self.tree.add( - ":notebook: " + _('{0}:').format(key), + ":notebook: " + _("{0}:").format(key), guide_style="bold bright_blue", ) for val in value: @@ -395,7 +410,7 @@ class OutputFamily: if isinstance(value, list): if default_value is None: default_value = [] -# default_value = [self.convert_value(option, val) for val in default_value] + # default_value = [self.convert_value(option, val) for val in default_value] len_value = len(value) len_default_value = len(default_value) len_values = max(len_value, len_default_value) @@ -420,7 +435,7 @@ class OutputFamily: ) return ret if value is None: - ret = '' + ret = "" else: if option: value = self.convert_value( @@ -431,7 +446,10 @@ class OutputFamily: ret = f"[{color}]{value}[/{color}]" else: ret = value - if default_value is not None and "force_store_value" not in option.property.get(): + if ( + default_value is not None + and "force_store_value" not in option.property.get() + ): self.root.value_default_enable = True default_value_color = self.root.value_default_color default_value = self.convert_value(option, default_value) @@ -443,9 +461,9 @@ class OutputFamily: else: ret = f"[{default_value_color}]{default_value}[/{default_value_color}]" if loaded_from: - ret += f' ({loaded_from})' + ret += f" ({loaded_from})" elif loaded_from: - ret += f' ({loaded_from})' + ret += f" ({loaded_from})" return ret def convert_value( @@ -455,7 +473,7 @@ class OutputFamily: ) -> str: if isinstance(value, list): print(value) - raise Exception('pfff') + raise Exception("pfff") """Dump variable, means transform bool, ... to yaml string""" if not self.root.show_secrets and option.type() == "password": return "*" * 10 diff --git a/src/rougail/output_console/i18n.py b/src/rougail/output_console/i18n.py index 00af780..d2f9654 100644 --- a/src/rougail/output_console/i18n.py +++ b/src/rougail/output_console/i18n.py @@ -19,6 +19,8 @@ along with this program. If not, see . from gettext import translation from pathlib import Path -t = translation("rougail_output_console", str(Path(__file__).parent / "locale"), fallback=True) +t = translation( + "rougail_output_console", str(Path(__file__).parent / "locale"), fallback=True +) _ = t.gettext