fix: black

This commit is contained in:
egarette@silique.fr 2025-05-11 19:13:12 +02:00
parent 561d117d4d
commit 263dae2b2c
4 changed files with 72 additions and 29 deletions

View file

@ -272,7 +272,7 @@ class Annotator(Walk):
return True
def _calculation_to_information_variable(
self, variable_path: str, values, prop: str, version: str, path: str
self, variable_path: str, values, prop: str, version: str, path: str
) -> str:
# is optional
variable = self.objectspace.paths.get_with_dynamic(

View file

@ -171,7 +171,7 @@ class RougailOutputDoc(Examples):
return True
calculation = child.information.get(f"{hidden_property}_calculation", None)
if calculation and calculation.get('type') == 'variable':
if calculation and calculation.get("type") == "variable":
variable_path, value, condition = calculation["value"]
variable = self.conf.forcepermissive.option(variable_path)
try:
@ -180,8 +180,16 @@ class RougailOutputDoc(Examples):
pass
else:
uncalculated = variable.value.get(uncalculated=True)
if not isinstance(uncalculated, Calculation) and self._is_inaccessible_user_data(variable) and (condition == 'when' and value == variable_value or
condition == 'when_not' and value != variable_value):
if (
not isinstance(uncalculated, Calculation)
and self._is_inaccessible_user_data(variable)
and (
condition == "when"
and value == variable_value
or condition == "when_not"
and value != variable_value
)
):
return True
if not child.isoptiondescription():
for hidden_property in self.disabled_modes:
@ -245,9 +253,9 @@ class RougailOutputDoc(Examples):
return None
def _parse_variable_follower_with_index(
self, variable, leader: dict, path: str, informations: dict
self, variable, leader: dict, path: str, informations: dict
) -> None:
if not self.example or (variable.index() + 1) > len(leader['example'][-1]):
if not self.example or (variable.index() + 1) > len(leader["example"][-1]):
return
informations[path]["example"][-1][variable.index()] = self._get_example(
variable, informations[path], None
@ -262,10 +270,14 @@ class RougailOutputDoc(Examples):
dynamic_variable["example"].append(
self._get_example(variable, dynamic_variable, leader)
)
description = self.formater.to_phrase(variable.description(uncalculated=True))
description = self.formater.to_phrase(
variable.description(uncalculated=True)
)
if "{{ identifier }}" in description:
description = self._convert_description(description, variable)
dynamic_variable["descriptions"].append(self.formater.to_phrase(description))
dynamic_variable["descriptions"].append(
self.formater.to_phrase(description)
)
if variable.isleader():
return dynamic_variable
return None
@ -335,7 +347,9 @@ class RougailOutputDoc(Examples):
)
self._populate(variable, informations)
if "description" in informations:
informations["descriptions"] = [self.formater.to_phrase(informations.pop("description"))]
informations["descriptions"] = [
self.formater.to_phrase(informations.pop("description"))
]
if variable.ismulti():
multi = not variable.isfollower() or variable.issubmulti()
else:
@ -363,7 +377,8 @@ class RougailOutputDoc(Examples):
informations["names"] = [obj.name()]
description = obj.description(uncalculated=True)
if obj.name(uncalculated=True) == description and (
not obj.isoptiondescription() or (self.support_namespace and obj.group_type() is not groups.namespace)
not obj.isoptiondescription()
or (self.support_namespace and obj.group_type() is not groups.namespace)
):
warning = _('No attribute "description" for "{0}" in {1}').format(
obj.path(uncalculated=True),
@ -392,7 +407,10 @@ class RougailOutputDoc(Examples):
informations["example"] = [example]
informations["mandatory_without_value"] = "mandatory" in variable.property.get(
uncalculated=True
) and (not variable.information.get("default_value_makes_sense", True) or variable.value.get(uncalculated=True) in [None, []])
) and (
not variable.information.get("default_value_makes_sense", True)
or variable.value.get(uncalculated=True) in [None, []]
)
def _get_example(self, variable, informations: dict, leader):
example = informations.get("examples")
@ -480,7 +498,11 @@ class RougailOutputDoc(Examples):
if not isinstance(val, Calculation):
default = informations.get("default")
if default is not None and val == default:
choices[idx] = str(val) + " " + self.formater.bold("" + _("(default)"))
choices[idx] = (
str(val)
+ " "
+ self.formater.bold("" + _("(default)"))
)
informations["display_default"] = False
continue
choices[idx] = self._to_string(variable, "choice", f"_{idx}")
@ -600,7 +622,9 @@ class RougailOutputDoc(Examples):
variable = None
else:
uncalculated = variable.value.get(uncalculated=True)
if not isinstance(uncalculated, Calculation) and self._is_inaccessible_user_data(variable):
if not isinstance(
uncalculated, Calculation
) and self._is_inaccessible_user_data(variable):
return None
if variable and self._is_inaccessible_user_data(variable):
msg = _("depends on an undocumented variable")
@ -626,10 +650,16 @@ class RougailOutputDoc(Examples):
hidden_msg = _("the value of an undocumented variable")
# if "{{ identifier }}" in calculation["value"] and calculation["value"] in self.dynamic_paths:
if "{{ identifier }}" in calculation["ori_path"]:
if calculation["value"] == calculation['ori_path']:
if calculation["value"] == calculation["ori_path"]:
regexp = None
else:
regexp = compile("^" + calculation["ori_path"].replace("{{ identifier }}", "(.*)") + "$")
regexp = compile(
"^"
+ calculation["ori_path"].replace(
"{{ identifier }}", "(.*)"
)
+ "$"
)
informations = [self.dynamic_paths[calculation["value"]]]
values = []
all_is_undocumented = None
@ -643,10 +673,12 @@ class RougailOutputDoc(Examples):
msg = hidden_msg
else:
if regexp:
display_path = calculation['ori_path']
display_path = calculation["ori_path"]
for identifier in regexp.findall(path):
display_path = display_path.replace(
"{{ identifier }}", self.formater.italic(identifier), 1
"{{ identifier }}",
self.formater.italic(identifier),
1,
)
else:
display_path = get_display_path(information, idx)
@ -668,16 +700,22 @@ class RougailOutputDoc(Examples):
uncalculated = variable.value.get(uncalculated=True)
except PropertiesOptionError:
true_msg = None
# true_msg = _("depends on an undocumented variable")
# true_msg = _("depends on an undocumented variable")
else:
if uncalculated and not isinstance(uncalculated, Calculation):
if uncalculated and not isinstance(
uncalculated, Calculation
):
if isinstance(uncalculated, list):
uncalculated = self.formater.list(uncalculated)
true_msg = _('(from an undocumented variable){0}').format(uncalculated)
true_msg = _(
"(from an undocumented variable){0}"
).format(uncalculated)
else:
if not isinstance(uncalculated, str):
uncalculated = dump(uncalculated)
true_msg = _('{0} (from an undocumented variable)').format(uncalculated)
true_msg = _(
"{0} (from an undocumented variable)"
).format(uncalculated)
else:
true_msg = _("depends on an undocumented variable")
if true_msg:

View file

@ -15,6 +15,7 @@ details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from typing import List
from ..i18n import _
@ -27,12 +28,13 @@ class Formater(CommonFormater):
name = "console"
level = 10
enter_table = "\n"
titles_color = {"title1": "bright_cyan underline bold",
"title2": "bright_green underline bold",
"title3": "green1 underline bold",
"title4": "green3 underline bold",
"title5": "dark_green underline bold",
}
titles_color = {
"title1": "bright_cyan underline bold",
"title2": "bright_green underline bold",
"title3": "green1 underline bold",
"title4": "green3 underline bold",
"title5": "dark_green underline bold",
}
def __init__(self) -> None:
self.max_line = 0
@ -43,6 +45,7 @@ class Formater(CommonFormater):
from rich.table import Table
from rich.theme import Theme
from rich.console import Console
self.rich_table = Table
custom_theme = Theme(self.titles_color)
@ -125,7 +128,7 @@ class Formater(CommonFormater):
) -> str:
"""Add a link"""
return self.prop(comment, False)
#return f"{comment} ({link})"
# return f"{comment} ({link})"
def columns(
self,

View file

@ -253,7 +253,9 @@ class CommonFormater:
for help_ in helps:
msg.append(help_.strip() + ENTER)
if "identifiers" in informations:
msg.append(self.section(_("Identifiers"), informations["identifiers"]) + ENTER)
msg.append(
self.section(_("Identifiers"), informations["identifiers"]) + ENTER
)
return msg
def family_description(self, informations: dict) -> str():