configfile: Minor line wrapping changes

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-12-22 20:06:15 -05:00
parent ac98d0ea7e
commit ca8e6ad89b
1 changed files with 16 additions and 18 deletions

View File

@ -33,22 +33,20 @@ class ConfigWrapper:
except self.error as e:
raise
except:
raise error("Unable to parse option '%s' in section '%s'" % (
option, self.section))
raise error("Unable to parse option '%s' in section '%s'"
% (option, self.section))
if minval is not None and v < minval:
raise error(
"Option '%s' in section '%s' must have minimum of %s" % (
option, self.section, minval))
raise error("Option '%s' in section '%s' must have minimum of %s"
% (option, self.section, minval))
if maxval is not None and v > maxval:
raise error(
"Option '%s' in section '%s' must have maximum of %s" % (
option, self.section, maxval))
raise error("Option '%s' in section '%s' must have maximum of %s"
% (option, self.section, maxval))
if above is not None and v <= above:
raise error("Option '%s' in section '%s' must be above %s" % (
option, self.section, above))
raise error("Option '%s' in section '%s' must be above %s"
% (option, self.section, above))
if below is not None and v >= below:
raise self.error("Option '%s' in section '%s' must be below %s" % (
option, self.section, below))
raise self.error("Option '%s' in section '%s' must be below %s"
% (option, self.section, below))
return v
def get(self, option, default=sentinel, note_valid=True):
return self._get_wrapper(self.fileconfig.get, option, default,
@ -240,13 +238,13 @@ class PrinterConfig:
for section_name in fileconfig.sections():
section = section_name.lower()
if section not in valid_sections and section not in objects:
raise error("Section '%s' is not a valid config section" % (
section,))
raise error("Section '%s' is not a valid config section"
% (section,))
for option in fileconfig.options(section_name):
option = option.lower()
if (section, option) not in access_tracking:
raise error("Option '%s' is not valid in section '%s'" % (
option, section))
raise error("Option '%s' is not valid in section '%s'"
% (option, section))
def log_config(self, config):
lines = ["===== Config file =====",
self._build_config_string(config),
@ -278,8 +276,8 @@ class PrinterConfig:
for section in self.autosave.fileconfig.sections():
for option in self.autosave.fileconfig.options(section):
if config.fileconfig.has_option(section, option):
msg = "SAVE_CONFIG section '%s' option '%s' conflicts " \
"with included value" % (section, option)
msg = ("SAVE_CONFIG section '%s' option '%s' conflicts "
"with included value" % (section, option))
raise gcode.error(msg)
cmd_SAVE_CONFIG_help = "Overwrite config file and restart"
def cmd_SAVE_CONFIG(self, gcmd):