feat: display layers if actived
This commit is contained in:
parent
ae8760ffc0
commit
0b69b3d812
1 changed files with 39 additions and 11 deletions
|
|
@ -49,6 +49,7 @@ class RougailOutputConsole:
|
|||
user_data_errors: Optional[list] = None,
|
||||
user_data_warnings: Optional[list] = None,
|
||||
config_owner_is_path: bool = False,
|
||||
layer_datas = None,
|
||||
**kwargs
|
||||
) -> None:
|
||||
if rougailconfig is None:
|
||||
|
|
@ -58,6 +59,7 @@ class RougailOutputConsole:
|
|||
self.rougailconfig = rougailconfig
|
||||
self.config = config
|
||||
self.metaconfig = metaconfig
|
||||
self.layer_datas = layer_datas
|
||||
self.config_owner_is_path = config_owner_is_path
|
||||
self.is_mandatory = self.rougailconfig["console.mandatory"]
|
||||
self.show_secrets = self.rougailconfig["console.show_secrets"]
|
||||
|
|
@ -102,7 +104,10 @@ class RougailOutputConsole:
|
|||
current_options = options
|
||||
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])
|
||||
|
||||
|
|
@ -114,9 +119,13 @@ class RougailOutputConsole:
|
|||
if 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:"
|
||||
): [option.description() for option in options_with_error]})
|
||||
): variables})
|
||||
|
||||
def exporter(self) -> bool:
|
||||
if self.is_mandatory:
|
||||
|
|
@ -197,15 +206,15 @@ class RougailOutputConsole:
|
|||
leader_obj.add_variable(follower)
|
||||
|
||||
def header(self):
|
||||
header_variable = ""
|
||||
caption_line = ""
|
||||
if self.variable_default_enable:
|
||||
header_variable += _("Variable") + "\n"
|
||||
caption_line += _("Variable") + "\n"
|
||||
if self.variable_advanced_enable:
|
||||
header_variable += f'[{self.variable_advanced_color}]{_("Undocumented variable")}[/{self.variable_advanced_color}]\n'
|
||||
caption_line += 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'
|
||||
caption_line += 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'
|
||||
caption_line += f'[{self.variable_hidden_color}]{_("Unmodifiable variable")}[/{self.variable_hidden_color}]\n'
|
||||
header_value = ""
|
||||
if self.value_unmodified_enable:
|
||||
header_value = f'[{self.value_unmodified_color}]{_("Default value")}[/{self.value_unmodified_color}]\n'
|
||||
|
|
@ -213,10 +222,29 @@ class RougailOutputConsole:
|
|||
header_value += _("Modified value") + "\n"
|
||||
if self.value_default_enable:
|
||||
header_value += f'([{self.value_default_color}]:hourglass_flowing_sand: {_("Original default value")}[/{self.value_default_color}])\n'
|
||||
header = Table.grid(padding=1, collapse_padding=True)
|
||||
header.pad_edge = False
|
||||
header.add_row(header_variable[:-1], header_value[:-1])
|
||||
self.out.append(Panel.fit(header, title=_("Caption")))
|
||||
caption = Table.grid(padding=1, collapse_padding=True)
|
||||
caption.pad_edge = False
|
||||
caption.add_row(caption_line[:-1], header_value[:-1])
|
||||
self.out.append(Panel.fit(caption, title=_("Caption")))
|
||||
#
|
||||
layers = Table.grid(padding=1, collapse_padding=True)
|
||||
caption.pad_edge = False
|
||||
if self.layer_datas:
|
||||
max_len = 0
|
||||
for datas in self.layer_datas.values():
|
||||
for data in datas.values():
|
||||
max_len = max(max_len, len(data))
|
||||
display_layers = ["" for i in range(max_len)]
|
||||
for datas in self.layer_datas.values():
|
||||
for data in datas.values():
|
||||
last_index = len(data) - 1
|
||||
for idx in range(max_len):
|
||||
if last_index < idx:
|
||||
display_layers[idx] += "\n"
|
||||
else:
|
||||
display_layers[idx] += data[idx] + "\n"
|
||||
layers.add_row(*[layer[:-1] for layer in display_layers])
|
||||
self.out.append(Panel.fit(layers, title=_("Layers")))
|
||||
|
||||
def display_errors(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Reference in a new issue