Explorar o código

Change value type check and add __str__ method to the Module class

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53551 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli %!s(int64=12) %!d(string=hai) anos
pai
achega
2ebae57275
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      lib/python/pygrass/modules/__init__.py

+ 8 - 5
lib/python/pygrass/modules/__init__.py

@@ -44,9 +44,9 @@ _GETFROMTAG = {
 
 _GETTYPE = {
     'string': str,
-    'integer': np.int32,
-    'float': np.float32,
-    'double': np.float64,
+    'integer': int,
+    'float': float,
+    'double': float,
 }
 
 
@@ -177,8 +177,8 @@ class Parameter(object):
             else:
                 self._value = value
         else:
-            raise TypeError('The Parameter <%s>, require: %s' %
-                            (self.name, self.typedesc))
+            str_err = 'The Parameter <%s>, require: %s, get: %s instead'
+            raise TypeError(str_err % (self.name, self.typedesc, type(value)))
 
     # here the property function is used to transform value in an attribute
     # in this case we define which function must be use to get/set the value
@@ -463,6 +463,9 @@ class Module(object):
         if self.run_:
             self.run()
 
+    def __str__(self):
+        return ' '.join(self.make_cmd())
+
     @property
     def __doc__(self):
         """{cmd_name}({cmd_params})