fix: black

This commit is contained in:
egarette@silique.fr 2026-07-10 18:51:26 +02:00
parent 878fc246dd
commit 871a0932f5
3 changed files with 42 additions and 17 deletions

View file

@ -24,4 +24,3 @@ RougailOutput = RougailOutputEnvironment
__all__ = ("RougailOutputEnvironment", "__version__")

View file

@ -16,7 +16,6 @@ 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 .i18n import _
@ -24,7 +23,8 @@ def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = [f"""
options = [
f"""
environment:
exists: true
redefine: true
@ -36,7 +36,8 @@ environment:
return_type: boolean
description: >-
{_('if environment is not in "step.output" and not in "step.user_data"')}
""", f"""
""",
f"""
environment:
exists: false
type: family
@ -51,7 +52,8 @@ environment:
variable: step.output
when_not: environment
propertyerror: false
""", f"""
""",
f"""
environment:
output:
@ -117,7 +119,8 @@ environment:
{{% endif %}}
description: >-
{_('if "_.multi_in_array" the value is ";" otherwise the value is ","')}
"""]
""",
]
return {
"name": "environment",

View file

@ -67,15 +67,23 @@ class RougailOutputEnvironment:
else:
self.booleans = {True: 1, False: 0}
self.upper = self.rougailconfig["environment.output.upper"]
self.path_is_variable_name = self.rougailconfig["environment.output.path_is_variable_name"]
self.path_is_variable_name = self.rougailconfig[
"environment.output.path_is_variable_name"
]
if self.path_is_variable_name:
self.custom_separator = self.rougailconfig["environment.output.custom_separator"]
self.custom_separator = self.rougailconfig[
"environment.output.custom_separator"
]
else:
self.custom_separator = None
self.multi_in_array = self.rougailconfig["environment.output.multi_in_array"]
if not self.multi_in_array:
self.multi_separator = self.rougailconfig["environment.output.multi_separator"]
self.submulti_separator = self.rougailconfig["environment.output.submulti_separator"]
self.multi_separator = self.rougailconfig[
"environment.output.multi_separator"
]
self.submulti_separator = self.rougailconfig[
"environment.output.submulti_separator"
]
ret = self.exporter()
if isinstance(self.dico, str):
value = self.dico
@ -157,8 +165,10 @@ class RougailOutputEnvironment:
def set_value(self, name, values):
if name in self.dico:
raise ExtensionError(_('The variable name "{0}" is duplicated').format(name))
self.dico[name] = f'{name}={self.conv_values(name, values)}'
raise ExtensionError(
_('The variable name "{0}" is duplicated').format(name)
)
self.dico[name] = f"{name}={self.conv_values(name, values)}"
def conv_values(self, name, values):
if isinstance(values, list):
@ -175,12 +185,20 @@ class RougailOutputEnvironment:
for value in values:
value = self.conv_to_string(value)
if self.submulti_separator in value:
raise ExtensionError(_('the character "{0}" is a sub multi separator, this character must not in the "{1}" value').format(self.submulti_separator, name))
raise ExtensionError(
_(
'the character "{0}" is a sub multi separator, this character must not in the "{1}" value'
).format(self.submulti_separator, name)
)
new_values.append(value)
values = self.submulti_separator.join(new_values)
values = self.conv_to_string(values)
if not self.multi_in_array and self.multi_separator in values:
raise ExtensionError(_('the character "{0}" is a multi separator, this character must not in the "{1}" value').format(self.multi_separator, name))
raise ExtensionError(
_(
'the character "{0}" is a multi separator, this character must not in the "{1}" value'
).format(self.multi_separator, name)
)
return quote(values)
def conv_to_string(self, values):
@ -207,10 +225,15 @@ class RougailOutputEnvironment:
if not follower_name:
follower_name = self.get_name(follower)
followers_name[follower_path] = follower_name
followers_data.setdefault(follower_name, {})[follower.index()] = follower.value.get()
followers_data.setdefault(follower_name, {})[
follower.index()
] = follower.value.get()
leader_len = len(leader_values)
for name, values in followers_data.items():
self.set_value(name, [values[idx] if idx in values else "" for idx in range(leader_len)])
self.set_value(
name,
[values[idx] if idx in values else "" for idx in range(leader_len)],
)
RougailOutput = RougailOutputEnvironment