valid value in param

This commit is contained in:
2021-02-17 17:30:06 +01:00
parent c11ae16ea0
commit 3b2d96566b
10 changed files with 68 additions and 5 deletions

View File

@ -24,6 +24,8 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import tiramisu
from .variable import CONVERT_OPTION
from ..i18n import _
@ -104,9 +106,11 @@ class ParamAnnotator:
f'with type "{variable_type}"')
raise DictConsistencyError(msg, 7, param.xmlfiles)
try:
param.text = CONVERT_OPTION[variable_type].get('func', str)(param.text)
option = CONVERT_OPTION[variable_type]
param.text = option.get('func', str)(param.text)
getattr(tiramisu, option['opttype'])('test', 'Object to valid value', param.text, **option.get('initkwargs', {}))
except ValueError as err:
msg = _(f'unable to change type of "{param.text}" '
msg = _(f'unable to change type of value "{param.text}" '
f'is not a valid "{variable_type}"')
raise DictConsistencyError(msg, 13, param.xmlfiles) from err
param.type = variable_type