[GRASS-SVN] r35834 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 9 15:20:13 EST 2009
Author: martinl
Date: 2009-02-09 15:20:11 -0500 (Mon, 09 Feb 2009)
New Revision: 35834
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py
Log:
wxGUI: fix workspace: replace invalid characters (<>)
(merge from trunk, r35829)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py 2009-02-09 20:05:28 UTC (rev 35833)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py 2009-02-09 20:20:11 UTC (rev 35834)
@@ -1,5 +1,5 @@
"""
- at package workspace
+ at package workspace.py
@brief Open/save workspace definition file
@@ -8,14 +8,12 @@
- WriteWorkspaceFile
- ProcessGrcFile
-(C) 2007-2008 by the GRASS Development Team
+(C) 2007-2009 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.
@author Martin Landa <landa.martin gmail.com>
-
- at date 2007-2008
"""
import os
@@ -70,6 +68,13 @@
self.cmd = []
self.displayIndex = -1 # first display has index '0'
+ def __filterValue(self, value):
+ """Translate value"""
+ value = value.replace('<', '<')
+ value = value.replace('>', '>')
+
+ return value
+
def startElement(self, name, attrs):
if name == 'display':
self.displayIndex += 1
@@ -252,7 +257,8 @@
self.Opacity = self.cmd = None
elif name == 'parameter':
- self.cmd.append('%s=%s' % (self.parameterName, self.value))
+ self.cmd.append('%s=%s' % (self.parameterName,
+ self.__filterValue(self.value)))
self.parameterName = self.value = None
#
@@ -396,6 +402,13 @@
self.indent =- 4
file.write('%s</gxw>\n' % (' ' * self.indent))
+ def __filterValue(self, value):
+ """Make value XML-valid"""
+ value = value.replace('<', '<')
+ value = value.replace('>', '>')
+
+ return value
+
def __writeLayer(self, mapTree, item):
"""Write bunch of layers to GRASS Workspace XML file"""
self.indent += 4
@@ -449,7 +462,7 @@
(' ' * self.indent, key))
self.indent += 4
self.file.write('%s<value>%s</value>\n' %
- (' ' * self.indent, value))
+ (' ' * self.indent, self.__filterValue(val)))
self.indent -= 4
self.file.write('%s</parameter>\n' % (' ' * self.indent));
self.indent -= 4
More information about the grass-commit
mailing list