WIP: Expand the developer documentation #27
2 changed files with 38 additions and 1 deletions
|
|
@ -611,3 +611,40 @@ def convert_value(option, value, needs_convert):
|
|||
except:
|
||||
pass
|
||||
return value
|
||||
|
||||
|
||||
def mandatories(config, errors: list) -> None:
|
||||
try:
|
||||
mandatories = config.value.mandatory()
|
||||
except (ConfigError, PropertiesOptionError, ValueError) as err:
|
||||
try:
|
||||
subconfig = err.subconfig
|
||||
except AttributeError:
|
||||
subconfig = None
|
||||
if subconfig:
|
||||
err.prefix = ""
|
||||
errors.append({str(err): subconfig})
|
||||
else:
|
||||
errors.append(str(err))
|
||||
else:
|
||||
for option in mandatories:
|
||||
_populate_mandatory(option, errors)
|
||||
|
||||
|
||||
def _populate_mandatory(option, errors: list) -> None:
|
||||
try:
|
||||
option.value.get()
|
||||
except PropertiesOptionError as err:
|
||||
if "empty" in err.proptype:
|
||||
msg = _("null is not a valid value for a multi")
|
||||
elif "mandatory" in err.proptype:
|
||||
msg = _("mandatory variable but has no value")
|
||||
else:
|
||||
msg = _("mandatory variable but is inaccessible and has no value or has null in value")
|
||||
else:
|
||||
proptype = option.value.mandatory(return_type=True)
|
||||
if proptype == "empty":
|
||||
msg = _("null is not a valid value for a multi")
|
||||
elif proptype == "mandatory":
|
||||
msg = _("mandatory variable but has no value")
|
||||
errors.append({msg: option._subconfig})
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
["rougail.var1"]
|
||||
[]
|
||||
Loading…
Reference in a new issue