[GRASS-SVN] r73029 - grass/trunk/lib/python/pygrass/modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 2 22:50:27 PDT 2018


Author: zarch
Date: 2018-08-02 22:50:27 -0700 (Thu, 02 Aug 2018)
New Revision: 73029

Modified:
   grass/trunk/lib/python/pygrass/modules/shortcuts.py
Log:
pygrass - shortcuts: Fix use of python reserved words

Modified: grass/trunk/lib/python/pygrass/modules/shortcuts.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/shortcuts.py	2018-08-03 05:50:14 UTC (rev 73028)
+++ grass/trunk/lib/python/pygrass/modules/shortcuts.py	2018-08-03 05:50:27 UTC (rev 73029)
@@ -34,6 +34,17 @@
        >>> what.inputs.map = 'elevation'
        >>> what.inputs.coordinates = [640000,220500]          # doctest: +SKIP
        >>> what.run()                                         # doctest: +SKIP
+       >>> v = MetaModule('v')
+       >>> v.import                                      # doctest: +ELLIPSIS
+       Traceback (most recent call last):
+         File ".../doctest.py", line 1315, in __run
+          compileflags, 1) in test.globs
+         File "<doctest grass.pygrass.modules.shortcuts.MetaModule[16]>", line 1
+          v.import
+               ^
+       SyntaxError: invalid syntax
+       >>> v.import_
+       Module('v.import')
     """
     def __init__(self, prefix, cls=None):
         self.prefix = prefix
@@ -44,7 +55,8 @@
                 for mod in fnmatch.filter(_CMDS, "%s.*" % self.prefix)]
 
     def __getattr__(self, name):
-        return self.cls('%s.%s' % (self.prefix, name.replace('_', '.')))
+        return self.cls('%s.%s' % (self.prefix,
+                                   name.strip('_').replace('_', '.')))
 
 
 # http://grass.osgeo.org/grass75/manuals/full_index.html



More information about the grass-commit mailing list