Browse Source

pythonlib/core: allow underscore at the end of module option (backport of https://trac.osgeo.org/grass/changeset/62196 without tests)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@62256 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 10 years ago
parent
commit
8fbd3a230a
1 changed files with 12 additions and 1 deletions
  1. 12 1
      lib/python/script/core.py

+ 12 - 1
lib/python/script/core.py

@@ -285,8 +285,15 @@ def make_command(prog, flags="", overwrite=False, quiet=False, verbose=False,
         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 @@ def start_command(prog, flags="", overwrite=False, quiet=False,
 
     @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>)