diff options
Diffstat (limited to 'Lib/idlelib/config.py')
-rw-r--r-- | Lib/idlelib/config.py | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index bbb3e3cde5..4cf44271f3 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -81,31 +81,6 @@ class IdleUserConfParser(IdleConfParser): IdleConfigParser specialised for user configuration handling. """ - def AddSection(self, section): - "If section doesn't exist, add it." - if not self.has_section(section): - self.add_section(section) - - def RemoveEmptySections(self): - "Remove any sections that have no options." - for section in self.sections(): - if not self.GetOptionList(section): - self.remove_section(section) - - def IsEmpty(self): - "Return True if no sections after removing empty sections." - self.RemoveEmptySections() - return not self.sections() - - def RemoveOption(self, section, option): - """Return True if option is removed from section, else False. - - False if either section does not exist or did not have option. - """ - if self.has_section(section): - return self.remove_option(section, option) - return False - def SetOption(self, section, option, value): """Return True if option is added or changed to value, else False. @@ -123,6 +98,31 @@ class IdleUserConfParser(IdleConfParser): self.set(section, option, value) return True + def RemoveOption(self, section, option): + """Return True if option is removed from section, else False. + + False if either section does not exist or did not have option. + """ + if self.has_section(section): + return self.remove_option(section, option) + return False + + def AddSection(self, section): + "If section doesn't exist, add it." + if not self.has_section(section): + self.add_section(section) + + def RemoveEmptySections(self): + "Remove any sections that have no options." + for section in self.sections(): + if not self.GetOptionList(section): + self.remove_section(section) + + def IsEmpty(self): + "Return True if no sections after removing empty sections." + self.RemoveEmptySections() + return not self.sections() + def RemoveFile(self): "Remove user config file self.file from disk if it exists." if os.path.exists(self.file): @@ -829,9 +829,12 @@ class ConfigChanges(dict): def save_all(self): """Save configuration changes to the user config file. - Then clear self in preparation for additional changes. + Clear self in preparation for additional changes. + Return changed for testing. """ idleConf.userCfg['main'].Save() + + changed = False for config_type in self: cfg_type_changed = False page = self[config_type] @@ -844,12 +847,14 @@ class ConfigChanges(dict): cfg_type_changed = True if cfg_type_changed: idleConf.userCfg[config_type].Save() + changed = True for config_type in ['keys', 'highlight']: # Save these even if unchanged! idleConf.userCfg[config_type].Save() self.clear() # ConfigDialog caller must add the following call # self.save_all_changed_extensions() # Uses a different mechanism. + return changed def delete_section(self, config_type, section): """Delete a section from self, userCfg, and file. |