[GRASS-SVN] r53091 - grass/branches/releasebranch_6_4/gui/wxpython/core

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 5 02:29:34 PDT 2012


Author: annakrat
Date: 2012-09-05 02:29:34 -0700 (Wed, 05 Sep 2012)
New Revision: 53091

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py
Log:
wxGUI: utils.GetLayerNameFromCmd: fixed case when flags go first

Modified: grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py	2012-09-05 09:14:05 UTC (rev 53090)
+++ grass/branches/releasebranch_6_4/gui/wxpython/core/utils.py	2012-09-05 09:29:34 UTC (rev 53091)
@@ -116,15 +116,24 @@
                      'h_map', 's_map', 'i_map',
                      'reliefmap', 'labels'):
                 params.append((idx, p, v))
-        
+
         if len(params) < 1:
-            if len(dcmd) > 1 and '=' not in dcmd[1]:
-                task = gtask.parse_interface(dcmd[0])
-                p = task.get_options()['params'][0].get('name', '')
-                params.append((1, p, dcmd[1]))
+            if len(dcmd) > 1:
+                i = 1
+                while i < len(dcmd):
+                    if '=' not in dcmd[i] and not dcmd[i].startswith('-'):
+                        task = gtask.parse_interface(dcmd[0])
+                        # this expects the first parameter to be the right one
+                        p = task.get_options()['params'][0].get('name', '')
+                        params.append((i, p, dcmd[i]))
+                        break
+                    i += 1
             else:
                 return mapname, False
-        
+
+        if len(params) < 1:
+            return mapname, False
+
         mapname = params[0][2]
         mapset = ''
         if fullyQualified and '@' not in mapname:
@@ -142,15 +151,15 @@
             else:
                 mapset = grass.gisenv()['MAPSET']
             
-            # update dcmd
-            for i, p, v in params:
-                if p:
-                    dcmd[i] = p + '=' + v
-                else:
-                    dcmd[i] = v
-                if mapset:
-                    dcmd[i] += '@' + mapset
-        
+        # update dcmd
+        for i, p, v in params:
+            if p:
+                dcmd[i] = p + '=' + v
+            else:
+                dcmd[i] = v
+            if mapset:
+                dcmd[i] += '@' + mapset
+
         maps = list()
         for i, p, v in params:
             if not p:



More information about the grass-commit mailing list