mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow FieldAttribute lists and sets to be set from a comma separated string
This commit is contained in:
parent
88772b6003
commit
d665911bab
1 changed files with 12 additions and 5 deletions
|
@ -334,7 +334,10 @@ class Base:
|
|||
if value is None:
|
||||
value = []
|
||||
elif not isinstance(value, list):
|
||||
value = [ value ]
|
||||
if isinstance(value, string_types):
|
||||
value = value.split(',')
|
||||
else:
|
||||
value = [ value ]
|
||||
if attribute.listof is not None:
|
||||
for item in value:
|
||||
if not isinstance(item, attribute.listof):
|
||||
|
@ -346,11 +349,15 @@ class Base:
|
|||
elif attribute.isa == 'set':
|
||||
if value is None:
|
||||
value = set()
|
||||
else:
|
||||
if not isinstance(value, (list, set)):
|
||||
elif not isinstance(value, (list, set)):
|
||||
if isinstance(value, string_types):
|
||||
value = value.split(',')
|
||||
else:
|
||||
# Making a list like this handles strings of
|
||||
# text and bytes properly
|
||||
value = [ value ]
|
||||
if not isinstance(value, set):
|
||||
value = set(value)
|
||||
if not isinstance(value, set):
|
||||
value = set(value)
|
||||
elif attribute.isa == 'dict':
|
||||
if value is None:
|
||||
value = dict()
|
||||
|
|
Loading…
Reference in a new issue