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

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

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.