|
|
|
@ -143,6 +143,29 @@ class DictDef(_ConfigDefinition):
|
|
|
|
e.args = ("Key: " + key,) + e.args
|
|
|
|
e.args = ("Key: " + key,) + e.args
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_template(self, include_optional=False):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Return a config dict with the minimum structure required for this ConfigDefinition.
|
|
|
|
|
|
|
|
Default values will be included, though not all required fields will necessarily have
|
|
|
|
|
|
|
|
defaults that successfully validate.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
include_optional: If set true, will include *all* config fields, not just the
|
|
|
|
|
|
|
|
required ones
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
Dict containing the structure that should be passed back in (with values) to comply
|
|
|
|
|
|
|
|
with this ConfigDefinition.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
template = {}
|
|
|
|
|
|
|
|
for key, confdef in self.def_dict.items():
|
|
|
|
|
|
|
|
if confdef.optional and (not include_optional):
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if hasattr(confdef,"get_template"):
|
|
|
|
|
|
|
|
template[key]=confdef.get_template(include_optional)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
template[key]=confdef.default
|
|
|
|
|
|
|
|
return template
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ListDefMixin():
|
|
|
|
class _ListDefMixin():
|
|
|
|
@ -156,6 +179,12 @@ class _ListDefMixin():
|
|
|
|
e.args = ("List index: " + str(index),) + e.args
|
|
|
|
e.args = ("List index: " + str(index),) + e.args
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_template(self, include_optional=False):
|
|
|
|
|
|
|
|
if hasattr(super(),"get_template"):
|
|
|
|
|
|
|
|
return [super().get_template(include_optional)]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return [self.default]
|
|
|
|
|
|
|
|
|
|
|
|
@freezedryable
|
|
|
|
@freezedryable
|
|
|
|
class BoolListDef(_ListDefMixin, BoolDef):
|
|
|
|
class BoolListDef(_ListDefMixin, BoolDef):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|