From b7f39b5f439cc7c3563706478d1ebafca7fde074 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 2 Sep 2012 13:04:38 -0700 Subject: [PATCH] emaint cleanconfmem: use writedict --- pym/portage/emaint/modules/config/config.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pym/portage/emaint/modules/config/config.py b/pym/portage/emaint/modules/config/config.py index e0288528d..33bd19c31 100644 --- a/pym/portage/emaint/modules/config/config.py +++ b/pym/portage/emaint/modules/config/config.py @@ -4,7 +4,7 @@ import portage from portage import os from portage.const import PRIVATE_PATH - +from portage.util import writedict class CleanConfig(object): @@ -53,21 +53,17 @@ class CleanConfig(object): onProgress(maxval, 0) i = 0 keys = sorted(configs) + modified = False for config in keys: if not os.path.exists(config): + modified = True configs.pop(config) messages.append(" %s" % config) if onProgress: onProgress(maxval, i+1) i += 1 - lines = [] - keys = sorted(configs) - for key in keys: - line = ' '.join([key, configs[key]]) - lines.append(line) - lines.append('') - with open(self.target, 'w') as configfile: - configfile.write('\n'.join(lines)) + if modified: + writedict(configs, self.target) return self._format_output(messages, True) def _format_output(self, messages=[], cleaned=False): -- 2.26.2