[GRASS-SVN] r48986 - in grass/branches/develbranch_6: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 29 12:36:15 EDT 2011


Author: martinl
Date: 2011-10-29 09:36:15 -0700 (Sat, 29 Oct 2011)
New Revision: 48986

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/lib/python/task.py
Log:
wxGUI: show optionally also default values for commands
       (merge r48985 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-10-29 16:33:17 UTC (rev 48985)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-10-29 16:36:15 UTC (rev 48986)
@@ -1820,7 +1820,8 @@
         @param string True to get cmd as a string otherwise a list
         @param substitute True to substitute variables
         """
-        cmd = self.task.get_cmd(ignoreErrors = True, ignoreRequired = True)
+        cmd = self.task.get_cmd(ignoreErrors = True, ignoreRequired = True,
+                                ignoreDefault = False)
         
         # substitute variables
         if substitute:

Modified: grass/branches/develbranch_6/lib/python/task.py
===================================================================
--- grass/branches/develbranch_6/lib/python/task.py	2011-10-29 16:33:17 UTC (rev 48985)
+++ grass/branches/develbranch_6/lib/python/task.py	2011-10-29 16:36:15 UTC (rev 48986)
@@ -191,7 +191,7 @@
         
         return errorList
     
-    def get_cmd(self, ignoreErrors = False, ignoreRequired = False):
+    def get_cmd(self, ignoreErrors = False, ignoreRequired = False, ignoreDefault = True):
         """!Produce an array of command name and arguments for feeding
         into some execve-like command processor.
 
@@ -199,6 +199,7 @@
         far, even though it would not be a correct command for GRASS
         @param ignoreRequired True to ignore required flags, otherwise
         '<required>' is shown
+        @param ignoreDefault True to ignore parameters with default values
         """
         cmd = [self.name]
         
@@ -212,12 +213,14 @@
                 if flag['suppress_required']:
                     suppress_required = True
         for p in self.params:
-            if p.get('value','') ==  '' and p.get('required', False):
+            if p.get('value', '') ==  '' and p.get('required', False):
                 if p.get('default', '') !=  '':
                     cmd +=  [ '%s=%s' % (p['name'], p['default']) ]
                 elif ignoreErrors and not suppress_required and not ignoreRequired:
                     cmd +=  [ '%s=%s' % (p['name'], _('<required>')) ]
-            elif p.get('value','') !=  '' and p['value'] !=  p.get('default','') :
+            elif p.get('value', '') ==  '' and p.get('default', '') != '' and not ignoreDefault:
+                cmd +=  [ '%s=%s' % (p['name'], p['default']) ]
+            elif p.get('value', '') !=  '' and p['value'] !=  p.get('default','') :
                 # Output only values that have been set, and different from defaults
                 cmd +=  [ '%s=%s' % (p['name'], p['value']) ]
         



More information about the grass-commit mailing list