[GRASS-SVN] r48985 - in grass/trunk: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 29 12:33:17 EDT 2011


Author: martinl
Date: 2011-10-29 09:33:17 -0700 (Sat, 29 Oct 2011)
New Revision: 48985

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
   grass/trunk/lib/python/task.py
Log:
wxGUI: show optionally also default values for commands


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-10-29 16:24:40 UTC (rev 48984)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-10-29 16:33:17 UTC (rev 48985)
@@ -1816,7 +1816,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/trunk/lib/python/task.py
===================================================================
--- grass/trunk/lib/python/task.py	2011-10-29 16:24:40 UTC (rev 48984)
+++ grass/trunk/lib/python/task.py	2011-10-29 16:33:17 UTC (rev 48985)
@@ -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