CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 19 of file cmscompleter.py.

Constructor & Destructor Documentation

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

Definition at line 20 of file cmscompleter.py.

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

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

References python.cmscompleter.CMSCompleter.cmsnamespace.

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

Member Data Documentation

python.cmscompleter.CMSCompleter.cmsnamespace

Definition at line 36 of file cmscompleter.py.

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

python.cmscompleter.CMSCompleter.namespace

Definition at line 32 of file cmscompleter.py.

python.cmscompleter.CMSCompleter.use_main_ns

Definition at line 29 of file cmscompleter.py.