summaryrefslogtreecommitdiff
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-03-26 21:13:24 +0000
committerGuido van Rossum <guido@python.org>1998-03-26 21:13:24 +0000
commitc84c48dc17375c3a21a86464dc653fbff8844f38 (patch)
tree2524876ba2b0dc52336f25509785c0f3893ad3ad /Lib/rlcompleter.py
parentaf0fd2cd94b3551b98e08c998e6b3253a7c3f01f (diff)
downloadcpython-c84c48dc17375c3a21a86464dc653fbff8844f38.tar.gz
Mass check-in after untabifying all files that need it.
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py98
1 files changed, 49 insertions, 49 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 4deb0bceb4..e0ae72c9ac 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -47,60 +47,60 @@ import __main__
class Completer:
def complete(self, text, state):
- """Return the next possible completion for 'text'.
+ """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'.
+ This is called successively with state == 0, 1, 2, ... until it
+ returns None. The completion should begin with 'text'.
- """
- if state == 0:
- if "." in text:
- self.matches = self.attr_matches(text)
- else:
- self.matches = self.global_matches(text)
- return self.matches[state]
+ """
+ if state == 0:
+ if "." in text:
+ self.matches = self.attr_matches(text)
+ else:
+ self.matches = self.global_matches(text)
+ return self.matches[state]
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.
-
- """
- import keyword
- matches = []
- n = len(text)
- for list in [keyword.kwlist,
- __builtin__.__dict__.keys(),
- __main__.__dict__.keys()]:
- for word in list:
- if word[:n] == text:
- matches.append(word)
- return matches
+ """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.
+
+ """
+ import keyword
+ matches = []
+ n = len(text)
+ for list in [keyword.kwlist,
+ __builtin__.__dict__.keys(),
+ __main__.__dict__.keys()]:
+ for word in list:
+ if word[:n] == text:
+ matches.append(word)
+ return matches
def attr_matches(self, text):
- """Compute matches when text contains a dot.
-
- Assuming the text is of the form NAME.NAME....[NAME], and is
- evaluabable in the globals of __main__, it will be evaluated
- and its attributes (as revealed by dir()) are used as possible
- completions.
-
- WARNING: this can still invoke arbitrary C code, if an object
- with a __getattr__ hook is evaluated.
-
- """
- import re
- m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
- if not m:
- return
- expr, attr = m.group(1, 3)
- words = dir(eval(expr, __main__.__dict__))
- matches = []
- n = len(attr)
- for word in words:
- if word[:n] == attr:
- matches.append("%s.%s" % (expr, word))
- return matches
+ """Compute matches when text contains a dot.
+
+ Assuming the text is of the form NAME.NAME....[NAME], and is
+ evaluabable in the globals of __main__, it will be evaluated
+ and its attributes (as revealed by dir()) are used as possible
+ completions.
+
+ WARNING: this can still invoke arbitrary C code, if an object
+ with a __getattr__ hook is evaluated.
+
+ """
+ import re
+ m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
+ if not m:
+ return
+ expr, attr = m.group(1, 3)
+ words = dir(eval(expr, __main__.__dict__))
+ matches = []
+ n = len(attr)
+ for word in words:
+ if word[:n] == attr:
+ matches.append("%s.%s" % (expr, word))
+ return matches
readline.set_completer(Completer().complete)