Bladeren bron

pythonlib: fn mapsets() added

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43995 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 jaren geleden
bovenliggende
commit
8225ac4a44
2 gewijzigde bestanden met toevoegingen van 26 en 0 verwijderingen
  1. 22 0
      lib/python/core.py
  2. 4 0
      lib/python/pythonlib.dox

+ 22 - 0
lib/python/core.py

@@ -863,6 +863,28 @@ def command_info(cmd):
                 
     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))

+ 4 - 0
lib/python/pythonlib.dox

@@ -167,6 +167,10 @@ Returns the name of a temporary file, created with g.tempfile.
 
  - mlist_grouped()
 
+<b>Interface to g.mapsets</b>
+
+ - mapsets()
+
 <b>Color parsing</b>
 
  - parse_color()