[GRASS-SVN] r43999 - grass/branches/releasebranch_6_4/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 24 02:47:16 EDT 2010


Author: martinl
Date: 2010-10-23 23:47:16 -0700 (Sat, 23 Oct 2010)
New Revision: 43999

Modified:
   grass/branches/releasebranch_6_4/lib/python/core.py
   grass/branches/releasebranch_6_4/lib/python/pythonlib.dox
Log:
pythonlib: fn mapsets() added
(merge r43995 from trunk)


Modified: grass/branches/releasebranch_6_4/lib/python/core.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/core.py	2010-10-24 06:46:14 UTC (rev 43998)
+++ grass/branches/releasebranch_6_4/lib/python/core.py	2010-10-24 06:47:16 UTC (rev 43999)
@@ -863,6 +863,28 @@
                 
     return cmdinfo
 
+# interface to g.mapsets
+
+def mapsets(accessible = True):
+    """!List accessible mapsets (mapsets in search path)
+
+    @param accessible False to list all mapsets in the location
+
+    @return list of mapsets
+    """
+    if accessible:
+        flags = 'p'
+    else:
+        flags = 'l'
+    mapsets = read_command('g.mapsets',
+                           flags = flags,
+                           fs = 'newline',
+                           quiet = True)
+    if not mapsets:
+        fatal(_("Unable to list mapsets"))
+        
+    return mapsets.splitlines()
+
 # get debug_level
 if find_program('g.gisenv', ['--help']):
     debug_level = int(gisenv().get('DEBUG', 0))

Modified: grass/branches/releasebranch_6_4/lib/python/pythonlib.dox
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/pythonlib.dox	2010-10-24 06:46:14 UTC (rev 43998)
+++ grass/branches/releasebranch_6_4/lib/python/pythonlib.dox	2010-10-24 06:47:16 UTC (rev 43999)
@@ -167,6 +167,10 @@
 
  - mlist_grouped()
 
+<b>Interface to g.mapsets</b>
+
+ - mapsets()
+
 <b>Color parsing</b>
 
  - parse_color()



More information about the grass-commit mailing list