Browse Source

Adding support for autocomplete in MetaModule class.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53781 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 12 years ago
parent
commit
a7adbdb075
1 changed files with 8 additions and 0 deletions
  1. 8 0
      lib/python/pygrass/modules/__init__.py

+ 8 - 0
lib/python/pygrass/modules/__init__.py

@@ -7,6 +7,7 @@ Created on Thu Jul 12 10:23:15 2012
 """
 from __future__ import print_function
 import subprocess
+import fnmatch
 
 try:
     from collections import OrderedDict
@@ -508,11 +509,18 @@ class Module(object):
             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('_', '.')))