Przeglądaj źródła

wxGUI/dbm: unicode bug fix
(merge https://trac.osgeo.org/grass/changeset/41581 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@41582 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 15 lat temu
rodzic
commit
7260454307

+ 1 - 16
gui/wxpython/gui_modules/dbm.py

@@ -58,21 +58,6 @@ from debug import Debug
 from dbm_dialogs import ModifyTableRecord
 from preferences import globalSettings as UserSettings
 
-def unicodeValue(value):
-    """!Encode value"""
-    enc = UserSettings.Get(group='atm', key='encoding', subkey='value')
-    if enc:
-        value = unicode(value, enc)
-    elif os.environ.has_key('GRASS_DB_ENCODING'):
-        value = unicode(value, os.environ['GRASS_DB_ENCODING'])
-    else:
-        try:
-            value = unicode(value, 'ascii')
-        except UnicodeDecodeError:
-            value = _("Unable to decode value. Set encoding in GUI preferences ('Attributes').")
-    
-    return value
-
 class Log:
     """
     The log output is redirected to the status bar of the containing frame.
@@ -301,7 +286,7 @@ class VirtualAttributeList(wx.ListCtrl,
             else:
                 # encode string values
                 try:
-                    self.itemDataMap[i].append(unicodeValue(value))
+                    self.itemDataMap[i].append(dbm_base.unicodeValue(value))
                 except UnicodeDecodeError:
                     self.itemDataMap[i].append(_("Unable to decode value. "
                                                  "Set encoding in GUI preferences ('Attributes')."))

+ 16 - 0
gui/wxpython/gui_modules/dbm_base.py

@@ -21,6 +21,22 @@ import wx
 
 import gselect
 import gcmd
+from preferences import globalSettings as UserSettings
+
+def unicodeValue(value):
+    """!Encode value"""
+    enc = UserSettings.Get(group='atm', key='encoding', subkey='value')
+    if enc:
+        value = unicode(value, enc)
+    elif os.environ.has_key('GRASS_DB_ENCODING'):
+        value = unicode(value, os.environ['GRASS_DB_ENCODING'])
+    else:
+        try:
+            value = unicode(value, 'ascii')
+        except UnicodeDecodeError:
+            value = _("Unable to decode value. Set encoding in GUI preferences ('Attributes').")
+    
+    return value
 
 def createDbInfoDesc(panel, mapDBInfo, layer):
     """!Create database connection information content"""