From c064f6519d5204f31c9da65bb3102b9597612097 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 8 Nov 2025 22:18:16 +0100 Subject: [PATCH] fix: black --- src/rougail/output_console/__init__.py | 105 ++++++++++++++++--------- 1 file changed, 70 insertions(+), 35 deletions(-) diff --git a/src/rougail/output_console/__init__.py b/src/rougail/output_console/__init__.py index f5bc512..59e777f 100644 --- a/src/rougail/output_console/__init__.py +++ b/src/rougail/output_console/__init__.py @@ -43,14 +43,14 @@ class RougailOutputConsole: def __init__( self, config: "Config", - metaconfig = None, + metaconfig=None, *, rougailconfig: "RougailConfig" = None, user_data_errors: Optional[list] = None, user_data_warnings: Optional[list] = None, config_owner_is_path: bool = False, - layer_datas = None, - **kwargs + layer_datas=None, + **kwargs, ) -> None: if rougailconfig is None: from rougail import RougailConfig @@ -102,14 +102,16 @@ class RougailOutputConsole: else: parent = self.config current_options = options - for child_path in option.path().split('.'): + for child_path in option.path().split("."): child = parent.option(child_path) if self.key_is_description: description = child.description(uncalculated=True) else: description = child.path(uncalculated=True) if child.isdynamic() and "{{ identifier }}" in description: - description = description.replace('{{ identifier }}', child.identifiers()[-1]) + description = description.replace( + "{{ identifier }}", child.identifiers()[-1] + ) if child.isoptiondescription(): current_options = current_options.setdefault(description, {}) @@ -117,15 +119,21 @@ class RougailOutputConsole: else: current_options.setdefault(None, []).append(description) if options: - self.errors.append({_("The following variables are mandatory but have no value:"): options}) + self.errors.append( + {_("The following variables are mandatory but have no value:"): options} + ) elif options_with_error: if self.key_is_description: variables = [option.description() for option in options_with_error] else: variables = [option.path() for option in options_with_error] - self.errors.append({_( - "The following variables are inaccessible but are empty and mandatory:" - ): variables}) + self.errors.append( + { + _( + "The following variables are inaccessible but are empty and mandatory:" + ): variables + } + ) def exporter(self) -> bool: if self.is_mandatory: @@ -359,10 +367,13 @@ class OutputFamily: key_name = option.name() return OutputFamily( self.colorize( - [{"value": key_name, - "color": color, - "loaded_from": None, - }] + [ + { + "value": key_name, + "color": color, + "loaded_from": None, + } + ] ), self.tree, self.root, @@ -402,13 +413,18 @@ class OutputFamily: loaded_from = option.information.get("loaded_from", None) if value is undefined: value = option.value.get() - values.append({"value": value, - "color": color, - "loaded_from": loaded_from, - }) + values.append( + { + "value": value, + "color": color, + "loaded_from": loaded_from, + } + ) suboption = option subconfig = self.root.config - if "force_store_value" not in option.property.get() and option.information.get("default_value_makes_sense", True): + if "force_store_value" not in option.property.get() and option.information.get( + "default_value_makes_sense", True + ): while True: default_value = suboption.value.default() if leader_index is not None: @@ -417,10 +433,16 @@ class OutputFamily: else: default_value = None is_root_metaconfig = False - if subconfig is None or not subconfig.path() or "." not in subconfig.path(): + if ( + subconfig is None + or not subconfig.path() + or "." not in subconfig.path() + ): is_root_metaconfig = True subconfig = self.get_subconfig_with_default_value(suboption) - if ((values and default_value is None) or default_value == []) and is_root_metaconfig: + if ( + (values and default_value is None) or default_value == [] + ) and is_root_metaconfig: break if not values: self.root.value_unmodified_enable = True @@ -442,10 +464,13 @@ class OutputFamily: else: key = "loaded_from" loaded_from = parent_option.information.get(key, None) - values.append({"value": default_value, - "color": color, - "loaded_from": loaded_from, - }) + values.append( + { + "value": default_value, + "color": color, + "loaded_from": loaded_from, + } + ) if is_root_metaconfig: break elif not values: @@ -462,19 +487,25 @@ class OutputFamily: else: self.root.value_default_enable = True color = self.root.value_default_color - values.append({"value": None, - "color": color, - "loaded_from": loaded_from, - }) + values.append( + { + "value": None, + "color": color, + "loaded_from": loaded_from, + } + ) if self.key_is_description: key_name = option.description() else: key_name = option.name() key = self.colorize( - [{"value": key_name, - "color": variable_color, - "loaded_from": None, - }] + [ + { + "value": key_name, + "color": variable_color, + "loaded_from": None, + } + ] ) value = self.colorize( values, @@ -502,14 +533,14 @@ class OutputFamily: break else: subconfig = self.root.metaconfig - for child in default_owner.split('.')[1:]: + for child in default_owner.split(".")[1:]: subconfig = subconfig.config(child) return subconfig def colorize( self, values, - option = None, + option=None, ) -> str: multi = False ret = [] @@ -561,7 +592,11 @@ class OutputFamily: value: Any, ) -> str: """Dump variable, means transform bool, ... to yaml string""" - if value is not None and not self.root.show_secrets and option.type() == "password": + if ( + value is not None + and not self.root.show_secrets + and option.type() == "password" + ): return "*" * 10 if isinstance(value, str): return value