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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 20 of file cmscompleter.py.

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 
40 

Member Function Documentation

◆ global_matches()

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.

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  builtins.__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 

References python.cmscompleter.CMSCompleter.cmsnamespace.

Member Data Documentation

◆ cmsnamespace

python.cmscompleter.CMSCompleter.cmsnamespace

Definition at line 36 of file cmscompleter.py.

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

◆ namespace

python.cmscompleter.CMSCompleter.namespace

Definition at line 32 of file cmscompleter.py.

◆ use_main_ns

python.cmscompleter.CMSCompleter.use_main_ns

Definition at line 29 of file cmscompleter.py.

edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66