[GRASS-SVN] r53973 - in grass/trunk/lib/python/pygrass: . vector

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 23 01:59:50 PST 2012


Author: lucadelu
Date: 2012-11-23 01:59:50 -0800 (Fri, 23 Nov 2012)
New Revision: 53973

Modified:
   grass/trunk/lib/python/pygrass/errors.py
   grass/trunk/lib/python/pygrass/vector/abstract.py
Log:
Moved must_bo_open decorator to errors

Modified: grass/trunk/lib/python/pygrass/errors.py
===================================================================
--- grass/trunk/lib/python/pygrass/errors.py	2012-11-22 12:26:11 UTC (rev 53972)
+++ grass/trunk/lib/python/pygrass/errors.py	2012-11-23 09:59:50 UTC (rev 53973)
@@ -5,6 +5,7 @@
 @author: pietro
 """
 
+from grass.script import warning
 
 class GrassError(Exception):
     def __init__(self, value):
@@ -19,4 +20,12 @@
         self.value = value
 
     def __str__(self):
-        return repr(self.value)
\ No newline at end of file
+        return repr(self.value)
+
+def must_be_open(method):
+    def wrapper(self):
+        if self.is_open():
+            return method(self)
+        else:
+            warning(_("The map is close!"))
+    return wrapper
\ No newline at end of file

Modified: grass/trunk/lib/python/pygrass/vector/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/abstract.py	2012-11-22 12:26:11 UTC (rev 53972)
+++ grass/trunk/lib/python/pygrass/vector/abstract.py	2012-11-23 09:59:50 UTC (rev 53973)
@@ -10,19 +10,11 @@
 from vector_type import MAPTYPE
 
 import pygrass.env as env
-from pygrass.errors import GrassError, OpenError
+from pygrass.errors import GrassError, OpenError, must_be_open
 from table import DBlinks
 
 
-def must_be_open(method):
-    def wrapper(self):
-        if self.is_open():
-            return method(self)
-        else:
-            print "You must open the map."
-    return wrapper
 
-
 #=============================================
 # VECTOR ABSTRACT CLASS
 #=============================================



More information about the grass-commit mailing list