emaint cleanconfmem: use writedict
authorZac Medico <zmedico@gentoo.org>
Sun, 2 Sep 2012 20:04:38 +0000 (13:04 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 2 Sep 2012 20:04:38 +0000 (13:04 -0700)
pym/portage/emaint/modules/config/config.py

index e0288528d8ac3ff117769f9b67150c5102d47afb..33bd19c31f76e795147f1e614658d083580aa5f8 100644 (file)
@@ -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):