              self._config.insert_config_section(section, items["helptext"], config=new_config)
              for item, def_opt in items.items():
                  if item == "helptext":
                      continue
                  new_opt = options[section][item].get()
                  logger.debug("Adding option: (item: '%s', default: %s new: '%s'",
                               item, def_opt, new_opt)
                  helptext = def_opt["helptext"]
                  helptext = self._config.format_help(helptext, is_section=False)
                  new_config.set(section, helptext)
                  new_config.set(section, item, str(new_opt))
          self._config.config = new_config
          self._config.save_config()
          logger.info("Saved config: '%s'", self._config.configfile)
 
</s> remove             self._config.insert_config_section(section, items["helptext"], config=new_config)
            for item, def_opt in items.items():
 </s> add             config.insert_config_section(section, items["helptext"], config=new_config)
            for item, options in items.items(): </s> remove         self._config.config = new_config
        self._config.save_config()
        logger.info("Saved config: '%s'", self._config.configfile)
        self.destroy()

        running_task = get_config().tk_vars["runningtask"].get()
        if self._name.lower() == "gui" and not running_task:
            self._root.rebuild()
        elif self._name.lower() == "gui" and running_task:
            logger.info("Can't redraw GUI whilst a task is running. GUI Settings will be applied "
                        "at the next restart.")
 </s> add         config.config = new_config
        config.save_config()
        logger.info("Saved config: '%s'", config.configfile)

        if category == "gui":
            if not get_config().tk_vars["runningtask"].get():
                get_config().root.rebuild()
            else:
                logger.info("Can't redraw GUI whilst a task is running. GUI Settings will be "
                            "applied at the next restart.") </s> remove         for section, items in self._config.defaults.items():
 </s> add         if "|" in selection:
            lookup = ".".join(selection.split("|")[1:])
        else:  # Expand global out from root node
            lookup = "global"

        if page_only and lookup not in config.config.sections():
            logger.info("No settings to save for the current page")
            return

        for section, items in config.defaults.items(): </s> remove         options = {".".join((key, sect)) if sect != key else key: opts
                   for key, value in self._config_cpanel_dict.items()
                   for sect, opts in value.items()}
 </s> add         selection = self._tree.focus()
        category = selection.split("|")[0]
        config = self._configs[category]
        # Create a new config to pull through any defaults change </s> remove     def _reset(self):
        """ Reset all configuration options to their default values. """
        logger.debug("Resetting config")
        for section, items in self._config.defaults.items():
            logger.debug("Resetting section: '%s'", section)
            lookup = [section.split(".")[0], section.split(".")[-1]]
            for item, def_opt in items.items():
                if item == "helptext":
                    continue
                default = def_opt["default"]
                logger.debug("Resetting: '%s' to '%s'", item, default)
                self._config_cpanel_dict[lookup[0]][lookup[1]][item].set(default)
 </s> add         Parameters
        ----------
        page_only: bool, optional
            ``True`` resets just the currently selected page's options to default, ``False`` resets
            all plugins within the currently selected config to default. Default: ``False``
        """
        logger.debug("Resetting config, page_only: %s", page_only)
        selection = self._tree.focus()
        if page_only:
            if selection not in self._config_cpanel_dict:
                logger.info("No configuration options to reset for current page: %s", selection)
                return
            items = list(self._config_cpanel_dict[selection]["options"].values())
        else:
            items = [opt
                     for key, val in self._config_cpanel_dict.items()
                     for opt in val["options"].values()
                     if key.startswith(selection.split("|")[0])]
        for item in items:
            logger.debug("Resetting item '%s' from '%s' to default '%s'",
                         item.title, item.get(), item.default)
            item.set(item.default)
        logger.debug("Reset config")

    def save(self, page_only=False):
        """ Save the configuration file to disk.
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
              self._config.insert_config_section(section, items["helptext"], config=new_config)
              for item, def_opt in items.items():
                  if item == "helptext":
                      continue
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
                if page_only and section != lookup:
                    # Keep existing values for pages we are not updating
                    new_opt = config.get(section, item)
                    logger.debug("Retain existing value '%s' for %s",
                                 new_opt, ".".join([section, item]))
                else:
                    # Get currently selected value
                    key = category
                    if section != "global":
                        key += "|{}".format(section.replace(".", "|"))
                    new_opt = self._config_cpanel_dict[key]["options"][item].get()
                    logger.debug("Updating value to '%s' for %s",
                                 new_opt, ".".join([section, item]))
                helptext = config.format_help(options["helptext"], is_section=False)
                  new_config.set(section, helptext)
                  new_config.set(section, item, str(new_opt))
          self._config.config = new_config
          self._config.save_config()
          logger.info("Saved config: '%s'", self._config.configfile)
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 GUI: Consolidate settings to single menu 
lib/gui/popup_configure.py