Browse Source

wxGUI: eliminate g.mlist, use grass.list_grouped2() instead

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34946 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 years ago
parent
commit
9fb2e15afd
2 changed files with 8 additions and 15 deletions
  1. 1 8
      gui/wxpython/gui_modules/gdialogs.py
  2. 7 7
      lib/python/grass.py

+ 1 - 8
gui/wxpython/gui_modules/gdialogs.py

@@ -689,14 +689,7 @@ class LoadMapLayersDialog(wx.Dialog):
         @param type layer type ('raster' or 'vector')
         @param type layer type ('raster' or 'vector')
         @param mapset mapset name
         @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)
         self.layers.Set(self.map_layers)
         
         
         # check all items by default
         # check all items by default

+ 7 - 7
lib/python/grass.py

@@ -296,24 +296,24 @@ def list_grouped(type):
             result[mapset].extend(line.split())
             result[mapset].extend(line.split())
     return result
     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
     """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. 
     are mapset names and the values are lists of maps in that mapset. 
     """
     """
     result = {}
     result = {}
-    mapset = None
+    mapset_element = None
     for line in read_command("g.mlist", flags="m",
     for line in read_command("g.mlist", flags="m",
-                             type = type, pattern = pattern).splitlines():
+                             type = type, mapset = mapset, pattern = pattern).splitlines():
         try:
         try:
-            map, mapset = line.split('@')
+            map, mapset_element = line.split('@')
         except ValueError:
         except ValueError:
             print >> sys.stderr, "Invalid element '%s'" % line
             print >> sys.stderr, "Invalid element '%s'" % line
             continue
             continue
         
         
-        if result.has_key(mapset):
-            result[mapset].append(map)
+        if result.has_key(mapset_element):
+            result[mapset_element].append(map)
         else:
         else:
-	    result[mapset] = [map, ]
+	    result[mapset_element] = [map, ]
     
     
     return result
     return result