Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Completer Class Reference

Public Member Functions

def complete
 
def global_matches
 
def attr_matches
 

Data Fields

 matches
 

Detailed Description

Definition at line 48 of file rlcompleter.py.

Member Function Documentation

def attr_matches (   self,
  text 
)
Compute matches when text contains a dot.

Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in the globals of __main__, it will be evaluated
and its attributes (as revealed by dir()) are used as possible
completions.  (For class instances, class members are are also
considered.)

WARNING: this can still invoke arbitrary C code, if an object
with a __getattr__ hook is evaluated.

Definition at line 85 of file rlcompleter.py.

References sre_parse.dir, and rlcompleter.get_class_members().

85 
86  def attr_matches(self, text):
87  """Compute matches when text contains a dot.
88 
89  Assuming the text is of the form NAME.NAME....[NAME], and is
90  evaluatable in the globals of __main__, it will be evaluated
91  and its attributes (as revealed by dir()) are used as possible
92  completions. (For class instances, class members are are also
93  considered.)
94 
95  WARNING: this can still invoke arbitrary C code, if an object
96  with a __getattr__ hook is evaluated.
97 
98  """
99  import re
100  m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
101  if not m:
102  return
103  expr, attr = m.group(1, 3)
104  object = eval(expr, __main__.__dict__)
105  words = dir(object)
106  if hasattr(object,'__class__'):
107  words.append('__class__')
108  words = words + get_class_members(object.__class__)
109  matches = []
110  n = len(attr)
111  for word in words:
112  if word[:n] == attr and word != "__builtins__":
113  matches.append("%s.%s" % (expr, word))
114  return matches
def complete (   self,
  text,
  state 
)
Return the next possible completion for 'text'.

This is called successively with state == 0, 1, 2, ... until it
returns None.  The completion should begin with 'text'.

Definition at line 50 of file rlcompleter.py.

50 
51  def complete(self, text, state):
52  """Return the next possible completion for 'text'.
53 
54  This is called successively with state == 0, 1, 2, ... until it
55  returns None. The completion should begin with 'text'.
56 
57  """
58  if state == 0:
59  if "." in text:
60  self.matches = self.attr_matches(text)
61  else:
62  self.matches = self.global_matches(text)
63  try:
64  return self.matches[state]
65  except IndexError:
66  return None
def global_matches (   self,
  text 
)
Compute matches when text is a simple name.

Return a list of all keywords, built-in functions and names
currently defines in __main__ that match.

Definition at line 67 of file rlcompleter.py.

67 
68  def global_matches(self, text):
69  """Compute matches when text is a simple name.
70 
71  Return a list of all keywords, built-in functions and names
72  currently defines in __main__ that match.
73 
74  """
75  import keyword
76  matches = []
77  n = len(text)
78  for list in [keyword.kwlist,
79  __builtin__.__dict__.keys(),
80  __main__.__dict__.keys()]:
81  for word in list:
82  if word[:n] == text and word != "__builtins__":
83  matches.append(word)
84  return matches

Field Documentation

matches

Definition at line 59 of file rlcompleter.py.


The documentation for this class was generated from the following file: