fix: black
This commit is contained in:
parent
6556c308bf
commit
603bcc33b0
2 changed files with 41 additions and 21 deletions
|
|
@ -96,7 +96,9 @@ class RougailOutputConsole:
|
||||||
except PropertiesOptionError:
|
except PropertiesOptionError:
|
||||||
options_with_error.append(option)
|
options_with_error.append(option)
|
||||||
if options:
|
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)
|
self.errors.append(options)
|
||||||
elif options_with_error:
|
elif options_with_error:
|
||||||
self.errors.append(
|
self.errors.append(
|
||||||
|
|
@ -120,13 +122,15 @@ class RougailOutputConsole:
|
||||||
if errors:
|
if errors:
|
||||||
self.display_errors(errors)
|
self.display_errors(errors)
|
||||||
return False
|
return False
|
||||||
old_path_in_description = self.config.information.get('path_in_description', True)
|
old_path_in_description = self.config.information.get(
|
||||||
self.config.information.set('path_in_description', False)
|
"path_in_description", True
|
||||||
|
)
|
||||||
|
self.config.information.set("path_in_description", False)
|
||||||
self.parse_options(
|
self.parse_options(
|
||||||
self.config,
|
self.config,
|
||||||
self.root,
|
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.header()
|
||||||
self.end()
|
self.end()
|
||||||
return True
|
return True
|
||||||
|
|
@ -183,20 +187,20 @@ class RougailOutputConsole:
|
||||||
leader_obj.add_variable(follower)
|
leader_obj.add_variable(follower)
|
||||||
|
|
||||||
def header(self):
|
def header(self):
|
||||||
header_variable = ''
|
header_variable = ""
|
||||||
if self.variable_default_enable:
|
if self.variable_default_enable:
|
||||||
header_variable += _('Variable') + '\n'
|
header_variable += _("Variable") + "\n"
|
||||||
if self.variable_advanced_enable:
|
if self.variable_advanced_enable:
|
||||||
header_variable += f'[{self.variable_advanced_color}]{_("Undocumented variable")}[/{self.variable_advanced_color}]\n'
|
header_variable += f'[{self.variable_advanced_color}]{_("Undocumented variable")}[/{self.variable_advanced_color}]\n'
|
||||||
if self.variable_advanced_and_modified_enable:
|
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'
|
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:
|
if self.variable_hidden_enable:
|
||||||
header_variable += f'[{self.variable_hidden_color}]{_("Unmodifiable variable")}[/{self.variable_hidden_color}]\n'
|
header_variable += f'[{self.variable_hidden_color}]{_("Unmodifiable variable")}[/{self.variable_hidden_color}]\n'
|
||||||
header_value = ''
|
header_value = ""
|
||||||
if self.value_unmodified_enable:
|
if self.value_unmodified_enable:
|
||||||
header_value = f'[{self.value_unmodified_color}]{_("Default value")}[/{self.value_unmodified_color}]\n'
|
header_value = f'[{self.value_unmodified_color}]{_("Default value")}[/{self.value_unmodified_color}]\n'
|
||||||
if self.value_modified_enable:
|
if self.value_modified_enable:
|
||||||
header_value += _("Modified value") + '\n'
|
header_value += _("Modified value") + "\n"
|
||||||
if self.value_default_enable:
|
if self.value_default_enable:
|
||||||
header_value += f'([{self.value_default_color}]{_("Original default value")}[/{self.value_default_color}])\n'
|
header_value += f'([{self.value_default_color}]{_("Original default value")}[/{self.value_default_color}])\n'
|
||||||
header = Table.grid(padding=1, collapse_padding=True)
|
header = Table.grid(padding=1, collapse_padding=True)
|
||||||
|
|
@ -224,7 +228,8 @@ class RougailOutputConsole:
|
||||||
self,
|
self,
|
||||||
warnings: list,
|
warnings: list,
|
||||||
) -> None:
|
) -> 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",
|
guide_style="bold bright_yellow",
|
||||||
)
|
)
|
||||||
for warning in warnings:
|
for warning in warnings:
|
||||||
|
|
@ -250,7 +255,15 @@ class RougailOutputConsole:
|
||||||
|
|
||||||
class OutputFamily:
|
class OutputFamily:
|
||||||
def __init__(
|
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:
|
) -> None:
|
||||||
if parent is None:
|
if parent is None:
|
||||||
tree = Tree
|
tree = Tree
|
||||||
|
|
@ -258,7 +271,7 @@ class OutputFamily:
|
||||||
tree = parent.add
|
tree = parent.add
|
||||||
if is_leader:
|
if is_leader:
|
||||||
self.tree = tree(
|
self.tree = tree(
|
||||||
":notebook: " + _('{0}:').format(family),
|
":notebook: " + _("{0}:").format(family),
|
||||||
guide_style="bold bright_blue",
|
guide_style="bold bright_blue",
|
||||||
)
|
)
|
||||||
elif no_icon:
|
elif no_icon:
|
||||||
|
|
@ -349,9 +362,11 @@ class OutputFamily:
|
||||||
default_value = None
|
default_value = None
|
||||||
follower_index = option.index()
|
follower_index = option.index()
|
||||||
if follower_index is not None:
|
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:
|
else:
|
||||||
loaded_from = option.information.get('loaded_from', None)
|
loaded_from = option.information.get("loaded_from", None)
|
||||||
if variable_color is None:
|
if variable_color is None:
|
||||||
self.root.variable_default_enable = True
|
self.root.variable_default_enable = True
|
||||||
if value is undefined:
|
if value is undefined:
|
||||||
|
|
@ -376,7 +391,7 @@ class OutputFamily:
|
||||||
)
|
)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
subtree = self.tree.add(
|
subtree = self.tree.add(
|
||||||
":notebook: " + _('{0}:').format(key),
|
":notebook: " + _("{0}:").format(key),
|
||||||
guide_style="bold bright_blue",
|
guide_style="bold bright_blue",
|
||||||
)
|
)
|
||||||
for val in value:
|
for val in value:
|
||||||
|
|
@ -395,7 +410,7 @@ class OutputFamily:
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
if default_value is None:
|
if default_value is None:
|
||||||
default_value = []
|
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_value = len(value)
|
||||||
len_default_value = len(default_value)
|
len_default_value = len(default_value)
|
||||||
len_values = max(len_value, len_default_value)
|
len_values = max(len_value, len_default_value)
|
||||||
|
|
@ -420,7 +435,7 @@ class OutputFamily:
|
||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
if value is None:
|
if value is None:
|
||||||
ret = ''
|
ret = ""
|
||||||
else:
|
else:
|
||||||
if option:
|
if option:
|
||||||
value = self.convert_value(
|
value = self.convert_value(
|
||||||
|
|
@ -431,7 +446,10 @@ class OutputFamily:
|
||||||
ret = f"[{color}]{value}[/{color}]"
|
ret = f"[{color}]{value}[/{color}]"
|
||||||
else:
|
else:
|
||||||
ret = value
|
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
|
self.root.value_default_enable = True
|
||||||
default_value_color = self.root.value_default_color
|
default_value_color = self.root.value_default_color
|
||||||
default_value = self.convert_value(option, default_value)
|
default_value = self.convert_value(option, default_value)
|
||||||
|
|
@ -443,9 +461,9 @@ class OutputFamily:
|
||||||
else:
|
else:
|
||||||
ret = f"[{default_value_color}]{default_value}[/{default_value_color}]"
|
ret = f"[{default_value_color}]{default_value}[/{default_value_color}]"
|
||||||
if loaded_from:
|
if loaded_from:
|
||||||
ret += f' ({loaded_from})'
|
ret += f" ({loaded_from})"
|
||||||
elif loaded_from:
|
elif loaded_from:
|
||||||
ret += f' ({loaded_from})'
|
ret += f" ({loaded_from})"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def convert_value(
|
def convert_value(
|
||||||
|
|
@ -455,7 +473,7 @@ class OutputFamily:
|
||||||
) -> str:
|
) -> str:
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
print(value)
|
print(value)
|
||||||
raise Exception('pfff')
|
raise Exception("pfff")
|
||||||
"""Dump variable, means transform bool, ... to yaml string"""
|
"""Dump variable, means transform bool, ... to yaml string"""
|
||||||
if not self.root.show_secrets and option.type() == "password":
|
if not self.root.show_secrets and option.type() == "password":
|
||||||
return "*" * 10
|
return "*" * 10
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from gettext import translation
|
from gettext import translation
|
||||||
from pathlib import Path
|
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
|
_ = t.gettext
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue