[GRASS-SVN] r34948 - in grass/branches/develbranch_6:
gui/wxpython/gui_modules lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 19 18:00:28 EST 2008
Author: martinl
Date: 2008-12-19 18:00:28 -0500 (Fri, 19 Dec 2008)
New Revision: 34948
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/lib/python/grass.py
Log:
wxGUI: eliminate g.mlist, use grass.list_grouped2() instead
(merge from trunk, r34946, r34947)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2008-12-19 22:58:30 UTC (rev 34947)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2008-12-19 23:00:28 UTC (rev 34948)
@@ -689,14 +689,11 @@
@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)
-
+ try:
+ self.map_layers = grass.list_grouped2(type=type, mapset=mapset)[mapset]
+ except KeyError:
+ self.map_layers = []
+
self.layers.Set(self.map_layers)
# check all items by default
Modified: grass/branches/develbranch_6/lib/python/grass.py
===================================================================
--- grass/branches/develbranch_6/lib/python/grass.py 2008-12-19 22:58:30 UTC (rev 34947)
+++ grass/branches/develbranch_6/lib/python/grass.py 2008-12-19 23:00:28 UTC (rev 34948)
@@ -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