[GRASS-SVN] r34631 - in grass/branches/develbranch_6: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 30 10:27:48 EST 2008


Author: martinl
Date: 2008-11-30 10:27:48 -0500 (Sun, 30 Nov 2008)
New Revision: 34631

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/lib/python/grass.py
Log:
grass.py: list_grouped2() added (g.mlist version of list_grouped())


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2008-11-30 15:16:57 UTC (rev 34630)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2008-11-30 15:27:48 UTC (rev 34631)
@@ -209,7 +209,7 @@
                 mapsets[i] = mapsets[0]
                 mapsets[0] = curr_mapset
 
-        filesdict = grass.list_grouped(elementdict[element])
+        filesdict = grass.list_grouped2(elementdict[element])
         
         for dir in mapsets:
             dir_node = self.AddItem('Mapset: '+dir)

Modified: grass/branches/develbranch_6/lib/python/grass.py
===================================================================
--- grass/branches/develbranch_6/lib/python/grass.py	2008-11-30 15:16:57 UTC (rev 34630)
+++ grass/branches/develbranch_6/lib/python/grass.py	2008-11-30 15:27:48 UTC (rev 34631)
@@ -314,6 +314,23 @@
             result[mapset].extend(line.split())
     return result
 
+def list_grouped2(type, pattern=None):
+    """Returns the output from running g.mlist, as a dictionary where the keys
+    are mapset names and the values are lists of maps in that mapset. 
+    """
+    result = {}
+    mapset = None
+    for line in read_command("g.mlist", flags="m",
+                             type = type, pattern = pattern).splitlines():
+        map, mapset = line.split('@')
+        
+        if result.has_key(mapset):
+            result[mapset].append(map)
+        else:
+	    result[mapset] = [map, ]
+    
+    return result
+
 def _concat(xs):
     result = []
     for x in xs:



More information about the grass-commit mailing list