test float variable in yml format
This commit is contained in:
parent
1f3c59737a
commit
4856922fb7
4 changed files with 26 additions and 14 deletions
|
@ -8,11 +8,11 @@ variables:
|
||||||
type: float
|
type: float
|
||||||
description: Description
|
description: Description
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
- variable:
|
- variable:
|
||||||
name: float_multi
|
name: float_multi
|
||||||
type: float
|
type: float
|
||||||
description: Description
|
description: Description
|
||||||
multi: true
|
multi: true
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
|
|
|
@ -9,11 +9,11 @@ variables:
|
||||||
description: Description
|
description: Description
|
||||||
provider: float
|
provider: float
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
- variable:
|
- variable:
|
||||||
name: float_multi
|
name: float_multi
|
||||||
type: float
|
type: float
|
||||||
description: Description
|
description: Description
|
||||||
multi: true
|
multi: true
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
|
|
|
@ -10,11 +10,11 @@ variables:
|
||||||
provider: float
|
provider: float
|
||||||
hidden: true
|
hidden: true
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
- variable:
|
- variable:
|
||||||
name: float_multi
|
name: float_multi
|
||||||
type: float
|
type: float
|
||||||
description: Description
|
description: Description
|
||||||
multi: true
|
multi: true
|
||||||
value:
|
value:
|
||||||
- text: '0.527'
|
- text: 0.527
|
||||||
|
|
|
@ -115,11 +115,23 @@ def xml_to_yaml(filename, destfilename):
|
||||||
value = True
|
value = True
|
||||||
elif value == 'False':
|
elif value == 'False':
|
||||||
value = False
|
value = False
|
||||||
|
else:
|
||||||
|
converted = False
|
||||||
try:
|
try:
|
||||||
# if it's a number
|
# if it's a number
|
||||||
nvalue = int(value)
|
nvalue = int(value)
|
||||||
assert str(nvalue) == value
|
assert str(nvalue) == value
|
||||||
value = nvalue
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
if key.startswith('@'):
|
if key.startswith('@'):
|
||||||
|
@ -134,7 +146,7 @@ def xml_to_yaml(filename, destfilename):
|
||||||
dico[key] = value
|
dico[key] = value
|
||||||
elif key == 'value':
|
elif key == 'value':
|
||||||
dico[key] = [{'text': value}]
|
dico[key] = [{'text': value}]
|
||||||
elif isinstance(value, (str, bool, int)):
|
elif isinstance(value, (str, bool, int, float)):
|
||||||
dico[key] = [{'text': value}]
|
dico[key] = [{'text': value}]
|
||||||
else:
|
else:
|
||||||
dico[key] = [value]
|
dico[key] = [value]
|
||||||
|
|
Loading…
Reference in a new issue