Reviewed-on: #32
This commit is contained in:
parent
e99d0fde3c
commit
8550a125a1
10 changed files with 98 additions and 0 deletions
|
@ -55,6 +55,8 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
if variable.version != '1.0' and variable.type == 'port':
|
||||
self._convert_port(variable)
|
||||
self._convert_value(variable)
|
||||
|
||||
def _convert_value(
|
||||
|
@ -98,6 +100,14 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
self.objectspace.default_multi[variable.path] = variable.default
|
||||
variable.default = None
|
||||
|
||||
def _convert_port(self, variable) -> None:
|
||||
if variable.multi is False and isinstance(variable.default, int):
|
||||
variable.default = str(variable.default)
|
||||
elif variable.multi is True and variable.default:
|
||||
for idx, value in enumerate(variable.default):
|
||||
if isinstance(value, int):
|
||||
variable.default[idx] = str(value)
|
||||
|
||||
def valid_choices(self) -> None:
|
||||
"""A variable with type "Choice" that is not mandatory must has "nil" value"""
|
||||
for variable in self.get_variables():
|
||||
|
|
0
tests/dictionaries/00_6port/__init__.py
Normal file
0
tests/dictionaries/00_6port/__init__.py
Normal file
13
tests/dictionaries/00_6port/dictionaries/rougail/00-base.yml
Normal file
13
tests/dictionaries/00_6port/dictionaries/rougail/00-base.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
version: '1.1'
|
||||
variable1:
|
||||
description: a port variable
|
||||
type: port
|
||||
variable2:
|
||||
description: a port variable with default value
|
||||
type: port
|
||||
default: '8080'
|
||||
variable3:
|
||||
description: a port variable with integer default value
|
||||
type: port
|
||||
default: 8080
|
14
tests/dictionaries/00_6port/makedict/after.json
Normal file
14
tests/dictionaries/00_6port/makedict/after.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"rougail.variable1": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
},
|
||||
"rougail.variable2": {
|
||||
"owner": "default",
|
||||
"value": "8080"
|
||||
},
|
||||
"rougail.variable3": {
|
||||
"owner": "default",
|
||||
"value": "8080"
|
||||
}
|
||||
}
|
5
tests/dictionaries/00_6port/makedict/base.json
Normal file
5
tests/dictionaries/00_6port/makedict/base.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rougail.variable1": null,
|
||||
"rougail.variable2": "8080",
|
||||
"rougail.variable3": "8080"
|
||||
}
|
14
tests/dictionaries/00_6port/makedict/before.json
Normal file
14
tests/dictionaries/00_6port/makedict/before.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"rougail.variable1": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
},
|
||||
"rougail.variable2": {
|
||||
"owner": "default",
|
||||
"value": "8080"
|
||||
},
|
||||
"rougail.variable3": {
|
||||
"owner": "default",
|
||||
"value": "8080"
|
||||
}
|
||||
}
|
1
tests/dictionaries/00_6port/makedict/mandatory.json
Normal file
1
tests/dictionaries/00_6port/makedict/mandatory.json
Normal file
|
@ -0,0 +1 @@
|
|||
["rougail.variable1"]
|
12
tests/dictionaries/00_6port/tiramisu/base.py
Normal file
12
tests/dictionaries/00_6port/tiramisu/base.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = PortOption(name="variable1", doc="a port variable", allow_private=True, properties=frozenset({"basic", "mandatory"}), informations={'type': 'port'})
|
||||
option_3 = PortOption(name="variable2", doc="a port variable with default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
option_4 = PortOption(name="variable3", doc="a port variable with integer default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3, option_4], properties=frozenset({"basic"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
18
tests/dictionaries/00_6port/tiramisu/multi.py
Normal file
18
tests/dictionaries/00_6port/tiramisu/multi.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_3 = PortOption(name="variable1", doc="a port variable", allow_private=True, properties=frozenset({"basic", "mandatory"}), informations={'type': 'port'})
|
||||
option_4 = PortOption(name="variable2", doc="a port variable with default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
option_5 = PortOption(name="variable3", doc="a port variable with integer default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4, option_5], properties=frozenset({"basic"}))
|
||||
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
|
||||
option_8 = PortOption(name="variable1", doc="a port variable", allow_private=True, properties=frozenset({"basic", "mandatory"}), informations={'type': 'port'})
|
||||
option_9 = PortOption(name="variable2", doc="a port variable with default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
option_10 = PortOption(name="variable3", doc="a port variable with integer default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
optiondescription_7 = OptionDescription(name="rougail", doc="Rougail", children=[option_8, option_9, option_10], properties=frozenset({"basic"}))
|
||||
optiondescription_6 = OptionDescription(name="2", doc="2", children=[optiondescription_7], properties=frozenset({"basic"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_6])
|
11
tests/dictionaries/00_6port/tiramisu/no_namespace.py
Normal file
11
tests/dictionaries/00_6port/tiramisu/no_namespace.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = PortOption(name="variable1", doc="a port variable", allow_private=True, properties=frozenset({"basic", "mandatory"}), informations={'type': 'port'})
|
||||
option_2 = PortOption(name="variable2", doc="a port variable with default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
option_3 = PortOption(name="variable3", doc="a port variable with integer default value", default="8080", allow_private=True, properties=frozenset({"mandatory", "standard"}), informations={'type': 'port'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])
|
Loading…
Reference in a new issue