mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Richard Wolff's changes:
cmd.py has incorporated the changes we discussed a couple of weeks ago (a command queue, returning line from precmd, and stop from postcmd) and some changes to help that were occasioned because I wanted to inherit from pdb which inherits from cmd.py and the help routine didn't look for commands or the associated help deeply enough.
This commit is contained in:
parent
b7833d3c0c
commit
5fca6fd2d9
1 changed files with 16 additions and 1 deletions
17
Lib/cmd.py
17
Lib/cmd.py
|
@ -131,15 +131,30 @@ class Cmd:
|
||||||
return
|
return
|
||||||
func()
|
func()
|
||||||
else:
|
else:
|
||||||
names = dir(self.__class__)
|
# Inheritance says we have to look in class and
|
||||||
|
# base classes; order is not important.
|
||||||
|
names = []
|
||||||
|
classes = [self.__class__]
|
||||||
|
while classes:
|
||||||
|
aclass = classes[0]
|
||||||
|
if aclass.__bases__:
|
||||||
|
classes = classes + list(aclass.__bases__)
|
||||||
|
names = names + dir(aclass)
|
||||||
|
del classes[0]
|
||||||
cmds_doc = []
|
cmds_doc = []
|
||||||
cmds_undoc = []
|
cmds_undoc = []
|
||||||
help = {}
|
help = {}
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[:5] == 'help_':
|
if name[:5] == 'help_':
|
||||||
help[name[5:]]=1
|
help[name[5:]]=1
|
||||||
|
names.sort()
|
||||||
|
# There can be duplicates if routines overridden
|
||||||
|
prevname = ''
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[:3] == 'do_':
|
if name[:3] == 'do_':
|
||||||
|
if name == prevname:
|
||||||
|
continue
|
||||||
|
prevname = name
|
||||||
cmd=name[3:]
|
cmd=name[3:]
|
||||||
if help.has_key(cmd):
|
if help.has_key(cmd):
|
||||||
cmds_doc.append(cmd)
|
cmds_doc.append(cmd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue