CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
python.cmscompleter.CMSCompleter Class Reference
Inheritance diagram for python.cmscompleter.CMSCompleter:

Public Member Functions

def __init__
 
def global_matches
 

Public Attributes

 cmsnamespace
 
 namespace
 
 use_main_ns
 

Detailed Description

Definition at line 17 of file cmscompleter.py.

Constructor & Destructor Documentation

def python.cmscompleter.CMSCompleter.__init__ (   self,
  namespace = None 
)

Definition at line 18 of file cmscompleter.py.

18 
19  def __init__(self, namespace = None):
20 
21  if namespace and not isinstance(namespace, dict):
22  raise TypeError,'namespace must be a dictionary'
23 
24  # Don't bind to namespace quite yet, but flag whether the user wants a
25  # specific namespace or to use __main__.__dict__. This will allow us
26  # to bind to __main__.__dict__ at completion time, not now.
27  if namespace is None:
28  self.use_main_ns = 1
29  else:
30  self.use_main_ns = 0
31  self.namespace = namespace
32  try:
33  # loading cms namespace
34  import namespaceDict
35  self.cmsnamespace = namespaceDict.getNamespaceDict()
36  except:
37  print 'Could not load CMS namespace'
38 

Member Function Documentation

def python.cmscompleter.CMSCompleter.global_matches (   self,
  text 
)
Compute matches when text is a simple name.

Return a list of all keywords, built-in functions and names currently
defined in self.namespace and self.cmsnamespace that match.

Definition at line 39 of file cmscompleter.py.

References python.cmscompleter.CMSCompleter.cmsnamespace.

39 
40  def global_matches(self, text):
41  """Compute matches when text is a simple name.
42 
43  Return a list of all keywords, built-in functions and names currently
44  defined in self.namespace and self.cmsnamespace that match.
45 
46  """
47  import keyword
48  matches = []
49  n = len(text)
50  for list in [keyword.kwlist,
51  __builtin__.__dict__,
52  self.cmsnamespace]:
53  for word in list:
54  if word[:n] == text and word != "__builtins__":
55  matches.append(word)
56  return matches
57 
58 # connect CMSCompleter with readline
59 readline.set_completer(CMSCompleter().complete)
60 readline.parse_and_bind('tab: complete')
61 
62 

Member Data Documentation

python.cmscompleter.CMSCompleter.cmsnamespace

Definition at line 34 of file cmscompleter.py.

Referenced by python.cmscompleter.CMSCompleter.global_matches().

python.cmscompleter.CMSCompleter.namespace

Definition at line 30 of file cmscompleter.py.

python.cmscompleter.CMSCompleter.use_main_ns

Definition at line 27 of file cmscompleter.py.