From 785de9fb99d91334f0b8cda48076e443ba9f7038 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 16 Jun 2017 14:37:56 +0200 Subject: [PATCH] Add dump_userconfig --- qutebrowser/config/config.py | 16 ---------------- qutebrowser/config/newconfig.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index f7a8c9f7b..555a7a22b 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -720,22 +720,6 @@ class ConfigManager(QObject): with qtutils.savefile_open(configfile) as f: f.write(str(self)) - def dump_userconfig(self): - """Get the part of the config which was changed by the user. - - Return: - The changed config part as string. - """ - lines = [] - for sectname, sect in self.sections.items(): - changed = sect.dump_userconfig() - if changed: - lines.append('[{}]'.format(sectname)) - lines += ['{} = {}'.format(k, v) for k, v in changed] - if not lines: - lines = [''] - return '\n'.join(lines) - def optionxform(self, val): """Implemented to be compatible with ConfigParser interpolation.""" return val diff --git a/qutebrowser/config/newconfig.py b/qutebrowser/config/newconfig.py index 97c1c98a4..5d8b02cca 100644 --- a/qutebrowser/config/newconfig.py +++ b/qutebrowser/config/newconfig.py @@ -258,6 +258,18 @@ class NewConfigManager(QObject): self._values[name] = opt.typ.from_str(value) self.changed.emit(name) + def dump_userconfig(self): + """Get the part of the config which was changed by the user. + + Return: + The changed config part as string. + """ + lines = ['{} = {}'.format(optname, value) + for optname, value in self._values.items()] + if not lines: + lines = [''] + return '\n'.join(lines) + class ConfigContainer: