Browse Source

wxGUI/modeler: encode model properties and substitute variables when
exporting to python


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52328 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 12 years ago
parent
commit
a21004defd
1 changed files with 10 additions and 8 deletions
  1. 10 8
      gui/wxpython/gmodeler/model.py

+ 10 - 8
gui/wxpython/gmodeler/model.py

@@ -1988,7 +1988,7 @@ class WritePythonFile:
         self.fd.write(
 r"""#!/usr/bin/env python
 #
-############################################################################
+#%s
 #
 # MODULE:       %s
 #
@@ -1998,11 +1998,13 @@ r"""#!/usr/bin/env python
 #
 # DATE:         %s
 #
-#############################################################################
-""" % (properties['name'],
-       properties['author'],
-       properties['description'],
-       time.asctime()))
+#%s
+""" % ('#' * 79,
+       properties['name'],
+       EncodeString(properties['author']),
+       EncodeString('\n# '.join(properties['description'].splitlines())),
+       time.asctime(),
+       '#' * 79))
         
         self.fd.write(
 r"""
@@ -2098,7 +2100,7 @@ if __name__ == "__main__":
         
     def _writePythonAction(self, item, variables = []):
         """!Write model action to Python file"""
-        task = GUI(show = None).ParseCommand(cmd = item.GetLog(string = False))
+        task = GUI(show = None).ParseCommand(cmd = item.GetLog(string = False, substitute = self.model.GetVariables()))
         strcmd = "%sgrass.run_command(" % (' ' * self.indent)
         self.fd.write(strcmd + self._getPythonActionCmd(task, len(strcmd), variables) + '\n')
         
@@ -2116,7 +2118,7 @@ if __name__ == "__main__":
                     params.append('%s = True' % name)
                 else:
                     flags += name
-            
+        
         for p in opts['params']:
             name = p.get('name', None)
             value = p.get('value', None)