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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 19 17:42:44 EST 2008


Author: martinl
Date: 2008-12-19 17:42:44 -0500 (Fri, 19 Dec 2008)
New Revision: 34946

Modified:
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
   grass/trunk/lib/python/grass.py
Log:
wxGUI: eliminate g.mlist, use grass.list_grouped2() instead


Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2008-12-19 22:27:43 UTC (rev 34945)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2008-12-19 22:42:44 UTC (rev 34946)
@@ -689,14 +689,7 @@
         @param type layer type ('raster' or 'vector')
         @param mapset mapset name
         """
-        list = gcmd.Command(['g.mlist',
-                             'type=%s' % type,
-                             'mapset=%s' % mapset])
-
-        self.map_layers = []
-        for map in list.ReadStdOutput():
-            self.map_layers.append(map)
-            
+        self.map_layers = grass.list_grouped2(type=type, mapset=mapset)[mapset]
         self.layers.Set(self.map_layers)
         
         # check all items by default

Modified: grass/trunk/lib/python/grass.py
===================================================================
--- grass/trunk/lib/python/grass.py	2008-12-19 22:27:43 UTC (rev 34945)
+++ grass/trunk/lib/python/grass.py	2008-12-19 22:42:44 UTC (rev 34946)
@@ -296,24 +296,24 @@
             result[mapset].extend(line.split())
     return result
 
-def list_grouped2(type, pattern=None):
+def list_grouped2(type, mapset = None, 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
+    mapset_element = None
     for line in read_command("g.mlist", flags="m",
-                             type = type, pattern = pattern).splitlines():
+                             type = type, mapset = mapset, pattern = pattern).splitlines():
         try:
-            map, mapset = line.split('@')
+            map, mapset_element = line.split('@')
         except ValueError:
             print >> sys.stderr, "Invalid element '%s'" % line
             continue
         
-        if result.has_key(mapset):
-            result[mapset].append(map)
+        if result.has_key(mapset_element):
+            result[mapset_element].append(map)
         else:
-	    result[mapset] = [map, ]
+	    result[mapset_element] = [map, ]
     
     return result
 



More information about the grass-commit mailing list