object in constrainte
This commit is contained in:
parent
e34d285eb3
commit
82e8057e9d
@ -141,14 +141,7 @@ class ConstrainteAnnotator:
|
||||
param_option_indexes.append(idx)
|
||||
else:
|
||||
# let's replace params by the path
|
||||
param.text, suffix = self.objectspace.paths.get_variable_path(param.text,
|
||||
check.namespace,
|
||||
)
|
||||
if suffix:
|
||||
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||
msg = _(f'the param "{param.text}" in check cannot be a dynamic '
|
||||
f'variable in {xmlfiles}')
|
||||
raise DictConsistencyError(msg, 23)
|
||||
param.text = self.objectspace.paths.get_variable_obj(param.text)
|
||||
param_option_indexes.sort(reverse=True)
|
||||
for idx in param_option_indexes:
|
||||
check.param.pop(idx)
|
||||
@ -223,7 +216,7 @@ class ConstrainteAnnotator:
|
||||
msg = _(f'optional parameter in valid_enum for variable "{variable.name}" '
|
||||
f'is not allowed in {xmlfiles}')
|
||||
raise DictConsistencyError(msg, 14)
|
||||
param_variable = self.objectspace.paths.get_variable_obj(param.text)
|
||||
param_variable = param.text
|
||||
if not param_variable.multi:
|
||||
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||
msg = _(f'only multi "variable" parameter is allowed for valid_enum '
|
||||
@ -608,10 +601,10 @@ class ConstrainteAnnotator:
|
||||
raise DictConsistencyError(msg, 27)
|
||||
if param.type == 'variable':
|
||||
try:
|
||||
text, suffix = self.objectspace.paths.get_variable_path(param.text,
|
||||
path, suffix = self.objectspace.paths.get_variable_path(param.text,
|
||||
fill.namespace,
|
||||
)
|
||||
param.text = text
|
||||
param.text = self.objectspace.paths.get_variable_obj(path)
|
||||
if suffix:
|
||||
param.suffix = suffix
|
||||
except DictConsistencyError as err:
|
||||
|
@ -25,6 +25,8 @@ class Path:
|
||||
full_name = '.'.join([namespace, name])
|
||||
self.full_paths_families[name] = full_name
|
||||
else:
|
||||
if '.' not in name:
|
||||
raise DictConsistencyError(_(f'Variable "{name}" in namespace "{namespace}" must have dot'), 39)
|
||||
full_name = name
|
||||
if full_name in self.families and \
|
||||
self.families[full_name]['variableobj'] != variableobj: # pragma: no cover
|
||||
@ -140,13 +142,13 @@ class Path:
|
||||
def get_variable_path(self,
|
||||
name: str,
|
||||
current_namespace: str,
|
||||
allow_source: str=False,
|
||||
allow_variable_namespace: str=False,
|
||||
) -> str: # pylint: disable=C0111
|
||||
dico, suffix = self._get_variable(name,
|
||||
with_suffix=True,
|
||||
)
|
||||
namespace = dico['variableobj'].namespace
|
||||
if not allow_source and namespace not in [Config['variable_namespace'], 'services'] and current_namespace != namespace:
|
||||
if not allow_variable_namespace and namespace not in [Config['variable_namespace'], 'services'] and current_namespace != namespace:
|
||||
raise DictConsistencyError(_(f'A variable located in the "{namespace}" namespace shall not be used in the "{current_namespace}" namespace'), 41)
|
||||
return dico['variableobj'].path, suffix
|
||||
|
||||
|
@ -324,7 +324,7 @@ class Variable(Common):
|
||||
self.attrib['validators'].append(self.calculation_value(child, ['ParamSelfOption()']))
|
||||
elif tag == 'choice':
|
||||
if child.type == 'calculation':
|
||||
value = self.storage.get(child.name).get()
|
||||
value = self.storage.get(child.name.path).get()
|
||||
choices = f"Calculation(func.calc_value, Params((ParamOption({value}))))"
|
||||
else:
|
||||
choices.append(child.name)
|
||||
@ -400,9 +400,9 @@ class Variable(Common):
|
||||
def build_param(self,
|
||||
param,
|
||||
):
|
||||
option_name = self.storage.get(param['option']).get()
|
||||
option_name = self.storage.get(param['option'].path).get()
|
||||
if 'suffix' in param:
|
||||
family = '.'.join(param['option'].split('.')[:-1])
|
||||
family = '.'.join(param['option'].path.split('.')[:-1])
|
||||
family_option = self.storage.get_name(family)
|
||||
return f"ParamDynOption({option_name}, '{param['suffix']}', {family_option}, notraisepropertyerror={param['notraisepropertyerror']}, todict={param['todict']})"
|
||||
return f"ParamOption({option_name}, notraisepropertyerror={param['notraisepropertyerror']}, todict={param['todict']})"
|
||||
|
Loading…
Reference in New Issue
Block a user