support of number value in yaml

This commit is contained in:
egarette@silique.fr 2022-11-04 19:42:16 +01:00
parent 854bc6a013
commit 1f3c59737a
31 changed files with 81 additions and 61 deletions

View file

@ -29,7 +29,7 @@ En YAML :
```yml
param:
- type: number
text: '1'
text: 1
```
Créons la fonction correspondante :

View file

@ -77,7 +77,7 @@ En YAML :
- type: string
text: val2
- type: number
text: '3'
text: 3
- type: boolean
text: true
- type: 'nil'
@ -177,10 +177,10 @@ En YAML :
name: range
param:
- type: number
text: '0'
text: 0
- type: number
text: '10'
text: 10
value:
- type: number
text: '9'
text: 9
```

View file

@ -147,6 +147,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -287,6 +288,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -428,6 +430,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -569,6 +572,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -710,6 +714,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -909,6 +914,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1049,6 +1055,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1206,6 +1213,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1346,6 +1354,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1503,6 +1512,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1643,6 +1653,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq
@ -1800,6 +1811,7 @@ mapping:
mapping:
text:
required: false
type: any
param:
required: false
type: seq

View file

@ -19,6 +19,6 @@ constraints:
- name: calc_val
param:
- type: number
text: '3'
text: 3
target:
- text: mode_conteneur_actif

View file

@ -19,9 +19,9 @@ constraints:
param:
- name: mini
type: number
text: '0'
text: 0
- name: maxi
type: number
text: '100'
text: 100
target:
- text: int

View file

@ -8,10 +8,10 @@ constraints:
param:
- name: mini
type: number
text: '0'
text: 0
- name: maxi
type: number
text: '100'
text: 100
target:
- optional: true
text: int

View file

@ -14,7 +14,7 @@ variables:
type: number
description: No change
value:
- text: '100'
- text: 100
- variable:
name: int
type: number
@ -25,7 +25,7 @@ constraints:
param:
- name: mini
type: number
text: '0'
text: 0
- name: maxi
type: variable
text: int2

View file

@ -21,14 +21,14 @@ variables:
help: bla bla bla
choice:
- type: number
text: '1'
text: 1
- type: number
text: '2'
text: 2
- type: number
text: '3'
text: 3
value:
- type: number
text: '1'
text: 1
- variable:
name: test_variable
type: number
@ -38,7 +38,7 @@ constraints:
- name: hidden_if_in
source: enumvar
param:
- text: '4'
- text: 4
target:
- type: variable
text: test_variable

View file

@ -21,11 +21,11 @@ variables:
help: bla bla bla
choice:
- type: number
text: '1'
text: 1
- type: number
text: '2'
text: 2
- type: number
text: '3'
text: 3
value:
- type: number
text: '1'
text: 1

View file

@ -21,11 +21,11 @@ variables:
help: bla bla bla
value:
- type: number
text: '3'
text: 3
choice:
- type: number
text: '1'
text: 1
- type: number
text: '2'
text: 2
- type: number
text: '3'
text: 3

View file

@ -9,12 +9,12 @@ variables:
description: New variable
value:
- type: number
text: '9'
text: 9
choice:
- type: function
name: trange
param:
- type: number
text: '0'
text: 0
- type: number
text: '10'
text: 10

View file

@ -15,7 +15,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition

View file

@ -15,7 +15,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition

View file

@ -15,7 +15,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition

View file

@ -8,14 +8,14 @@ variables:
type: number
description: "d\xE9lai en minutes avant lancement"
value:
- text: '0'
- text: 0
- variable:
name: calc_url
type: web_address
description: domain
hidden: true
value:
- text: '0'
- text: 0
constraints:
- fill:
- name: calc_val

View file

@ -8,4 +8,4 @@ variables:
type: number
description: "d\xE9lai en minutes avant lancement"
value:
- text: '0'
- text: 0

View file

@ -8,7 +8,7 @@ variables:
type: number
description: "d\xE9lai en minutes avant lancement"
value:
- text: '0'
- text: 0
- variable:
name: day
type: number

View file

@ -19,7 +19,7 @@ constraints:
param:
- name: mini
type: number
text: '0'
text: 0
- name: maxi
type: variable
text: int

View file

@ -18,8 +18,8 @@ constraints:
- name: unknown
param:
- name: mini
text: '0'
text: 0
- name: maxi
text: '100'
text: 100
target:
- text: int

View file

@ -18,6 +18,6 @@ constraints:
- name: valid_entier
param:
- name: mini
text: '0'
text: 0
- name: maxi
text: '100'
text: 100

View file

@ -14,7 +14,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition

View file

@ -14,7 +14,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition
@ -24,7 +24,7 @@ constraints:
name: condition_1
propertyerror: true
- name: match
text: '3128'
text: 3128
- name: mismatch
type: variable
propertyerror: true

View file

@ -11,7 +11,7 @@ variables:
description: "Port d'\xE9coute du proxy NTLM"
mode: expert
value:
- text: '3127'
- text: 3127
constraints:
- fill:
- name: calc_multi_condition
@ -21,7 +21,7 @@ constraints:
name: condition_2
propertyerror: true
- name: match
text: '3128'
text: 3128
- name: mismatch
type: variable
propertyerror: true

View file

@ -25,9 +25,9 @@ constraints:
param:
- name: mini
type: number
text: '0'
text: 0
- name: maxi
type: number
text: '100'
text: 100
target:
- text: vardynval1

View file

@ -8,4 +8,4 @@ variables:
type: number
description: "d\xE9lai en minutes avant lancement"
value:
- text: '0'
- text: 0

View file

@ -21,14 +21,14 @@ variables:
help: bla bla bla
choice:
- type: number
text: '1'
text: 1
- type: number
text: '2'
text: 2
- type: number
text: '3'
text: 3
value:
- type: number
text: '1'
text: 1
- variable:
name: test_variable
type: number
@ -38,7 +38,7 @@ constraints:
- name: hidden_if_in
source: condition
param:
- text: '4'
- text: 4
target:
- type: variable
text: test_variable

View file

@ -19,6 +19,6 @@ constraints:
param:
- name: unknown
type: number
text: '0'
text: 0
target:
- text: int

View file

@ -18,9 +18,9 @@ constraints:
- name: valid_entier
param:
- name: mini
text: '0'
text: 0
- name: maxi
type: number
text: '100'
text: 100
target:
- text: int

View file

@ -23,8 +23,8 @@ variables:
text: a
choice:
- type: string
text: '1'
text: 1
- type: string
text: '2'
text: 2
- type: string
text: '3'
text: 3

View file

@ -115,6 +115,13 @@ 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
if key.startswith('@'):
# remove @
dico[key[1:]] = value
@ -127,7 +134,7 @@ def xml_to_yaml(filename, destfilename):
dico[key] = value
elif key == 'value':
dico[key] = [{'text': value}]
elif isinstance(value, (str, bool)):
elif isinstance(value, (str, bool, int)):
dico[key] = [{'text': value}]
else:
dico[key] = [value]

View file

@ -19,7 +19,8 @@ def parse_dtd_subelement(obj_name, content, default_required=False):
yield {'name': content.name, 'type': None, 'required': default_required}
if content.left:
if content.left.type == 'pcdata':
yield {'name': 'text', 'type': None, 'required': False}
# choice
yield {'name': 'text', 'type': 'any', 'required': False}
else:
yield {'name': content.left.name, 'type': None, 'required': default_required}
if content.right: