[yum-git] output.py yum/misc.py

James Antill james at linux.duke.edu
Tue Apr 8 15:12:30 UTC 2008


 output.py   |    2 +-
 yum/misc.py |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit f1a7fbee6ddf4be3e078c16cafedf179b935d80c
Author: James Antill <james at and.org>
Date:   Tue Apr 8 11:11:11 2008 -0400

    Fix stupid python str() call, add helper

diff --git a/output.py b/output.py
index 532a06e..1c7fd47 100644
--- a/output.py
+++ b/output.py
@@ -253,7 +253,7 @@ class YumOutput:
 
     def fmtKeyValFill(self, key, val):
         """ Return a key value pair in the common two column output format. """
-        val = str(val)
+        val = misc.to_str(val)
         keylen = len(key)
         cols = self.term.columns
         nxt = ' ' * (keylen - 2) + ': '
diff --git a/yum/misc.py b/yum/misc.py
index 44f85d4..70af2cc 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -522,4 +522,10 @@ def to_unicode(obj, encoding='utf-8'):
             obj = unicode(obj, encoding)
     return obj
 
+def to_str(obj):
+    """ Convert something to a string, if it isn't one. """
+    if not isinstance(obj, basestring):
+        obj = str(obj)
+    return obj
+
         



More information about the Yum-cvs-commits mailing list