[GRASS-SVN] r55137 - in grass/branches/releasebranch_6_4/gui/wxpython: core gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Feb 20 15:10:57 PST 2013
Author: annakrat
Date: 2013-02-20 15:10:57 -0800 (Wed, 20 Feb 2013)
New Revision: 55137
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: fix #1605
Modified: grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py 2013-02-20 20:10:07 UTC (rev 55136)
+++ grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py 2013-02-20 23:10:57 UTC (rev 55137)
@@ -331,6 +331,51 @@
return layers
+def GetAllVectorLayers(vector):
+ """!Returns list of all vector layers as strings.
+
+ @param vector name of vector map
+ """
+ layers = []
+ if not vector:
+ return layers
+
+ fullname = grass.find_file(name = vector, element = 'vector')['fullname']
+ if not fullname:
+ Debug.msg(3, "utils.GetAllVectorLayers(): vector map <%s> not found" % vector)
+ return layers
+
+ ret, out, msg = RunCommand('v.category',
+ getErrorMsg = True,
+ read = True,
+ quiet = True,
+ option = 'report',
+ flags = 'g',
+ input = fullname)
+ print out
+ if ret != 0:
+ sys.stderr.write(_("Vector map <%(map)s>: %(msg)s\n") % { 'map' : fullname, 'msg' : msg })
+ return layers
+
+ Debug.msg(1, "utils.GetAllVectorLayers(): ret %s" % ret)
+
+ for line in out.splitlines():
+ if 'all' not in line:
+ continue
+ try:
+ layer = line.split(' ')[0]
+ except IndexError:
+ continue
+ # use this to get layer names
+ # but only when all modules use Vect_get_field2()
+ # which is not the case right now
+ layers.append(layer)
+
+ Debug.msg(3, "utils.GetAllVectorLayers(): vector=%s -> %s" % \
+ (fullname, ','.join(layers)))
+
+ return layers
+
def Deg2DMS(lon, lat, string = True, hemisphere = True, precision = 3):
"""!Convert deg value to dms string
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/gselect.py 2013-02-20 20:10:07 UTC (rev 55136)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/gselect.py 2013-02-20 23:10:57 UTC (rev 55137)
@@ -48,7 +48,7 @@
from core.gcmd import RunCommand, GError, GMessage
from core.utils import GetListOfLocations, GetListOfMapsets, GetFormats
-from core.utils import GetSettingsPath, GetValidLayerName, ListSortLower, GetVectorNumberOfLayers
+from core.utils import GetSettingsPath, GetValidLayerName, ListSortLower, GetAllVectorLayers
from core.settings import UserSettings
from core.debug import Debug
@@ -681,7 +681,7 @@
@param vector name of vector map
"""
if vector:
- layers = GetVectorNumberOfLayers(vector)
+ layers = GetAllVectorLayers(vector)
else:
layers = list()
More information about the grass-commit
mailing list