[GRASS-SVN] r34632 - in grass/trunk: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 30 10:29:08 EST 2008


Author: martinl
Date: 2008-11-30 10:29:08 -0500 (Sun, 30 Nov 2008)
New Revision: 34632

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/lib/python/grass.py
Log:
grass.py: list_grouped2() added (g.mlist version of list_grouped())
	  (merge from devbr6, r34631)


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-11-30 15:27:48 UTC (rev 34631)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-11-30 15:29:08 UTC (rev 34632)
@@ -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/trunk/lib/python/grass.py
===================================================================
--- grass/trunk/lib/python/grass.py	2008-11-30 15:27:48 UTC (rev 34631)
+++ grass/trunk/lib/python/grass.py	2008-11-30 15:29:08 UTC (rev 34632)
@@ -296,6 +296,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