add default value to True in boolean

This commit is contained in:
2020-07-09 18:48:51 +02:00
parent 7e34709628
commit 7191bbbcb3
4 changed files with 7 additions and 16 deletions

View File

@ -60,7 +60,7 @@ CONVERT_OPTION = {'number': dict(opttype=IntOption),
'string': dict(opttype=StrOption),
'password': dict(opttype=PasswordOption),
'mail': dict(opttype=EmailOption),
'boolean': dict(opttype=BoolOption),
'boolean': dict(opttype=BoolOption, initkwargs={'default': True}),
'symlink': dict(opttype=SymLinkOption),
'filename': dict(opttype=FilenameOption),
'date': dict(opttype=DateOption),
@ -269,6 +269,9 @@ class Variable(Common):
self.option = None
self.informations = {}
self.attrib = {}
convert_option = CONVERT_OPTION[elt.attrib['type']]
if 'initkwargs' in convert_option:
self.attrib.update(convert_option['initkwargs'])
if elt.attrib['type'] != 'symlink':
self.attrib['properties'] = []
self.attrib['validators'] = []
@ -278,15 +281,12 @@ class Variable(Common):
self.populate_attrib(elt)
self.is_follower = is_follower
self.is_leader = is_leader
convert_option = CONVERT_OPTION[elt.attrib['type']]
self.object_type = convert_option['opttype']
self.populate_choice(elt)
for child in elt:
self.populate_property(child)
self.populate_value(child)
self.populate_check(child)
if 'initkwargs' in convert_option:
self.attrib.update(convert_option['initkwargs'])
if elt.attrib['type'] == 'symlink':
self.attrib['opt'] = storage.get(self.attrib['opt'])
@ -371,9 +371,6 @@ class Variable(Common):
if not self.is_leader:
self.attrib['default_multi'].append(value)
else:
if 'default' in self.attrib:
raise CreoleLoaderError(_('default value already set for {}'
'').format(self.attrib['path']))
value = convert_tiramisu_value(child.text, type_)
if self.is_follower:
self.attrib['default_multi'] = value