Add dump_userconfig
This commit is contained in:
parent
b5eac744b5
commit
785de9fb99
@ -720,22 +720,6 @@ class ConfigManager(QObject):
|
|||||||
with qtutils.savefile_open(configfile) as f:
|
with qtutils.savefile_open(configfile) as f:
|
||||||
f.write(str(self))
|
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 = ['<Default configuration>']
|
|
||||||
return '\n'.join(lines)
|
|
||||||
|
|
||||||
def optionxform(self, val):
|
def optionxform(self, val):
|
||||||
"""Implemented to be compatible with ConfigParser interpolation."""
|
"""Implemented to be compatible with ConfigParser interpolation."""
|
||||||
return val
|
return val
|
||||||
|
@ -258,6 +258,18 @@ class NewConfigManager(QObject):
|
|||||||
self._values[name] = opt.typ.from_str(value)
|
self._values[name] = opt.typ.from_str(value)
|
||||||
self.changed.emit(name)
|
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 = ['<Default configuration>']
|
||||||
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
class ConfigContainer:
|
class ConfigContainer:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user