[GRASS-SVN] r54252 - grass/trunk/gui/wxpython/dbmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 8 11:32:32 PST 2012


Author: martinl
Date: 2012-12-08 11:32:31 -0800 (Sat, 08 Dec 2012)
New Revision: 54252

Modified:
   grass/trunk/gui/wxpython/dbmgr/vinfo.py
Log:
wxGUI/dbmgr: rewrite unicodeValue()


Modified: grass/trunk/gui/wxpython/dbmgr/vinfo.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/vinfo.py	2012-12-08 18:15:13 UTC (rev 54251)
+++ grass/trunk/gui/wxpython/dbmgr/vinfo.py	2012-12-08 19:32:31 UTC (rev 54252)
@@ -31,24 +31,13 @@
         return value
     
     enc = UserSettings.Get(group = 'atm', key = 'encoding', subkey = 'value')
-    if enc:
-        try:
-            value = unicode(value, enc)
-        except LookupError, e:
-            value = e
-    elif 'GRASS_DB_ENCODING' in os.environ:
-        try:
-            value = unicode(value, os.environ['GRASS_DB_ENCODING'])
-        except LookupError, e:
-            value = e
+    if not enc and 'GRASS_DB_ENCODING' in os.environ:
+        enc = os.environ['GRASS_DB_ENCODING']
     else:
-        try:
-            value = unicode(value, 'ascii')
-        except UnicodeDecodeError:
-            value = _("Unable to decode value. Set encoding in GUI preferences ('Attributes').")
+        enc = 'ascii'
     
-    return value
-
+    return unicode(value, enc, errors = 'replace')
+    
 def createDbInfoDesc(panel, mapDBInfo, layer):
     """!Create database connection information content"""
     infoFlexSizer = wx.FlexGridSizer (cols = 2, hgap = 1, vgap = 1)



More information about the grass-commit mailing list