3 """ |
3 """ |
4 Word completion for the eric5 shell |
4 Word completion for the eric5 shell |
5 |
5 |
6 <h4>NOTE for eric5 variant</h4> |
6 <h4>NOTE for eric5 variant</h4> |
7 |
7 |
8 This version is a re-implementation of rlcompleter |
8 This version is a re-implementation of rlcompleter |
9 as found in the Python3 library. It is modified to work with the eric5 |
9 as found in the Python3 library. It is modified to work with the eric5 |
10 debug clients. |
10 debug clients. |
11 |
11 |
12 <h4>Original rlcompleter documentation</h4> |
12 <h4>Original rlcompleter documentation</h4> |
13 |
13 |
14 This requires the latest extension to the readline module. The completer |
14 This requires the latest extension to the readline module. The completer |
51 import builtins |
51 import builtins |
52 import __main__ |
52 import __main__ |
53 |
53 |
54 __all__ = ["Completer"] |
54 __all__ = ["Completer"] |
55 |
55 |
|
56 |
56 class Completer(object): |
57 class Completer(object): |
57 """ |
58 """ |
58 Class implementing the command line completer object. |
59 Class implementing the command line completer object. |
59 """ |
60 """ |
60 def __init__(self, namespace = None): |
61 def __init__(self, namespace=None): |
61 """ |
62 """ |
62 Create a new completer for the command line. |
63 Create a new completer for the command line. |
63 |
64 |
64 Completer([namespace]) -> completer instance. |
65 Completer([namespace]) -> completer instance. |
65 |
66 |
174 # get the content of the object, except __builtins__ |
175 # get the content of the object, except __builtins__ |
175 words = dir(thisobject) |
176 words = dir(thisobject) |
176 if "__builtins__" in words: |
177 if "__builtins__" in words: |
177 words.remove("__builtins__") |
178 words.remove("__builtins__") |
178 |
179 |
179 if hasattr(object,'__class__'): |
180 if hasattr(object, '__class__'): |
180 words.append('__class__') |
181 words.append('__class__') |
181 words = words + get_class_members(object.__class__) |
182 words = words + get_class_members(object.__class__) |
182 matches = [] |
183 matches = [] |
183 n = len(attr) |
184 n = len(attr) |
184 for word in words: |
185 for word in words: |
192 # which cause the completion to fail. This way we skip the |
193 # which cause the completion to fail. This way we skip the |
193 # bad entries and can still continue processing the others. |
194 # bad entries and can still continue processing the others. |
194 pass |
195 pass |
195 return matches |
196 return matches |
196 |
197 |
|
198 |
197 def get_class_members(klass): |
199 def get_class_members(klass): |
198 """ |
200 """ |
199 Module function to retrieve the class members. |
201 Module function to retrieve the class members. |
200 |
202 |
201 @param klass The class object to be analysed. |
203 @param klass The class object to be analysed. |