[GRASS-SVN] r61587 - in grass/trunk/lib/python/pygrass/modules/interface: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 12 08:15:06 PDT 2014


Author: zarch
Date: 2014-08-12 08:15:06 -0700 (Tue, 12 Aug 2014)
New Revision: 61587

Modified:
   grass/trunk/lib/python/pygrass/modules/interface/parameter.py
   grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_parameter.py
Log:
pygrass: Add quotes to bash string representation if the parameter is of type string

Modified: grass/trunk/lib/python/pygrass/modules/interface/parameter.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/parameter.py	2014-08-11 11:21:41 UTC (rev 61586)
+++ grass/trunk/lib/python/pygrass/modules/interface/parameter.py	2014-08-12 15:15:06 UTC (rev 61587)
@@ -209,7 +209,8 @@
                               if isinstance(val, tuple) else str(val)
                               for val in self.rawvalue])
         else:
-            value = str(self.rawvalue)
+            value = (repr(self.rawvalue) if self.typedesc == "string"
+                     else str(self.rawvalue))
         return "%s=%s" % (self.name, value)
 
     def get_python(self):

Modified: grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_parameter.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_parameter.py	2014-08-11 11:21:41 UTC (rev 61586)
+++ grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_parameter.py	2014-08-12 15:15:06 UTC (rev 61587)
@@ -309,7 +309,7 @@
         # set private attributes to skip the check function
         param._value = 'elev'
         param._rawvalue = 'elev'
-        self.assertEqual("rast=elev", param.get_bash())
+        self.assertEqual("rast='elev'", param.get_bash())
 
     def test_multiple_strings(self):
         param = Parameter(diz=dict(name='rast', required='yes',
@@ -320,7 +320,7 @@
         self.assertEqual("rast=elev,asp,slp", param.get_bash())
         param._value = ['elev', ]
         param._rawvalue = 'elev'
-        self.assertEqual("rast=elev", param.get_bash())
+        self.assertEqual("rast='elev'", param.get_bash())
 
     def test_keydescvalues(self):
         param = Parameter(diz=dict(name='range', required='yes',



More information about the grass-commit mailing list