fix: black
This commit is contained in:
parent
878fc246dd
commit
871a0932f5
3 changed files with 42 additions and 17 deletions
|
|
@ -24,4 +24,3 @@ RougailOutput = RougailOutputEnvironment
|
||||||
|
|
||||||
|
|
||||||
__all__ = ("RougailOutputEnvironment", "__version__")
|
__all__ = ("RougailOutputEnvironment", "__version__")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,7 +23,8 @@ def get_rougail_config(
|
||||||
*,
|
*,
|
||||||
backward_compatibility=True,
|
backward_compatibility=True,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
options = [f"""
|
options = [
|
||||||
|
f"""
|
||||||
environment:
|
environment:
|
||||||
exists: true
|
exists: true
|
||||||
redefine: true
|
redefine: true
|
||||||
|
|
@ -36,7 +36,8 @@ environment:
|
||||||
return_type: boolean
|
return_type: boolean
|
||||||
description: >-
|
description: >-
|
||||||
{_('if environment is not in "step.output" and not in "step.user_data"')}
|
{_('if environment is not in "step.output" and not in "step.user_data"')}
|
||||||
""", f"""
|
""",
|
||||||
|
f"""
|
||||||
environment:
|
environment:
|
||||||
exists: false
|
exists: false
|
||||||
type: family
|
type: family
|
||||||
|
|
@ -51,7 +52,8 @@ environment:
|
||||||
variable: step.output
|
variable: step.output
|
||||||
when_not: environment
|
when_not: environment
|
||||||
propertyerror: false
|
propertyerror: false
|
||||||
""", f"""
|
""",
|
||||||
|
f"""
|
||||||
environment:
|
environment:
|
||||||
|
|
||||||
output:
|
output:
|
||||||
|
|
@ -117,7 +119,8 @@ environment:
|
||||||
{{% endif %}}
|
{{% endif %}}
|
||||||
description: >-
|
description: >-
|
||||||
{_('if "_.multi_in_array" the value is ";" otherwise the value is ","')}
|
{_('if "_.multi_in_array" the value is ";" otherwise the value is ","')}
|
||||||
"""]
|
""",
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"name": "environment",
|
"name": "environment",
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,23 @@ class RougailOutputEnvironment:
|
||||||
else:
|
else:
|
||||||
self.booleans = {True: 1, False: 0}
|
self.booleans = {True: 1, False: 0}
|
||||||
self.upper = self.rougailconfig["environment.output.upper"]
|
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:
|
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:
|
else:
|
||||||
self.custom_separator = None
|
self.custom_separator = None
|
||||||
self.multi_in_array = self.rougailconfig["environment.output.multi_in_array"]
|
self.multi_in_array = self.rougailconfig["environment.output.multi_in_array"]
|
||||||
if not self.multi_in_array:
|
if not self.multi_in_array:
|
||||||
self.multi_separator = self.rougailconfig["environment.output.multi_separator"]
|
self.multi_separator = self.rougailconfig[
|
||||||
self.submulti_separator = self.rougailconfig["environment.output.submulti_separator"]
|
"environment.output.multi_separator"
|
||||||
|
]
|
||||||
|
self.submulti_separator = self.rougailconfig[
|
||||||
|
"environment.output.submulti_separator"
|
||||||
|
]
|
||||||
ret = self.exporter()
|
ret = self.exporter()
|
||||||
if isinstance(self.dico, str):
|
if isinstance(self.dico, str):
|
||||||
value = self.dico
|
value = self.dico
|
||||||
|
|
@ -157,8 +165,10 @@ class RougailOutputEnvironment:
|
||||||
|
|
||||||
def set_value(self, name, values):
|
def set_value(self, name, values):
|
||||||
if name in self.dico:
|
if name in self.dico:
|
||||||
raise ExtensionError(_('The variable name "{0}" is duplicated').format(name))
|
raise ExtensionError(
|
||||||
self.dico[name] = f'{name}={self.conv_values(name, values)}'
|
_('The variable name "{0}" is duplicated').format(name)
|
||||||
|
)
|
||||||
|
self.dico[name] = f"{name}={self.conv_values(name, values)}"
|
||||||
|
|
||||||
def conv_values(self, name, values):
|
def conv_values(self, name, values):
|
||||||
if isinstance(values, list):
|
if isinstance(values, list):
|
||||||
|
|
@ -175,12 +185,20 @@ class RougailOutputEnvironment:
|
||||||
for value in values:
|
for value in values:
|
||||||
value = self.conv_to_string(value)
|
value = self.conv_to_string(value)
|
||||||
if self.submulti_separator in 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)
|
new_values.append(value)
|
||||||
values = self.submulti_separator.join(new_values)
|
values = self.submulti_separator.join(new_values)
|
||||||
values = self.conv_to_string(values)
|
values = self.conv_to_string(values)
|
||||||
if not self.multi_in_array and self.multi_separator in 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)
|
return quote(values)
|
||||||
|
|
||||||
def conv_to_string(self, values):
|
def conv_to_string(self, values):
|
||||||
|
|
@ -207,10 +225,15 @@ class RougailOutputEnvironment:
|
||||||
if not follower_name:
|
if not follower_name:
|
||||||
follower_name = self.get_name(follower)
|
follower_name = self.get_name(follower)
|
||||||
followers_name[follower_path] = follower_name
|
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)
|
leader_len = len(leader_values)
|
||||||
for name, values in followers_data.items():
|
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
|
RougailOutput = RougailOutputEnvironment
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue