CMS 3D CMS Logo

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__ (self, namespace=None)
 
def global_matches (self, text)
 

Public Attributes

 cmsnamespace
 
 namespace
 
 use_main_ns
 

Detailed Description

Definition at line 18 of file cmscompleter.py.

Constructor & Destructor Documentation

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

Definition at line 19 of file cmscompleter.py.

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  from . import namespaceDict
35  self.cmsnamespace = namespaceDict.getNamespaceDict()
36  except:
37  print 'Could not load CMS namespace'
38 
39 
def __init__(self, namespace=None)
Definition: cmscompleter.py:19

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 40 of file cmscompleter.py.

References python.cmscompleter.CMSCompleter.cmsnamespace.

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 35 of file cmscompleter.py.

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

python.cmscompleter.CMSCompleter.namespace

Definition at line 31 of file cmscompleter.py.

python.cmscompleter.CMSCompleter.use_main_ns

Definition at line 28 of file cmscompleter.py.