optional sub attribute unauthorized
This commit is contained in:
parent
e57cf4dea8
commit
0c02807775
1 changed files with 38 additions and 17 deletions
|
@ -201,7 +201,9 @@ class Common:
|
|||
self.populate_attrib()
|
||||
if self.informations:
|
||||
for information in self.informations:
|
||||
self.tiramisu.text['option'].append(f'{information}.set_option({self.option_name})')
|
||||
self.tiramisu.text["option"].append(
|
||||
f"{information}.set_option({self.option_name})"
|
||||
)
|
||||
return self.option_name
|
||||
|
||||
def populate_attrib(self):
|
||||
|
@ -275,7 +277,7 @@ class Common:
|
|||
informations = self.objectspace.informations.get(self.elt.path)
|
||||
if not informations:
|
||||
return
|
||||
keys['informations'] = informations
|
||||
keys["informations"] = informations
|
||||
|
||||
def populate_param(
|
||||
self,
|
||||
|
@ -299,14 +301,20 @@ class Common:
|
|||
if param["variable"].path == self.elt.path:
|
||||
return f'ParamSelfInformation("{param["information"]}", {default})'
|
||||
information_variable_path = param["variable"].path
|
||||
information_variable = self.tiramisu.reflector_objects[information_variable_path]
|
||||
information_variable = self.tiramisu.reflector_objects[
|
||||
information_variable_path
|
||||
]
|
||||
if information_variable_path not in self.calls:
|
||||
option_name = information_variable.get(self.calls, self.elt.path)
|
||||
return f'ParamInformation("{param["information"]}", {default}, option={option_name})'
|
||||
else:
|
||||
information = f'ParamInformation("{param["information"]}", {default})'
|
||||
information = (
|
||||
f'ParamInformation("{param["information"]}", {default})'
|
||||
)
|
||||
information_name = self.tiramisu.get_information_name()
|
||||
self.tiramisu.text["option"].append(f'{information_name} = {information}')
|
||||
self.tiramisu.text["option"].append(
|
||||
f"{information_name} = {information}"
|
||||
)
|
||||
information_variable.informations.append(information_name)
|
||||
return information_name
|
||||
return f'ParamInformation("{param["information"]}", {default})'
|
||||
|
@ -385,10 +393,11 @@ class Common:
|
|||
ret = ret + ")"
|
||||
return ret
|
||||
|
||||
def populate_calculation(self,
|
||||
datas: Union[Calculation, str, list],
|
||||
return_a_tuple: bool=False,
|
||||
) -> str:
|
||||
def populate_calculation(
|
||||
self,
|
||||
datas: Union[Calculation, str, list],
|
||||
return_a_tuple: bool = False,
|
||||
) -> str:
|
||||
if isinstance(datas, str):
|
||||
return self.convert_str(datas)
|
||||
if isinstance(datas, Calculation):
|
||||
|
@ -404,9 +413,9 @@ class Common:
|
|||
else:
|
||||
params.append(str(data))
|
||||
if return_a_tuple:
|
||||
ret = '('
|
||||
ret = "("
|
||||
else:
|
||||
ret = '['
|
||||
ret = "["
|
||||
ret += ", ".join(params)
|
||||
if return_a_tuple:
|
||||
if len(params) <= 1:
|
||||
|
@ -441,7 +450,11 @@ class Variable(Common):
|
|||
)
|
||||
return
|
||||
if self.elt.type == "choice":
|
||||
raise DictConsistencyError("Sub-attributes not allowed in a 'choices' attribute", 100, self.elt.xmlfiles)
|
||||
raise DictConsistencyError(
|
||||
"Sub-attributes not allowed in a 'choices' attribute",
|
||||
100,
|
||||
self.elt.xmlfiles,
|
||||
)
|
||||
if self.elt.path in self.objectspace.multis:
|
||||
keys["multi"] = self.objectspace.multis[self.elt.path]
|
||||
if hasattr(self.elt, "default") and self.elt.default is not None:
|
||||
|
@ -449,14 +462,22 @@ class Variable(Common):
|
|||
keys["default"] = self.populate_calculation(self.elt.default)
|
||||
except VariableCalculationDependencyError:
|
||||
pass
|
||||
for attribute in ['frozen', 'hidden', "mandatory", "disabled"]:
|
||||
if hasattr(self.elt, attribute):
|
||||
raise DictConsistencyError(f"Sub-attributes not allowed in a '{attribute}' attribute", 100, self.elt.xmlfiles)
|
||||
for attribute in ["frozen", "hidden", "mandatory", "disabled"]:
|
||||
if hasattr(self.elt, attribute): # FIXME FIXME and attribute == "optional":
|
||||
raise DictConsistencyError(
|
||||
f"Sub-attributes not allowed in a '{attribute}' attribute",
|
||||
100,
|
||||
self.elt.xmlfiles,
|
||||
)
|
||||
if self.elt.path in self.objectspace.default_multi:
|
||||
keys["default_multi"] = self.populate_calculation(self.objectspace.default_multi[self.elt.path])
|
||||
keys["default_multi"] = self.populate_calculation(
|
||||
self.objectspace.default_multi[self.elt.path]
|
||||
)
|
||||
if self.elt.validators:
|
||||
keys["validators"] = self.populate_calculation(self.elt.validators)
|
||||
for key, value in CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items():
|
||||
for key, value in (
|
||||
CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items()
|
||||
):
|
||||
if isinstance(value, str):
|
||||
value = self.convert_str(value)
|
||||
keys[key] = value
|
||||
|
|
Loading…
Reference in a new issue