[GRASS-SVN] r48671 - in grass/branches/develbranch_6/gui/wxpython: gui_modules icons xml

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 7 05:50:29 EDT 2011


Author: martinl
Date: 2011-10-07 02:50:28 -0700 (Fri, 07 Oct 2011)
New Revision: 48671

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/icons/icon.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml
Log:
wxGUI/modeler: fix variable substitution
	       (merge r48670 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-07 09:49:17 UTC (rev 48670)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-10-07 09:50:28 UTC (rev 48671)
@@ -527,8 +527,7 @@
                                 continue
                             
                             if pattern.search(par[idx]['value']):
-                                par[idx]['value'] = pattern.sub(par[idx]['value'], var)
-                            
+                                par[idx]['value'] = pattern.sub(var, par[idx]['value'])
                         self.RunAction(action, { action.GetName(): {'params': par } }, log, onDone)
         
         if params:
@@ -4695,12 +4694,12 @@
     sys.exit(main())
 """)
         
-    def _writePythonItem(self, item, ignoreBlock = True):
+    def _writePythonItem(self, item, ignoreBlock = True, variables = []):
         """!Write model object to Python file"""
         if isinstance(item, ModelAction):
             if ignoreBlock and item.GetBlockId(): # ignore items in loops of conditions
                 return
-            self._writePythonAction(item)
+            self._writePythonAction(item, variables = variables)
         elif isinstance(item, ModelLoop) or isinstance(item, ModelCondition):
             # substitute condition
             variables = self.model.GetVariables()
@@ -4718,13 +4717,13 @@
                 if condText[0] == '`' and condText[-1] == '`':
                     task = menuform.GUI(show = None).ParseCommand(cmd = utils.split(condText[1:-1]))
                     cond += "grass.read_command("
-                    cond += self._getPythonActionCmd(task, len(cond)) + ".splitlines()"
+                    cond += self._getPythonActionCmd(task, len(cond), variables = [condVar]) + ".splitlines()"
                 else:
                     cond += condText
                 self.fd.write('%s:\n' % cond)
                 self.indent += 4
                 for action in item.GetItems():
-                    self._writePythonItem(action, ignoreBlock = False)
+                    self._writePythonItem(action, ignoreBlock = False, variables = [condVar])
                 self.indent -= 4
             else: # ModelCondition
                 self.fd.write('%sif %s:\n' % (' ' * self.indent, cond))
@@ -4740,13 +4739,13 @@
                         self._writePythonItem(action, ignoreBlock = False)
                 self.indent += 4
         
-    def _writePythonAction(self, item):
+    def _writePythonAction(self, item, variables = []):
         """!Write model action to Python file"""
         task = menuform.GUI(show = None).ParseCommand(cmd = item.GetLog(string = False))
         strcmd = "%sgrass.run_command(" % (' ' * self.indent)
-        self.fd.write(strcmd + self._getPythonActionCmd(task, len(strcmd)) + '\n')
+        self.fd.write(strcmd + self._getPythonActionCmd(task, len(strcmd), variables) + '\n')
         
-    def _getPythonActionCmd(self, task, cmdIndent):
+    def _getPythonActionCmd(self, task, cmdIndent, variables = []):
         opts = task.get_options()
         
         ret = ''

Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2011-10-07 09:49:17 UTC (rev 48670)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py	2011-10-07 09:50:28 UTC (rev 48671)
@@ -401,11 +401,11 @@
         'toPython'   : MetaIcon(img = iconSet.get('python-export', wx.ART_ERROR),
                                 label = _('Export model to Python script')),
         'actionAdd'  : MetaIcon(img = iconSet.get('module-add', wx.ART_ERROR),
-                                label = _('Add action (GRASS module) to model')),
+                                label = _('Add command (GRASS module) to model')),
         'dataAdd'    : MetaIcon(img = iconSet.get('data-add', wx.ART_ERROR),
-                                label = _('Add data item to model')),
+                                label = _('Add data to model')),
         'relation'   : MetaIcon(img = iconSet.get('relation-create', wx.ART_ERROR),
-                                label = _('Define relation between data and action items')),
+                                label = _('Manually define relation between data and commands')),
         'run'        : MetaIcon(img = iconSet.get('execute', wx.ART_ERROR),
                                 label = _('Run model')),
         'validate'   : MetaIcon(img = iconSet.get('check', wx.ART_ERROR),

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml	2011-10-07 09:49:17 UTC (rev 48670)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml	2011-10-07 09:50:28 UTC (rev 48671)
@@ -66,8 +66,8 @@
       <label>&amp;Model</label>
       <items>
 	<menuitem>
-	  <label>Add action</label>
-	  <help>Add action (GRASS module) to model</help>
+	  <label>Add command</label>
+	  <help>Add action (GRASS command) to model</help>
 	  <handler>OnAddAction</handler>
 	  <shortcut>Ctrl+A</shortcut>
 	</menuitem>
@@ -83,8 +83,8 @@
 	  <handler>OnDefineRelation</handler>
 	</menuitem>
 	<menuitem>
-	  <label>Add loop</label>
-	  <help>Adds loop (for) to model</help>
+	  <label>Add loop / series</label>
+	  <help>Adds loop (series) to model</help>
 	  <handler>OnDefineLoop</handler>
 	  <shortcut>Ctrl+L</shortcut>
 	</menuitem>



More information about the grass-commit mailing list