[GRASS-SVN] r49064 - in grass/branches/develbranch_6: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 3 04:00:30 EDT 2011


Author: martinl
Date: 2011-11-03 01:00:30 -0700 (Thu, 03 Nov 2011)
New Revision: 49064

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/lib/python/task.py
Log:
attempt to fix #1485 (Cannot save workspace from wxGUI)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-11-03 05:55:21 UTC (rev 49063)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-11-03 08:00:30 UTC (rev 49064)
@@ -1917,7 +1917,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/branches/develbranch_6/lib/python/task.py
===================================================================
--- grass/branches/develbranch_6/lib/python/task.py	2011-11-03 05:55:21 UTC (rev 49063)
+++ grass/branches/develbranch_6/lib/python/task.py	2011-11-03 08:00:30 UTC (rev 49064)
@@ -444,17 +444,17 @@
     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":
+        tree = etree.fromstring(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