Lines Matching refs:self

32 The data member `self.ruler' sets the character used to draw separator lines
35 If the value of `self.intro' is nonempty when the cmdloop method is called,
39 The data members `self.doc_header', `self.misc_header', and
40 `self.undoc_header' set the headers used for the help function's
76 def __init__(self, completekey='tab', stdin=None, stdout=None):
88 self.stdin = stdin
90 self.stdin = sys.stdin
92 self.stdout = stdout
94 self.stdout = sys.stdout
95 self.cmdqueue = []
96 self.completekey = completekey
98 def cmdloop(self, intro=None):
105 self.preloop()
106 if self.use_rawinput and self.completekey:
109 self.old_completer = readline.get_completer()
110 readline.set_completer(self.complete)
111 readline.parse_and_bind(self.completekey+": complete")
116 self.intro = intro
117 if self.intro:
118 self.stdout.write(str(self.intro)+"\n")
121 if self.cmdqueue:
122 line = self.cmdqueue.pop(0)
124 if self.use_rawinput:
126 line = input(self.prompt)
130 self.stdout.write(self.prompt)
131 self.stdout.flush()
132 line = self.stdin.readline()
137 line = self.precmd(line)
138 stop = self.onecmd(line)
139 stop = self.postcmd(stop, line)
140 self.postloop()
142 if self.use_rawinput and self.completekey:
145 readline.set_completer(self.old_completer)
150 def precmd(self, line):
157 def postcmd(self, stop, line):
161 def preloop(self):
165 def postloop(self):
172 def parseline(self, line):
183 if hasattr(self, 'do_shell'):
188 while i < n and line[i] in self.identchars: i = i+1
192 def onecmd(self, line):
202 cmd, arg, line = self.parseline(line)
204 return self.emptyline()
206 return self.default(line)
207 self.lastcmd = line
209 self.lastcmd = ''
211 return self.default(line)
214 func = getattr(self, 'do_' + cmd)
216 return self.default(line)
219 def emptyline(self):
226 if self.lastcmd:
227 return self.onecmd(self.lastcmd)
229 def default(self, line):
236 self.stdout.write('*** Unknown syntax: %s\n'%line)
238 def completedefault(self, *ignored):
247 def completenames(self, text, *ignored):
249 return [a[3:] for a in self.get_names() if a.startswith(dotext)]
251 def complete(self, text, state):
265 cmd, args, foo = self.parseline(line)
267 compfunc = self.completedefault
270 compfunc = getattr(self, 'complete_' + cmd)
272 compfunc = self.completedefault
274 compfunc = self.completenames
275 self.completion_matches = compfunc(text, line, begidx, endidx)
277 return self.completion_matches[state]
281 def get_names(self):
284 return dir(self.__class__)
286 def complete_help(self, *args):
287 commands = set(self.completenames(*args))
288 topics = set(a[5:] for a in self.get_names()
292 def do_help(self, arg):
297 func = getattr(self, 'help_' + arg)
300 doc=getattr(self, 'do_' + arg).__doc__
302 self.stdout.write("%s\n"%str(doc))
306 self.stdout.write("%s\n"%str(self.nohelp % (arg,)))
310 names = self.get_names()
329 elif getattr(self, name).__doc__:
333 self.stdout.write("%s\n"%str(self.doc_leader))
334 self.print_topics(self.doc_header, cmds_doc, 15,80)
335 self.print_topics(self.misc_header, sorted(topics),15,80)
336 self.print_topics(self.undoc_header, cmds_undoc, 15,80)
338 def print_topics(self, header, cmds, cmdlen, maxcol):
340 self.stdout.write("%s\n"%str(header))
341 if self.ruler:
342 self.stdout.write("%s\n"%str(self.ruler * len(header)))
343 self.columnize(cmds, maxcol-1)
344 self.stdout.write("\n")
346 def columnize(self, list, displaywidth=80):
353 self.stdout.write("<empty>\n")
363 self.stdout.write('%s\n'%str(list[0]))
401 self.stdout.write("%s\n"%str(" ".join(texts)))