[Yum-devel] [PATCH 1/2] Move exception2msg into yum.i18n so everyone can use it easily.
seth vidal
skvidal at fedoraproject.org
Wed Jan 12 16:22:56 UTC 2011
On Wed, 2011-01-12 at 09:58 -0500, James Antill wrote:
> ---
> 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
If the longer-term goal is to dump i18n for kitchen - should we think
about either:
1. putting exception2msg in kitchen
or
2. putting exception2msg elsewhere in yum?
-sv
More information about the Yum-devel
mailing list