[GRASS-SVN] r62256 - grass/branches/releasebranch_7_0/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 14 18:17:15 PDT 2014


Author: wenzeslaus
Date: 2014-10-14 18:17:15 -0700 (Tue, 14 Oct 2014)
New Revision: 62256

Modified:
   grass/branches/releasebranch_7_0/lib/python/script/core.py
Log:
pythonlib/core: allow underscore at the end of module option (backport of r62196 without tests)

Modified: grass/branches/releasebranch_7_0/lib/python/script/core.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/script/core.py	2014-10-15 00:28:17 UTC (rev 62255)
+++ grass/branches/releasebranch_7_0/lib/python/script/core.py	2014-10-15 01:17:15 UTC (rev 62256)
@@ -285,8 +285,15 @@
         args.append("-%s" % flags)
     for opt, val in options.iteritems():
         if val != None:
-            if opt[0] == '_':
+            if opt.startswith('_'):
                 opt = opt[1:]
+                warning(_("To run the module add underscore at the end"
+                    " of the option <%s> to avoid conflict with Python"
+                    " keywords. Underscore at the beginning is"
+                    " depreciated in GRASS GIS 7.0 and will be removed"
+                    " in version 7.1.") % opt)
+            elif opt.endswith('_'):
+                opt = opt[:-1]
             args.append("%s=%s" % (opt, _make_val(val)))
     return args
 
@@ -311,6 +318,10 @@
 
     @endcode
 
+    If the module parameter is the same as Python keyword, add
+    underscore at the end of the parameter. For example, use
+    ``lambda_=1.6`` instead of ``lambda=1.6``.
+
     @param prog GRASS module
     @param flags flags to be used (given as a string)
     @param overwrite True to enable overwriting the output (<tt>--o</tt>)



More information about the grass-commit mailing list