in Command Default missing values from variables admit a warning message but no error

This commit is contained in:
Bela 2018-03-15 13:31:37 +01:00
parent f94425c241
commit 4c1bcffa1f

View file

@ -304,13 +304,28 @@ class Default(Command):
Understand variables.
If a variable cannot be understood, use "" instead.
If in this case it boils down to an empty string, save nothing.
"""
if "Overwrite" in self or "Value" not in self.reason:
if "Value" not in self:
raise ConfigError("A Default needs a default Value. " +
"Add a line " + self.name + "-Value: " +
"<your Default value>")
# try:
self.reason["Value"] = self.interpret(self["Value"])
# except KeyError as e:
# raise ConfigError("Evaluation of Default aborted: " + str(e))
try:
self.reason["Value"] = self.interpret(self["Value"])
except ConfigError as e:
try:
name = "field " + self.reason["Name"]
except KeyError: # no name:
try:
name = "field " + self.reason["FieldName"]
except KeyError:
name = "unnamed field"
print("Evaluation of " + name + " has problem. Try to use" +
" empty strings as replacement. (Error: " + str(e) + ")")
# now ConfigError is a real problem:
value = self.interpret(self["Value"], default="")
if value != "":
self.reason["Value"] = value