  
      def save_config(self):
          """ Save a config file """
          logger.info("Updating config at: '%s'", self.configfile)
          f_cfgfile = open(self.configfile, "w")
          self.config.write(f_cfgfile)
          f_cfgfile.close()
          logger.debug("Updated config at: '%s'", self.configfile)
  
      def validate_config(self):
          """ Check for options in default config against saved config
              and add/remove as appropriate """
 
</s> remove         """ Handle the config """
        logger.debug("Handling config")
 </s> add         """ Handle the config.

        Checks whether a config file exists for this section. If not then a default is created.

        Configuration choices are then loaded and validated
        """
        logger.debug("Handling config: (section: %s, configfile: '%s')",
                     self.section, self.configfile) </s> remove                 opt_value = self.config.get(section, item)
                if opt_value.lower() == "none" and any(choice.lower() == "none"
                                                       for choice in opt["choices"]):
                    continue
                if opt_value not in opt["choices"]:
                    default = str(opt["default"])
                    logger.warning("'%s' is not a valid config choice for '%s': '%s'. Defaulting "
                                   "to: '%s'", opt_value, section, item, default)
                    self.config.set(section, item, default)
 </s> add                 if opt["type"] == list:  # Multi-select items
                    opt_value = self._parse_list(section, item)
                    if not opt_value:  # No option selected
                        continue
                    if not all(val in opt["choices"] for val in opt_value):
                        invalid = [val for val in opt_value if val not in opt["choices"]]
                        valid = ", ".join(val for val in opt_value if val in opt["choices"])
                        logger.warning("The option(s) %s are not valid selections for '%s': '%s'. "
                                       "setting to: '%s'", invalid, section, item, valid)
                        self.config.set(section, item, valid)
                else:  # Single-select items
                    opt_value = self.config.get(section, item)
                    if opt_value.lower() == "none" and any(choice.lower() == "none"
                                                           for choice in opt["choices"]):
                        continue
                    if opt_value not in opt["choices"]:
                        default = str(opt["default"])
                        logger.warning("'%s' is not a valid config choice for '%s': '%s'. "
                                       "Defaulting to: '%s'", opt_value, section, item, default)
                        self.config.set(section, item, default) </s> remove         """ Return a config item in it's correct format """
 </s> add         """ Return a config item in it's correct format.

        Parameters
        ----------
        section: str
            The configuration section currently being processed
        option: str
            The configuration option currently being processed

        Returns
        -------
        varies
            The selected configuration option in the correct data format
        """ </s> remove         helptext = '# {}'.format(helptext.replace("\n", "\n# "))
 </s> add         formatted = ""
        for hlp in helptext.split("\n"):
            subsequent_indent = "\t\t" if hlp.startswith("\t") else ""
            hlp = f"\t- {hlp[1:].strip()}" if hlp.startswith("\t") else hlp
            formatted += textwrap.fill(hlp,
                                       100,
                                       tabsize=4,
                                       subsequent_indent=subsequent_indent) + "\n"
        helptext = '# {}'.format(formatted[:-1].replace("\n", "\n# "))  # Strip last newline
        with open(self.configfile, "w") as f_cfgfile:
            self.config.write(f_cfgfile)
  
      def save_config(self):
          """ Save a config file """
          logger.info("Updating config at: '%s'", self.configfile)
        with open(self.configfile, "w") as f_cfgfile:
            self.config.write(f_cfgfile)
        with open(self.configfile, "w") as f_cfgfile:
            self.config.write(f_cfgfile)
        with open(self.configfile, "w") as f_cfgfile:
            self.config.write(f_cfgfile)
          logger.debug("Updated config at: '%s'", self.configfile)
  
      def validate_config(self):
          """ Check for options in default config against saved config
              and add/remove as appropriate """
keep keep keep keep replace replace replace keep keep keep keep keep
 scripts.train - Add freeze weights option
lib.config:
  - Better formatting for .ini files
  - Support multi-select options
gui - Add support for multi-select config items 
lib/config.py