[jhbuild] Decode raw_input for non ASCII locales. (GNOME bug 617794)



commit cca3ba403682330f0ca236edafc2eecf0e72cfb2
Author: Craig Keogh <cskeogh adam com au>
Date:   Sun Jun 6 13:10:23 2010 +0930

    Decode raw_input for non ASCII locales. (GNOME bug 617794)

 jhbuild/frontends/terminal.py |    2 ++
 jhbuild/main.py               |    7 +++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index fb719f0..0d8a29f 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -295,6 +295,7 @@ class TerminalBuildScript(buildscript.BuildScript):
                 uprint('  [%d] %s' % (i, _('Go to phase "%s"') % altphase_label))
                 i += 1
             val = raw_input(uencode(_('choice: ')))
+            val = udecode(val)
             val = val.strip()
             if val == '1':
                 return phase
@@ -327,6 +328,7 @@ class TerminalBuildScript(buildscript.BuildScript):
                     needs_confirmation = False
                 if needs_confirmation:
                     val = raw_input(uencode(_('Type "yes" to confirm the action: ')))
+                    val = udecode(val)
                     val = val.strip()
                     if val.lower() in ('yes', _('yes').lower()):
                         return selected_phase
diff --git a/jhbuild/main.py b/jhbuild/main.py
index 147ec23..adba7e0 100644
--- a/jhbuild/main.py
+++ b/jhbuild/main.py
@@ -57,6 +57,12 @@ def uencode(s):
     else:
         return s
 
+def udecode(s):
+    if type(s) is not unicode:
+        return s.decode(_encoding, 'replace')
+    else:
+        return s
+
 def uprint(*args):
     '''Print Unicode string encoded for the terminal'''
     for s in args[:-1]:
@@ -66,6 +72,7 @@ def uprint(*args):
 
 __builtin__.__dict__['uprint'] = uprint
 __builtin__.__dict__['uencode'] = uencode
+__builtin__.__dict__['udecode'] = udecode
 
 class LoggingFormatter(logging.Formatter):
     def __init__(self):



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