[GRASS-SVN] r57490 - grass/trunk/lib/python/pygrass/modules/interface
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 23 04:39:55 PDT 2013
Author: zarch
Date: 2013-08-23 04:39:55 -0700 (Fri, 23 Aug 2013)
New Revision: 57490
Modified:
grass/trunk/lib/python/pygrass/modules/interface/parameter.py
Log:
Manage string parameter
Modified: grass/trunk/lib/python/pygrass/modules/interface/parameter.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/parameter.py 2013-08-23 11:36:25 UTC (rev 57489)
+++ grass/trunk/lib/python/pygrass/modules/interface/parameter.py 2013-08-23 11:39:55 UTC (rev 57490)
@@ -106,6 +106,15 @@
(self.name, self.values))
else:
self._value = value
+ elif self.type is str and isinstance(value, unicode):
+ if hasattr(self, 'values'):
+ if value in self.values:
+ self._value = value
+ else:
+ raise ValueError('The Parameter <%s>, must be one of: %r' %
+ (self.name, self.values))
+ else:
+ self._value = value
else:
str_err = 'The Parameter <%s>, require: %s, get: %s instead'
raise TypeError(str_err % (self.name, self.typedesc, type(value)))
More information about the grass-commit
mailing list