[GRASS-SVN] r53781 - grass/trunk/lib/python/pygrass/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 12 10:14:05 PST 2012
Author: zarch
Date: 2012-11-12 10:14:04 -0800 (Mon, 12 Nov 2012)
New Revision: 53781
Modified:
grass/trunk/lib/python/pygrass/modules/__init__.py
Log:
Adding support for autocomplete in MetaModule class.
Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py 2012-11-12 18:13:53 UTC (rev 53780)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py 2012-11-12 18:14:04 UTC (rev 53781)
@@ -7,6 +7,7 @@
"""
from __future__ import print_function
import subprocess
+import fnmatch
try:
from collections import OrderedDict
@@ -508,11 +509,18 @@
self.popen.wait()
self.stdout, self.stderr = self.popen.communicate()
+_CMDS = list(grass.script.core.get_commands()[0])
+_CMDS.sort()
+
class MetaModule(object):
def __init__(self, prefix):
self.prefix = prefix
+ def __dir__(self):
+ return [mod[(len(self.prefix) + 1):].replace('.', '_')
+ for mod in fnmatch.filter(_CMDS, "%s.*" % self.prefix)]
+
def __getattr__(self, name):
return Module('%s.%s' % (self.prefix, name.replace('_', '.')))
More information about the grass-commit
mailing list