[GRASS-SVN] r57488 - grass/trunk/lib/python/pygrass/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 23 04:35:27 PDT 2013


Author: zarch
Date: 2013-08-23 04:35:27 -0700 (Fri, 23 Aug 2013)
New Revision: 57488

Modified:
   grass/trunk/lib/python/pygrass/gis/__init__.py
Log:
Add path methods and manage errors when create a new mapset

Modified: grass/trunk/lib/python/pygrass/gis/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/__init__.py	2013-08-23 11:27:51 UTC (rev 57487)
+++ grass/trunk/lib/python/pygrass/gis/__init__.py	2013-08-23 11:35:27 UTC (rev 57488)
@@ -69,8 +69,11 @@
 
 
 def make_mapset(mapset, location=None, gisdbase=None):
-    if libgis.G__make_mapset(gisdbase, location, mapset) != 0:
+    res = libgis.G_make_mapset(gisdbase, location, mapset)
+    if res == -1:
         raise GrassError("I cannot create a new mapset.")
+    elif res == -2:
+        raise GrassError("Illegal name.")
 
 
 class Gisdbase(object):
@@ -208,7 +211,10 @@
             return fnmatch.filter(mapsets, pattern)
         return mapsets
 
+    def path(self):
+        return join(self.gisdbase, self.name)
 
+
 class Mapset(object):
     """Mapset ::
 
@@ -226,6 +232,7 @@
         self.gisdbase = gisdbase
         self.location = location
         self.name = mapset
+        self.visible = VisibleMapset(self.name, self.location, self.gisdbase)
 
     def _get_gisdb(self):
         return self._gisdb
@@ -311,4 +318,7 @@
         """Delete the mapset"""
         if self.is_current():
             raise GrassError('The mapset is in use.')
-        shutil.rmtree(join(self.gisdbase, self.location, self.name))
+        shutil.rmtree(self.path())
+
+    def path(self):
+        return join(self.gisdbase, self.location, self.name)



More information about the grass-commit mailing list