Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fca6fd

Browse files
committed
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.
1 parent b7833d3 commit 5fca6fd

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Lib/cmd.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,30 @@ def do_help(self, arg):
131131
return
132132
func()
133133
else:
134-
names = dir(self.__class__)
134+
# Inheritance says we have to look in class and
135+
# base classes; order is not important.
136+
names = []
137+
classes = [self.__class__]
138+
while classes:
139+
aclass = classes[0]
140+
if aclass.__bases__:
141+
classes = classes + list(aclass.__bases__)
142+
names = names + dir(aclass)
143+
del classes[0]
135144
cmds_doc = []
136145
cmds_undoc = []
137146
help = {}
138147
for name in names:
139148
if name[:5] == 'help_':
140149
help[name[5:]]=1
150+
names.sort()
151+
# There can be duplicates if routines overridden
152+
prevname = ''
141153
for name in names:
142154
if name[:3] == 'do_':
155+
if name == prevname:
156+
continue
157+
prevname = name
143158
cmd=name[3:]
144159
if help.has_key(cmd):
145160
cmds_doc.append(cmd)

0 commit comments

Comments
 (0)