test float variable in yml format

This commit is contained in:
egarette@silique.fr 2022-11-04 20:16:57 +01:00
parent 1f3c59737a
commit 4856922fb7
4 changed files with 26 additions and 14 deletions

View file

@ -8,11 +8,11 @@ variables:
type: float
description: Description
value:
- text: '0.527'
- text: 0.527
- variable:
name: float_multi
type: float
description: Description
multi: true
value:
- text: '0.527'
- text: 0.527

View file

@ -9,11 +9,11 @@ variables:
description: Description
provider: float
value:
- text: '0.527'
- text: 0.527
- variable:
name: float_multi
type: float
description: Description
multi: true
value:
- text: '0.527'
- text: 0.527

View file

@ -10,11 +10,11 @@ variables:
provider: float
hidden: true
value:
- text: '0.527'
- text: 0.527
- variable:
name: float_multi
type: float
description: Description
multi: true
value:
- text: '0.527'
- text: 0.527

View file

@ -115,13 +115,25 @@ def xml_to_yaml(filename, destfilename):
value = True
elif value == 'False':
value = False
try:
# if it's a number
nvalue = int(value)
assert str(nvalue) == value
value = nvalue
except:
pass
else:
converted = False
try:
# if it's a number
nvalue = int(value)
assert str(nvalue) == value
value = nvalue
converted = True
except:
pass
if not converted:
try:
# if it's a number
nvalue = float(value)
assert str(nvalue) == value
value = nvalue
converted = True
except:
pass
if key.startswith('@'):
# remove @
dico[key[1:]] = value
@ -134,7 +146,7 @@ def xml_to_yaml(filename, destfilename):
dico[key] = value
elif key == 'value':
dico[key] = [{'text': value}]
elif isinstance(value, (str, bool, int)):
elif isinstance(value, (str, bool, int, float)):
dico[key] = [{'text': value}]
else:
dico[key] = [value]