[GRASS-SVN] r49142 - in grass/trunk: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 8 06:11:09 EST 2011


Author: martinl
Date: 2011-11-08 03:11:09 -0800 (Tue, 08 Nov 2011)
New Revision: 49142

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/lib/python/task.py
Log:
wxGUI: fix #1485 and #1380 (WxGUI, menu does not work at all (languages using double-byte characters))
       (merge r49141 from relbr64)


Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-11-08 10:57:12 UTC (rev 49141)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-11-08 11:11:09 UTC (rev 49142)
@@ -2100,7 +2100,13 @@
         """
         # parse the interface decription
         if not self.grass_task:
-            tree = etree.fromstring(gtask.get_interface_description(cmd))
+            enc = locale.getdefaultlocale()[1]
+            if enc and enc.lower() == "cp932":
+                p = re.compile('encoding="' + enc + '"', re.IGNORECASE)
+                tree = etree.fromstring(p.sub('encoding="utf-8"',
+                                              gtask.get_interface_description(cmd).decode(enc).encode('utf-8')))
+            else:
+                tree = etree.fromstring(gtask.get_interface_description(cmd))
             self.grass_task = gtask.processTask(tree).get_task()
             
             for p in self.grass_task.params:

Modified: grass/trunk/lib/python/task.py
===================================================================
--- grass/trunk/lib/python/task.py	2011-11-08 10:57:12 UTC (rev 49141)
+++ grass/trunk/lib/python/task.py	2011-11-08 11:11:09 UTC (rev 49142)
@@ -444,17 +444,19 @@
     return cmdout.replace('grass-interface.dtd', os.path.join(os.getenv('GISBASE'), 'etc', 'grass-interface.dtd'))
 
 def parse_interface(name, parser = processTask, blackList = None):
-        """!Parse interface of given GRASS module
-        
-        @param name name of GRASS module to be parsed
-        """
-        # enc = locale.getdefaultlocale()[1]
-        # if enc and enc.lower() not in ("utf8", "utf-8"):
-        #     tree = etree.fromstring(getInterfaceDescription(cmd[0]).decode(enc).encode("utf-8"))
-        # else:
+    """!Parse interface of given GRASS module
+    
+    @param name name of GRASS module to be parsed
+    """
+    enc = locale.getdefaultlocale()[1]
+    if enc and enc.lower() == "cp932":
+        p = re.compile('encoding="' + enc + '"', re.IGNORECASE)
+        tree = etree.fromstring(p.sub('encoding="utf-8"',
+                                      get_interface_description(name).decode(enc).encode("utf-8")))
+    else:
         tree = etree.fromstring(get_interface_description(name))
-        
-        return parser(tree, blackList = blackList).get_task()
+    
+    return parser(tree, blackList = blackList).get_task()
 
 def command_info(cmd):
     """!Returns meta information for any GRASS command as dictionary



More information about the grass-commit mailing list