1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add float and percent types for FieldAttributes

Also sets the max_fail_percentage value to the percent type.
This commit is contained in:
James Cammarata 2015-08-26 12:02:21 -04:00
parent 9f95720ef7
commit af41ba929c
2 changed files with 9 additions and 1 deletions

View file

@ -289,8 +289,16 @@ class Base:
value = unicode(value)
elif attribute.isa == 'int':
value = int(value)
elif attribute.isa == 'float':
value = float(value)
elif attribute.isa == 'bool':
value = boolean(value)
elif attribute.isa == 'percent':
# special value, which may be an integer or float
# with an optional '%' at the end
if isinstance(value, string_types) and '%' in value:
value = value.replace('%', '')
value = float(value)
elif attribute.isa == 'list':
if value is None:
value = []

View file

@ -78,7 +78,7 @@ class Play(Base, Taggable, Become):
# Flag/Setting Attributes
_any_errors_fatal = FieldAttribute(isa='bool', default=False)
_force_handlers = FieldAttribute(isa='bool')
_max_fail_percentage = FieldAttribute(isa='string', default='0')
_max_fail_percentage = FieldAttribute(isa='percent')
_serial = FieldAttribute(isa='int', default=0)
_strategy = FieldAttribute(isa='string', default='linear')