[GRASS-SVN] r53953 - in grass/branches/releasebranch_6_4/gui/wxpython: core gmodeler
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 21 12:48:47 PST 2012
Author: martinl
Date: 2012-11-21 12:48:47 -0800 (Wed, 21 Nov 2012)
New Revision: 53953
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/core/workspace.py
grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/model.py
Log:
wxGUI: use default locales for writing workspace and model files
(merge r53952 from devbr6)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/core/workspace.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/core/workspace.py 2012-11-21 20:43:38 UTC (rev 53952)
+++ grass/branches/releasebranch_6_4/gui/wxpython/core/workspace.py 2012-11-21 20:48:47 UTC (rev 53953)
@@ -17,11 +17,13 @@
"""
import os
+import locale
import wx
from core.utils import normalize_whitespace
from core.settings import UserSettings
+from core.gcmd import EncodeString
from nviz.main import NvizSettings
class ProcessWorkspaceFile:
@@ -534,7 +536,8 @@
self.indent = 0
# write header
- self.file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+ enc = locale.getdefaultlocale()[1]
+ self.file.write('<?xml version="1.0" encoding="%s"?>\n' % enc)
self.file.write('<!DOCTYPE gxw SYSTEM "grass-gxw.dtd">\n')
self.file.write('%s<gxw>\n' % (' ' * self.indent))
@@ -641,12 +644,12 @@
if type == 'command':
cmd = mapTree.GetPyData(item)[0]['maplayer'].GetCmd(string=True)
self.file.write('%s<layer type="%s" name="%s" checked="%d">\n' % \
- (' ' * self.indent, type, cmd, checked));
+ (' ' * self.indent, type, EncodeString(cmd), checked));
self.file.write('%s</layer>\n' % (' ' * self.indent));
elif type == 'group':
name = mapTree.GetItemText(item)
self.file.write('%s<group name="%s" checked="%d">\n' % \
- (' ' * self.indent, name.encode('utf8'), checked));
+ (' ' * self.indent, EncodeString(name), checked));
self.indent += 4
subItem = mapTree.GetFirstChild(item)[0]
self.__writeLayer(mapTree, subItem)
@@ -660,7 +663,7 @@
if opacity < 1:
name = name.split('(', -1)[0].strip()
self.file.write('%s<layer type="%s" name="%s" checked="%d" opacity="%f">\n' % \
- (' ' * self.indent, type, name.encode('utf8'), checked, opacity));
+ (' ' * self.indent, type, EncodeString(name), checked, opacity));
self.indent += 4
# selected ?
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/model.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/model.py 2012-11-21 20:43:38 UTC (rev 53952)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/model.py 2012-11-21 20:48:47 UTC (rev 53953)
@@ -31,6 +31,7 @@
import re
import mimetypes
import time
+import locale
try:
import xml.etree.ElementTree as etree
except ImportError:
@@ -1774,7 +1775,8 @@
def _header(self):
"""!Write header"""
- self.fd.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+ enc = locale.getdefaultlocale()[1]
+ self.fd.write('<?xml version="1.0" encoding="%s"?>\n' % enc)
self.fd.write('<!DOCTYPE gxm SYSTEM "grass-gxm.dtd">\n')
self.fd.write('%s<gxm>\n' % (' ' * self.indent))
self.indent += 4
More information about the grass-commit
mailing list