[Yum-devel] [PATCH 1/2] Move exception2msg into yum.i18n so everyone can use it easily.
James Antill
james at and.org
Wed Jan 12 14:58:00 UTC 2011
---
utils.py | 23 +----------------------
yum/i18n.py | 22 +++++++++++++++++++++-
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/utils.py b/utils.py
index ced6ba0..8891ddf 100644
--- a/utils.py
+++ b/utils.py
@@ -21,7 +21,7 @@ import yum
from cli import *
from yum import Errors
from yum import _
-from yum.i18n import utf8_width
+from yum.i18n import utf8_width, exception2msg
from yum import logginglevels
from optparse import OptionGroup
@@ -129,27 +129,6 @@ def show_lock_owner(pid, logger):
return ps
-def exception2msg(e):
- """ DIE python DIE! Which one works:
- to_unicode(e.value); unicode(e); str(e);
- Call this so you don't have to care. """
- try:
- return to_unicode(e.value)
- except:
- pass
-
- try:
- return unicode(e)
- except:
- pass
-
- try:
- return str(e)
- except:
- pass
- return "<exception failed to convert to text>"
-
-
class YumUtilBase(YumBaseCli):
def __init__(self,name,ver,usage):
YumBaseCli.__init__(self)
diff --git a/yum/i18n.py b/yum/i18n.py
index 9889bf6..2df81bb 100755
--- a/yum/i18n.py
+++ b/yum/i18n.py
@@ -461,7 +461,27 @@ def str_eq(a, b):
return True
return False
-
+
+def exception2msg(e):
+ """ DIE python DIE! Which one works:
+ to_unicode(e.value); unicode(e); str(e);
+ Call this so you don't have to care. """
+ try:
+ return to_unicode(e.value)
+ except:
+ pass
+
+ try:
+ return unicode(e)
+ except:
+ pass
+
+ try:
+ return str(e)
+ except:
+ pass
+ return "<exception failed to convert to text>"
+
try:
'''
Setup the yum translation domain and make _() and P_() translation wrappers
--
1.7.2.3
More information about the Yum-devel
mailing list