pouet
This commit is contained in:
parent
0c02807775
commit
3f378194ba
8 changed files with 367 additions and 140 deletions
|
@ -46,7 +46,7 @@ def convert_boolean(value: str) -> bool:
|
||||||
return True
|
return True
|
||||||
elif value == "false":
|
elif value == "false":
|
||||||
return False
|
return False
|
||||||
elif value in ['', None]:
|
elif value in ["", None]:
|
||||||
return None
|
return None
|
||||||
raise Exception(f'unknown boolean value "{value}"')
|
raise Exception(f'unknown boolean value "{value}"')
|
||||||
|
|
||||||
|
@ -61,34 +61,45 @@ CONVERT_OPTION = {
|
||||||
"unix_filename": dict(opttype="FilenameOption", example="/tmp/myfile.txt"),
|
"unix_filename": dict(opttype="FilenameOption", example="/tmp/myfile.txt"),
|
||||||
"date": dict(opttype="DateOption", example="2000-01-01"),
|
"date": dict(opttype="DateOption", example="2000-01-01"),
|
||||||
"unix_user": dict(opttype="UsernameOption", example="username"),
|
"unix_user": dict(opttype="UsernameOption", example="username"),
|
||||||
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}, example="1.1.1.1"),
|
"ip": dict(
|
||||||
|
opttype="IPOption", initkwargs={"allow_reserved": True}, example="1.1.1.1"
|
||||||
|
),
|
||||||
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
|
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
|
||||||
"netmask": dict(opttype="NetmaskOption", example="255.255.255.0"),
|
"netmask": dict(opttype="NetmaskOption", example="255.255.255.0"),
|
||||||
"network": dict(opttype="NetworkOption", example="1.1.1.0"),
|
"network": dict(opttype="NetworkOption", example="1.1.1.0"),
|
||||||
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
|
"network_cidr": dict(
|
||||||
|
opttype="NetworkOption", initkwargs={"cidr": True}, example="1.1.1.0/24"
|
||||||
|
),
|
||||||
"broadcast": dict(opttype="BroadcastOption", example="1.1.1.255"),
|
"broadcast": dict(opttype="BroadcastOption", example="1.1.1.255"),
|
||||||
"netbios": dict(
|
"netbios": dict(
|
||||||
opttype="DomainnameOption",
|
opttype="DomainnameOption",
|
||||||
initkwargs={"type": "netbios", "warnings_only": True},
|
initkwargs={"type": "netbios", "warnings_only": True},
|
||||||
example="example"
|
example="example",
|
||||||
),
|
),
|
||||||
"domainname": dict(
|
"domainname": dict(
|
||||||
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False},
|
opttype="DomainnameOption",
|
||||||
example="example.net"
|
initkwargs={"type": "domainname", "allow_ip": False},
|
||||||
|
example="example.net",
|
||||||
),
|
),
|
||||||
"hostname": dict(
|
"hostname": dict(
|
||||||
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False},
|
opttype="DomainnameOption",
|
||||||
example="example"
|
initkwargs={"type": "hostname", "allow_ip": False},
|
||||||
|
example="example",
|
||||||
),
|
),
|
||||||
"web_address": dict(
|
"web_address": dict(
|
||||||
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True},
|
opttype="URLOption",
|
||||||
example="https://example.net"
|
initkwargs={"allow_ip": False, "allow_without_dot": True},
|
||||||
|
example="https://example.net",
|
||||||
|
),
|
||||||
|
"port": dict(
|
||||||
|
opttype="PortOption", initkwargs={"allow_private": True}, example="111"
|
||||||
),
|
),
|
||||||
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}, example="111"),
|
|
||||||
"mac": dict(opttype="MACOption", example="00:00:00:00:00"),
|
"mac": dict(opttype="MACOption", example="00:00:00:00:00"),
|
||||||
"unix_permissions": dict(
|
"unix_permissions": dict(
|
||||||
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int,
|
opttype="PermissionsOption",
|
||||||
example="644"
|
initkwargs={"warnings_only": True},
|
||||||
|
func=int,
|
||||||
|
example="644",
|
||||||
),
|
),
|
||||||
"choice": dict(opttype="ChoiceOption", example="a_choice"),
|
"choice": dict(opttype="ChoiceOption", example="a_choice"),
|
||||||
#
|
#
|
||||||
|
@ -100,7 +111,8 @@ class Param(BaseModel):
|
||||||
key: str
|
key: str
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
|
self,
|
||||||
path,
|
path,
|
||||||
attribute,
|
attribute,
|
||||||
family_is_dynamic,
|
family_is_dynamic,
|
||||||
|
@ -127,12 +139,13 @@ class SuffixParam(Param):
|
||||||
type: str
|
type: str
|
||||||
suffix: Optional[int] = None
|
suffix: Optional[int] = None
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
|
self,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
if not kwargs['family_is_dynamic']:
|
if not kwargs["family_is_dynamic"]:
|
||||||
msg = f'suffix parameter for "{kwargs["attribute"]}" in "{kwargs["path"]}" cannot be set none dynamic family'
|
msg = f'suffix parameter for "{kwargs["attribute"]}" in "{kwargs["path"]}" cannot be set none dynamic family'
|
||||||
raise DictConsistencyError(msg, 10, kwargs['xmlfiles'])
|
raise DictConsistencyError(msg, 10, kwargs["xmlfiles"])
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,17 +158,17 @@ class InformationParam(Param):
|
||||||
class IndexParam(Param):
|
class IndexParam(Param):
|
||||||
type: str
|
type: str
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
|
self,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
if not kwargs["is_follower"]:
|
if not kwargs["is_follower"]:
|
||||||
msg = f'the variable "{kwargs["path"]}" is not a follower, so cannot have index type for param in "{kwargs["attribute"]}"'
|
msg = f'the variable "{kwargs["path"]}" is not a follower, so cannot have index type for param in "{kwargs["attribute"]}"'
|
||||||
raise DictConsistencyError(msg, 25, kwargs['xmlfiles'])
|
raise DictConsistencyError(msg, 25, kwargs["xmlfiles"])
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PARAM_TYPES = {
|
PARAM_TYPES = {
|
||||||
"any": AnyParam,
|
"any": AnyParam,
|
||||||
"variable": VariableParam,
|
"variable": VariableParam,
|
||||||
|
@ -170,8 +183,8 @@ class Calculation(BaseModel):
|
||||||
path: str
|
path: str
|
||||||
inside_list: bool
|
inside_list: bool
|
||||||
version: str
|
version: str
|
||||||
ori_path: Optional[str]=None
|
ori_path: Optional[str] = None
|
||||||
default_values: Any=None
|
default_values: Any = None
|
||||||
namespace: Optional[str]
|
namespace: Optional[str]
|
||||||
xmlfiles: List[str]
|
xmlfiles: List[str]
|
||||||
|
|
||||||
|
@ -195,7 +208,12 @@ class Calculation(BaseModel):
|
||||||
else:
|
else:
|
||||||
path = self.ori_path
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
param["variable"], self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
param["variable"],
|
||||||
|
self.path_prefix,
|
||||||
|
path,
|
||||||
|
self.version,
|
||||||
|
self.namespace,
|
||||||
|
self.xmlfiles,
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
if not param.get("optional"):
|
if not param.get("optional"):
|
||||||
|
@ -214,7 +232,12 @@ class Calculation(BaseModel):
|
||||||
else:
|
else:
|
||||||
path = self.ori_path
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
param["variable"], self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
param["variable"],
|
||||||
|
self.path_prefix,
|
||||||
|
path,
|
||||||
|
self.version,
|
||||||
|
self.namespace,
|
||||||
|
self.xmlfiles,
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
msg = f'cannot find variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}"'
|
msg = f'cannot find variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}"'
|
||||||
|
@ -231,7 +254,14 @@ class Calculation(BaseModel):
|
||||||
|
|
||||||
class JinjaCalculation(Calculation):
|
class JinjaCalculation(Calculation):
|
||||||
attribute_name: Literal[
|
attribute_name: Literal[
|
||||||
"frozen", "hidden", "mandatory", "disabled", "default", "validators", "choices", "dynamic"
|
"frozen",
|
||||||
|
"hidden",
|
||||||
|
"mandatory",
|
||||||
|
"disabled",
|
||||||
|
"default",
|
||||||
|
"validators",
|
||||||
|
"choices",
|
||||||
|
"dynamic",
|
||||||
]
|
]
|
||||||
jinja: StrictStr
|
jinja: StrictStr
|
||||||
params: Optional[List[Param]] = None
|
params: Optional[List[Param]] = None
|
||||||
|
@ -264,7 +294,7 @@ class JinjaCalculation(Calculation):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if self.default_values:
|
if self.default_values:
|
||||||
default["params"]['__default_value'] = self.default_values
|
default["params"]["__default_value"] = self.default_values
|
||||||
if add_help:
|
if add_help:
|
||||||
default["help"] = function + "_help"
|
default["help"] = function + "_help"
|
||||||
if self.params:
|
if self.params:
|
||||||
|
@ -340,7 +370,7 @@ class JinjaCalculation(Calculation):
|
||||||
False,
|
False,
|
||||||
objectspace,
|
objectspace,
|
||||||
add_help=True,
|
add_help=True,
|
||||||
params={None: [self.attribute_name], 'when': True, 'inverse': False},
|
params={None: [self.attribute_name], "when": True, "inverse": False},
|
||||||
)
|
)
|
||||||
elif self.attribute_name == "choices":
|
elif self.attribute_name == "choices":
|
||||||
return_type = self.return_type
|
return_type = self.return_type
|
||||||
|
@ -362,16 +392,13 @@ class JinjaCalculation(Calculation):
|
||||||
raise Exception("hu?")
|
raise Exception("hu?")
|
||||||
|
|
||||||
|
|
||||||
class VariableCalculation(Calculation):
|
class _VariableCalculation(Calculation):
|
||||||
attribute_name: Literal[
|
|
||||||
"default", "choices", "dynamic"
|
|
||||||
]
|
|
||||||
variable: StrictStr
|
variable: StrictStr
|
||||||
propertyerror: bool = True
|
propertyerror: bool = True
|
||||||
allow_none: bool = False
|
allow_none: bool = False
|
||||||
optional: bool = False
|
|
||||||
|
|
||||||
def get_params(self,
|
def get_params(
|
||||||
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
needs_multi: Optional[bool] = None,
|
needs_multi: Optional[bool] = None,
|
||||||
):
|
):
|
||||||
|
@ -380,7 +407,12 @@ class VariableCalculation(Calculation):
|
||||||
else:
|
else:
|
||||||
path = self.ori_path
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
self.variable, self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
self.variable,
|
||||||
|
self.path_prefix,
|
||||||
|
path,
|
||||||
|
self.version,
|
||||||
|
self.namespace,
|
||||||
|
self.xmlfiles,
|
||||||
)
|
)
|
||||||
if not variable:
|
if not variable:
|
||||||
if self.optional:
|
if self.optional:
|
||||||
|
@ -398,7 +430,7 @@ class VariableCalculation(Calculation):
|
||||||
param["suffix"] = suffix
|
param["suffix"] = suffix
|
||||||
params = {None: [param]}
|
params = {None: [param]}
|
||||||
if self.default_values:
|
if self.default_values:
|
||||||
params['__default_value'] = self.default_values
|
params["__default_value"] = self.default_values
|
||||||
if self.allow_none:
|
if self.allow_none:
|
||||||
params["allow_none"] = True
|
params["allow_none"] = True
|
||||||
if needs_multi is None:
|
if needs_multi is None:
|
||||||
|
@ -408,11 +440,15 @@ class VariableCalculation(Calculation):
|
||||||
needs_multi = self.path in objectspace.multis
|
needs_multi = self.path in objectspace.multis
|
||||||
calc_variable_is_multi = variable.path in objectspace.multis
|
calc_variable_is_multi = variable.path in objectspace.multis
|
||||||
if not calc_variable_is_multi:
|
if not calc_variable_is_multi:
|
||||||
if variable.path in objectspace.paths._dynamics and (suffix is None or suffix[-1] is None):
|
if variable.path in objectspace.paths._dynamics and (
|
||||||
|
suffix is None or suffix[-1] is None
|
||||||
|
):
|
||||||
self_dyn_path = objectspace.paths._dynamics.get(self.path)
|
self_dyn_path = objectspace.paths._dynamics.get(self.path)
|
||||||
if self_dyn_path is not None:
|
if self_dyn_path is not None:
|
||||||
var_dyn_path = objectspace.paths._dynamics[variable.path]
|
var_dyn_path = objectspace.paths._dynamics[variable.path]
|
||||||
if self_dyn_path != var_dyn_path and not self_dyn_path.startswith(f'{var_dyn_path}.'):
|
if self_dyn_path != var_dyn_path and not self_dyn_path.startswith(
|
||||||
|
f"{var_dyn_path}."
|
||||||
|
):
|
||||||
calc_variable_is_multi = True
|
calc_variable_is_multi = True
|
||||||
else:
|
else:
|
||||||
calc_variable_is_multi = True
|
calc_variable_is_multi = True
|
||||||
|
@ -432,18 +468,27 @@ class VariableCalculation(Calculation):
|
||||||
raise DictConsistencyError(msg, 21, self.xmlfiles)
|
raise DictConsistencyError(msg, 21, self.xmlfiles)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
class VariableCalculation(_VariableCalculation):
|
||||||
|
attribute_name: Literal["default", "choices", "dynamic"]
|
||||||
|
optional: bool = False
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
params = self.get_params(objectspace)
|
params = self.get_params(objectspace)
|
||||||
|
if self.attribute_name == "choices":
|
||||||
|
if hasattr(self, "optional") and self.optional is True:
|
||||||
|
msg = "'choices' variable shall not have an 'optional' atttibute"
|
||||||
|
raise DictConsistencyError(msg, 33, self.xmlfiles)
|
||||||
return {
|
return {
|
||||||
"function": "calc_value",
|
"function": "calc_value",
|
||||||
"params": params,
|
"params": params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class VariablePropertyCalculation(VariableCalculation):
|
class VariablePropertyCalculation(_VariableCalculation):
|
||||||
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
|
||||||
when: Any = undefined
|
when: Any = undefined
|
||||||
when_not: Any = undefined
|
when_not: Any = undefined
|
||||||
|
@ -455,7 +500,7 @@ class VariablePropertyCalculation(VariableCalculation):
|
||||||
params = self.get_params(objectspace, False)
|
params = self.get_params(objectspace, False)
|
||||||
variable = params[None][0]["variable"]
|
variable = params[None][0]["variable"]
|
||||||
if self.when is not undefined:
|
if self.when is not undefined:
|
||||||
if self.version == '1.0':
|
if self.version == "1.0":
|
||||||
msg = f'when is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
|
msg = f'when is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
|
||||||
raise DictConsistencyError(msg, 103, variable.xmlfiles)
|
raise DictConsistencyError(msg, 103, variable.xmlfiles)
|
||||||
if self.when_not is not undefined:
|
if self.when_not is not undefined:
|
||||||
|
@ -464,7 +509,7 @@ class VariablePropertyCalculation(VariableCalculation):
|
||||||
when = self.when
|
when = self.when
|
||||||
inverse = False
|
inverse = False
|
||||||
elif self.when_not is not undefined:
|
elif self.when_not is not undefined:
|
||||||
if self.version == '1.0':
|
if self.version == "1.0":
|
||||||
msg = f'when_not is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
|
msg = f'when_not is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
|
||||||
raise DictConsistencyError(msg, 104, variable.xmlfiles)
|
raise DictConsistencyError(msg, 104, variable.xmlfiles)
|
||||||
when = self.when_not
|
when = self.when_not
|
||||||
|
@ -475,9 +520,10 @@ class VariablePropertyCalculation(VariableCalculation):
|
||||||
when = True
|
when = True
|
||||||
inverse = False
|
inverse = False
|
||||||
params[None].insert(0, self.attribute_name)
|
params[None].insert(0, self.attribute_name)
|
||||||
params['when'] = when
|
params["when"] = when
|
||||||
params['inverse'] = inverse
|
params["inverse"] = inverse
|
||||||
return {"function": "variable_to_property",
|
return {
|
||||||
|
"function": "variable_to_property",
|
||||||
"params": params,
|
"params": params,
|
||||||
"help": "variable_to_property",
|
"help": "variable_to_property",
|
||||||
}
|
}
|
||||||
|
@ -492,10 +538,13 @@ class InformationCalculation(Calculation):
|
||||||
self,
|
self,
|
||||||
objectspace,
|
objectspace,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
params = {None: [{
|
params = {
|
||||||
|
None: [
|
||||||
|
{
|
||||||
"type": "information",
|
"type": "information",
|
||||||
"information": self.information,
|
"information": self.information,
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
if self.variable:
|
if self.variable:
|
||||||
if self.ori_path is None:
|
if self.ori_path is None:
|
||||||
|
@ -503,13 +552,18 @@ class InformationCalculation(Calculation):
|
||||||
else:
|
else:
|
||||||
path = self.ori_path
|
path = self.ori_path
|
||||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||||
self.variable, self.path_prefix, path, self.version, self.namespace, self.xmlfiles
|
self.variable,
|
||||||
|
self.path_prefix,
|
||||||
|
path,
|
||||||
|
self.version,
|
||||||
|
self.namespace,
|
||||||
|
self.xmlfiles,
|
||||||
)
|
)
|
||||||
if variable is None or suffix is not None:
|
if variable is None or suffix is not None:
|
||||||
raise Exception("pfff")
|
raise Exception("pfff")
|
||||||
params[None][0]["variable"] = variable
|
params[None][0]["variable"] = variable
|
||||||
if self.default_values:
|
if self.default_values:
|
||||||
params['__default_value'] = self.default_values
|
params["__default_value"] = self.default_values
|
||||||
return {
|
return {
|
||||||
"function": "calc_value",
|
"function": "calc_value",
|
||||||
"params": params,
|
"params": params,
|
||||||
|
@ -526,7 +580,7 @@ class SuffixCalculation(Calculation):
|
||||||
) -> dict:
|
) -> dict:
|
||||||
suffix = {"type": "suffix"}
|
suffix = {"type": "suffix"}
|
||||||
if self.suffix is not None:
|
if self.suffix is not None:
|
||||||
suffix['suffix'] = self.suffix
|
suffix["suffix"] = self.suffix
|
||||||
return {
|
return {
|
||||||
"function": "calc_value",
|
"function": "calc_value",
|
||||||
"params": {None: [suffix]},
|
"params": {None: [suffix]},
|
||||||
|
@ -584,7 +638,7 @@ class Family(BaseModel):
|
||||||
|
|
||||||
class Dynamic(Family):
|
class Dynamic(Family):
|
||||||
# None only for format 1.0
|
# None only for format 1.0
|
||||||
variable: str=None
|
variable: str = None
|
||||||
dynamic: Union[List[Union[StrictStr, Calculation]], Calculation]
|
dynamic: Union[List[Union[StrictStr, Calculation]], Calculation]
|
||||||
|
|
||||||
|
|
||||||
|
@ -614,11 +668,6 @@ class Variable(BaseModel):
|
||||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||||
|
|
||||||
|
|
||||||
#class Choice(Variable):
|
|
||||||
# type: Literal["choice"] = "choice"
|
|
||||||
# choices: Union[List[BASETYPE_CALC], Calculation]
|
|
||||||
|
|
||||||
|
|
||||||
class SymLink(BaseModel):
|
class SymLink(BaseModel):
|
||||||
type: Literal["symlink"] = "symlink"
|
type: Literal["symlink"] = "symlink"
|
||||||
name: str
|
name: str
|
||||||
|
|
|
@ -78,7 +78,9 @@ class TiramisuReflector:
|
||||||
)
|
)
|
||||||
if self.objectspace.export_with_import:
|
if self.objectspace.export_with_import:
|
||||||
self.text["header"].extend(
|
self.text["header"].extend(
|
||||||
["from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"]
|
[
|
||||||
|
"from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"
|
||||||
|
]
|
||||||
)
|
)
|
||||||
if funcs_paths:
|
if funcs_paths:
|
||||||
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
||||||
|
@ -105,7 +107,7 @@ class TiramisuReflector:
|
||||||
baseelt = BaseElt()
|
baseelt = BaseElt()
|
||||||
self.objectspace.reflector_names[
|
self.objectspace.reflector_names[
|
||||||
baseelt.path
|
baseelt.path
|
||||||
] = f'option_0{self.objectspace.suffix}'
|
] = f"option_0{self.objectspace.suffix}"
|
||||||
basefamily = Family(
|
basefamily = Family(
|
||||||
baseelt,
|
baseelt,
|
||||||
self,
|
self,
|
||||||
|
@ -121,33 +123,33 @@ class TiramisuReflector:
|
||||||
elt,
|
elt,
|
||||||
self,
|
self,
|
||||||
)
|
)
|
||||||
# else:
|
# else:
|
||||||
# path_prefixes = self.objectspace.paths.get_path_prefixes()
|
# path_prefixes = self.objectspace.paths.get_path_prefixes()
|
||||||
# for path_prefix in path_prefixes:
|
# for path_prefix in path_prefixes:
|
||||||
# space = self.objectspace.space.variables[path_prefix]
|
# space = self.objectspace.space.variables[path_prefix]
|
||||||
# self.set_name(space)
|
# self.set_name(space)
|
||||||
# baseprefix = Family(
|
# baseprefix = Family(
|
||||||
# space,
|
# space,
|
||||||
# self,
|
# self,
|
||||||
# )
|
# )
|
||||||
# basefamily.add(baseprefix)
|
# basefamily.add(baseprefix)
|
||||||
# for elt in self.reorder_family(space):
|
# for elt in self.reorder_family(space):
|
||||||
# self.populate_family(
|
# self.populate_family(
|
||||||
# baseprefix,
|
# baseprefix,
|
||||||
# elt,
|
# elt,
|
||||||
# )
|
# )
|
||||||
# if not hasattr(baseprefix.elt, "information"):
|
# if not hasattr(baseprefix.elt, "information"):
|
||||||
# baseprefix.elt.information = self.objectspace.information(
|
# baseprefix.elt.information = self.objectspace.information(
|
||||||
# baseprefix.elt.xmlfiles
|
# baseprefix.elt.xmlfiles
|
||||||
# )
|
# )
|
||||||
# for key, value in self.objectspace.paths.get_providers_path(
|
# for key, value in self.objectspace.paths.get_providers_path(
|
||||||
# path_prefix
|
# path_prefix
|
||||||
# ).items():
|
# ).items():
|
||||||
# setattr(baseprefix.elt.information, key, value)
|
# setattr(baseprefix.elt.information, key, value)
|
||||||
# for key, value in self.objectspace.paths.get_suppliers_path(
|
# for key, value in self.objectspace.paths.get_suppliers_path(
|
||||||
# path_prefix
|
# path_prefix
|
||||||
# ).items():
|
# ).items():
|
||||||
# setattr(baseprefix.elt.information, key, value)
|
# setattr(baseprefix.elt.information, key, value)
|
||||||
baseelt.name = normalize_family(self.objectspace.base_option_name)
|
baseelt.name = normalize_family(self.objectspace.base_option_name)
|
||||||
baseelt.description = self.objectspace.base_option_name
|
baseelt.description = self.objectspace.base_option_name
|
||||||
self.reflector_objects[baseelt.path].get(
|
self.reflector_objects[baseelt.path].get(
|
||||||
|
@ -450,10 +452,14 @@ class Variable(Common):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if self.elt.type == "choice":
|
if self.elt.type == "choice":
|
||||||
raise DictConsistencyError(
|
# TODO : 'optional' sub-attriute shall be forbidden
|
||||||
"Sub-attributes not allowed in a 'choices' attribute",
|
# raise DictConsistencyError(
|
||||||
100,
|
# "Sub-attributes not allowed in a 'choices' attribute",
|
||||||
self.elt.xmlfiles,
|
# 100,
|
||||||
|
# self.elt.xmlfiles,
|
||||||
|
# )
|
||||||
|
keys["values"] = self.populate_calculation(
|
||||||
|
self.elt.choices, return_a_tuple=True
|
||||||
)
|
)
|
||||||
if self.elt.path in self.objectspace.multis:
|
if self.elt.path in self.objectspace.multis:
|
||||||
keys["multi"] = self.objectspace.multis[self.elt.path]
|
keys["multi"] = self.objectspace.multis[self.elt.path]
|
||||||
|
@ -462,13 +468,13 @@ class Variable(Common):
|
||||||
keys["default"] = self.populate_calculation(self.elt.default)
|
keys["default"] = self.populate_calculation(self.elt.default)
|
||||||
except VariableCalculationDependencyError:
|
except VariableCalculationDependencyError:
|
||||||
pass
|
pass
|
||||||
for attribute in ["frozen", "hidden", "mandatory", "disabled"]:
|
# for attribute in ["frozen", "hidden", "mandatory", "disabled"]:
|
||||||
if hasattr(self.elt, attribute): # FIXME FIXME and attribute == "optional":
|
# if hasattr(self.elt, attribute): # FIXME FIXME and attribute == "optional":
|
||||||
raise DictConsistencyError(
|
# raise DictConsistencyError(
|
||||||
f"Sub-attributes not allowed in a '{attribute}' attribute",
|
# f"Sub-attributes not allowed in a '{attribute}' attribute",
|
||||||
100,
|
# 100,
|
||||||
self.elt.xmlfiles,
|
# self.elt.xmlfiles,
|
||||||
)
|
# )
|
||||||
if self.elt.path in self.objectspace.default_multi:
|
if self.elt.path in self.objectspace.default_multi:
|
||||||
keys["default_multi"] = self.populate_calculation(
|
keys["default_multi"] = self.populate_calculation(
|
||||||
self.objectspace.default_multi[self.elt.path]
|
self.objectspace.default_multi[self.elt.path]
|
||||||
|
|
|
@ -1,10 +1,24 @@
|
||||||
from tiramisu import *
|
from tiramisu import *
|
||||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
|
||||||
|
load_functions("tests/dictionaries/../eosfunc/test.py")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}))
|
option_2 = StrOption(
|
||||||
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2], properties=frozenset({"standard"}))
|
name="my_calculated_variable",
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
optiondescription_1 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_2],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(
|
||||||
|
name="baseoption", doc="baseoption", children=[optiondescription_1]
|
||||||
|
)
|
||||||
|
|
|
@ -1,14 +1,51 @@
|
||||||
from tiramisu import *
|
from tiramisu import *
|
||||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
|
||||||
|
load_functions("tests/dictionaries/../eosfunc/test.py")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}))
|
option_3 = StrOption(
|
||||||
optiondescription_2 = OptionDescription(name="rougail", doc="rougail", children=[option_3], properties=frozenset({"standard"}))
|
name="my_calculated_variable",
|
||||||
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
doc="my_calculated_variable",
|
||||||
option_6 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, properties=frozenset({"mandatory", "notempty", "standard"}))
|
multi=True,
|
||||||
optiondescription_5 = OptionDescription(name="rougail", doc="rougail", children=[option_6], properties=frozenset({"standard"}))
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"standard"}))
|
informations={"type": "string"},
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])
|
)
|
||||||
|
optiondescription_2 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_3],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
optiondescription_1 = OptionDescription(
|
||||||
|
name="1",
|
||||||
|
doc="1",
|
||||||
|
children=[optiondescription_2],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_6 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
optiondescription_5 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_6],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
optiondescription_4 = OptionDescription(
|
||||||
|
name="2",
|
||||||
|
doc="2",
|
||||||
|
children=[optiondescription_5],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(
|
||||||
|
name="baseoption",
|
||||||
|
doc="baseoption",
|
||||||
|
children=[optiondescription_1, optiondescription_4],
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
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 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
|
@ -1,11 +1,34 @@
|
||||||
from tiramisu import *
|
from tiramisu import *
|
||||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
|
||||||
|
load_functions("tests/dictionaries/../eosfunc/test.py")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
option_2 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}))
|
option_2 = StrOption(
|
||||||
option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "notempty", "standard"}))
|
name="my_variable",
|
||||||
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3], properties=frozenset({"standard"}))
|
doc="my_variable",
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
multi=True,
|
||||||
|
default=["val1", "val2"],
|
||||||
|
default_multi="val1",
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
option_3 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
default=Calculation(func["calc_value"], Params((ParamOption(option_2)))),
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
optiondescription_1 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_2, option_3],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(
|
||||||
|
name="baseoption", doc="baseoption", children=[optiondescription_1]
|
||||||
|
)
|
||||||
|
|
|
@ -1,16 +1,71 @@
|
||||||
from tiramisu import *
|
from tiramisu import *
|
||||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
load_functions('tests/dictionaries/../eosfunc/test.py')
|
|
||||||
|
load_functions("tests/dictionaries/../eosfunc/test.py")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
option_3 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}))
|
option_3 = StrOption(
|
||||||
option_4 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "notempty", "standard"}))
|
name="my_variable",
|
||||||
optiondescription_2 = OptionDescription(name="rougail", doc="rougail", children=[option_3, option_4], properties=frozenset({"standard"}))
|
doc="my_variable",
|
||||||
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
multi=True,
|
||||||
option_7 = StrOption(name="my_variable", doc="my_variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "notempty", "standard"}))
|
default=["val1", "val2"],
|
||||||
option_8 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_7)))), properties=frozenset({"mandatory", "notempty", "standard"}))
|
default_multi="val1",
|
||||||
optiondescription_6 = OptionDescription(name="rougail", doc="rougail", children=[option_7, option_8], properties=frozenset({"standard"}))
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"}))
|
informations={"type": "string"},
|
||||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])
|
)
|
||||||
|
option_4 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
default=Calculation(func["calc_value"], Params((ParamOption(option_3)))),
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
optiondescription_2 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_3, option_4],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
optiondescription_1 = OptionDescription(
|
||||||
|
name="1",
|
||||||
|
doc="1",
|
||||||
|
children=[optiondescription_2],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_7 = StrOption(
|
||||||
|
name="my_variable",
|
||||||
|
doc="my_variable",
|
||||||
|
multi=True,
|
||||||
|
default=["val1", "val2"],
|
||||||
|
default_multi="val1",
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
option_8 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
default=Calculation(func["calc_value"], Params((ParamOption(option_7)))),
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
optiondescription_6 = OptionDescription(
|
||||||
|
name="rougail",
|
||||||
|
doc="Rougail",
|
||||||
|
children=[option_7, option_8],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
optiondescription_5 = OptionDescription(
|
||||||
|
name="2",
|
||||||
|
doc="2",
|
||||||
|
children=[optiondescription_6],
|
||||||
|
properties=frozenset({"standard"}),
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(
|
||||||
|
name="baseoption",
|
||||||
|
doc="baseoption",
|
||||||
|
children=[optiondescription_1, optiondescription_5],
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
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 = StrOption(
|
||||||
|
name="my_variable",
|
||||||
|
doc="my_variable",
|
||||||
|
multi=True,
|
||||||
|
default=["val1", "val2"],
|
||||||
|
default_multi="val1",
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
option_2 = StrOption(
|
||||||
|
name="my_calculated_variable",
|
||||||
|
doc="my_calculated_variable",
|
||||||
|
multi=True,
|
||||||
|
properties=frozenset({"mandatory", "notempty", "standard"}),
|
||||||
|
informations={"type": "string"},
|
||||||
|
)
|
||||||
|
option_0 = OptionDescription(
|
||||||
|
name="baseoption", doc="baseoption", children=[option_1, option_2]
|
||||||
|
)
|
Loading…
Reference in a new issue