[meld] Replace Preferences dump with stringification



commit a2b89cd86c8b8f5d3e1b6f54beefb6c18f954509
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Oct 27 09:05:47 2012 +1000

    Replace Preferences dump with stringification

 meld/util/prefs.py |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/meld/util/prefs.py b/meld/util/prefs.py
index e721c03..46a8bce 100644
--- a/meld/util/prefs.py
+++ b/meld/util/prefs.py
@@ -152,11 +152,11 @@ class GConfPreferences(object):
         """
         self._listeners.append(callback)
 
-    def dump(self):
-        """Print all preferences.
-        """
+    def __str__(self):
+        prefs_entries = []
         for k, v in self._prefs.items():
-            print k, v.type, v.current
+            prefs_entries.append("%s %s %s" % (k, v.type, str(v.current)))
+        return "\n".join(prefs_entries)
 
 
 class ConfigParserPreferences(object):
@@ -262,11 +262,12 @@ class ConfigParserPreferences(object):
         """
         self._listeners.append(callback)
 
-    def dump(self):
-        """Print all preferences.
-        """
+    def __str__(self):
+        prefs_entries = []
         for k, v in self._prefs.items():
-            print k, v.type, v.current
+            prefs_entries.append("%s %s %s" % (k, v.type, str(v.current)))
+        return "\n".join(prefs_entries)
+
 
 # Prefer gconf, falling back to ConfigParser
 try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]