Skip to content

Commit cd99e79

Browse files
csabellaterryjreedy
authored andcommitted
bpo-31459: Rename IDLE's module browser from Class Browser to Module Browser. (#3704)
The original module-level class and method browser became a module browser, with the addition of module-level functions, years ago. Nested classes and functions were added yesterday. For back- compatibility, the virtual event <<open-class-browser>>, which appears on the Keys tab of the Settings dialog, is not changed. Patch by Cheryl Sabella.
1 parent 99167f8 commit cd99e79

File tree

7 files changed

+44
-37
lines changed

7 files changed

+44
-37
lines changed

‎Lib/idlelib/browser.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Class browser.
1+
"""Module browser.
22
33
XXX TO DO:
44
@@ -55,7 +55,7 @@ def transform_children(child_dict, modname=None):
5555
return sorted(obs, key=lambda o: o.lineno)
5656

5757

58-
class ClassBrowser:
58+
class ModuleBrowser:
5959
"""Browse module classes and functions in IDLE.
6060
"""
6161
# This class is the base class for pathbrowser.PathBrowser.
@@ -122,8 +122,8 @@ def init(self, flist):
122122

123123
def settitle(self):
124124
"Set the window title."
125-
self.top.wm_title("Class Browser - " + self.name)
126-
self.top.wm_iconname("Class Browser")
125+
self.top.wm_title("Module Browser - " + self.name)
126+
self.top.wm_iconname("Module Browser")
127127

128128
def rootnode(self):
129129
"Return a ModuleBrowserTreeItem as the root of the tree."
@@ -226,7 +226,7 @@ def OnDoubleClick(self):
226226
pass
227227

228228

229-
def _class_browser(parent): # htest #
229+
def _module_browser(parent): # htest #
230230
try:
231231
file = sys.argv[1] # If pass file on command line
232232
# If this succeeds, unittest will fail.
@@ -242,10 +242,10 @@ class Nested_in_closure: pass
242242
flist = pyshell.PyShellFileList(parent)
243243
global file_open
244244
file_open = flist.open
245-
ClassBrowser(flist, name, [dir], _htest=True)
245+
ModuleBrowser(flist, name, [dir], _htest=True)
246246

247247
if __name__ == "__main__":
248248
from unittest import main
249249
main('idlelib.idle_test.test_browser', verbosity=2, exit=False)
250250
from idlelib.idle_test.htest import run
251-
run(_class_browser)
251+
run(_module_browser)

‎Lib/idlelib/editor.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
190190
flist.dict[key] = self
191191
text.bind("<<open-new-window>>", self.new_callback)
192192
text.bind("<<close-all-windows>>", self.flist.close_all_callback)
193-
text.bind("<<open-class-browser>>", self.open_class_browser)
193+
text.bind("<<open-class-browser>>", self.open_module_browser)
194194
text.bind("<<open-path-browser>>", self.open_path_browser)
195195
text.bind("<<open-turtle-demo>>", self.open_turtle_demo)
196196

@@ -632,10 +632,10 @@ def goto_line_event(self, event):
632632
def open_module(self):
633633
"""Get module name from user and open it.
634634
635-
Return module path or None for calls by open_class_browser
635+
Return module path or None for calls by open_module_browser
636636
when latter is not invoked in named editor window.
637637
"""
638-
# XXX This, open_class_browser, and open_path_browser
638+
# XXX This, open_module_browser, and open_path_browser
639639
# would fit better in iomenu.IOBinding.
640640
try:
641641
name = self.text.get("sel.first", "sel.last").strip()
@@ -657,7 +657,7 @@ def open_module_event(self, event):
657657
self.open_module()
658658
return "break"
659659

660-
def open_class_browser(self, event=None):
660+
def open_module_browser(self, event=None):
661661
filename = self.io.filename
662662
if not (self.__class__.__name__ == 'PyShellEditorWindow'
663663
and filename):
@@ -667,7 +667,7 @@ def open_class_browser(self, event=None):
667667
head, tail = os.path.split(filename)
668668
base, ext = os.path.splitext(tail)
669669
from idlelib import browser
670-
browser.ClassBrowser(self.flist, base, [head])
670+
browser.ModuleBrowser(self.flist, base, [head])
671671
return "break"
672672

673673
def open_path_browser(self, event=None):

‎Lib/idlelib/idle_test/htest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _wrapper(parent): # htest #
8686
"Typing ') should hide the calltip.\n"
8787
}
8888

89-
_class_browser_spec = {
89+
_module_browser_spec = {
9090
'file': 'browser',
9191
'kwds': {},
9292
'msg': "Inspect names of module, class(with superclass if "

‎Lib/idlelib/idle_test/test_browser.py‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from collections import deque
1818

1919

20-
class ClassBrowserTest(unittest.TestCase):
20+
class ModuleBrowserTest(unittest.TestCase):
2121

2222
@classmethod
2323
def setUpClass(cls):
@@ -28,41 +28,41 @@ def setUpClass(cls):
2828
cls.file = __file__
2929
cls.path = os.path.dirname(cls.file)
3030
cls.module = os.path.basename(cls.file).rstrip('.py')
31-
cls.cb = browser.ClassBrowser(cls.flist, cls.module, [cls.path], _utest=True)
31+
cls.mb = browser.ModuleBrowser(cls.flist, cls.module, [cls.path], _utest=True)
3232

3333
@classmethod
3434
def tearDownClass(cls):
35-
cls.cb.close()
35+
cls.mb.close()
3636
cls.root.destroy()
37-
del cls.root, cls.flist, cls.cb
37+
del cls.root, cls.flist, cls.mb
3838

3939
def test_init(self):
40-
cb = self.cb
40+
mb = self.mb
4141
eq = self.assertEqual
42-
eq(cb.name, self.module)
43-
eq(cb.file, self.file)
44-
eq(cb.flist, self.flist)
42+
eq(mb.name, self.module)
43+
eq(mb.file, self.file)
44+
eq(mb.flist, self.flist)
4545
eq(pyclbr._modules, {})
46-
self.assertIsInstance(cb.node, TreeNode)
46+
self.assertIsInstance(mb.node, TreeNode)
4747

4848
def test_settitle(self):
49-
cb = self.cb
50-
self.assertIn(self.module, cb.top.title())
51-
self.assertEqual(cb.top.iconname(), 'Class Browser')
49+
mb = self.mb
50+
self.assertIn(self.module, mb.top.title())
51+
self.assertEqual(mb.top.iconname(), 'Module Browser')
5252

5353
def test_rootnode(self):
54-
cb = self.cb
55-
rn = cb.rootnode()
54+
mb = self.mb
55+
rn = mb.rootnode()
5656
self.assertIsInstance(rn, browser.ModuleBrowserTreeItem)
5757

5858
def test_close(self):
59-
cb = self.cb
60-
cb.top.destroy = Func()
61-
cb.node.destroy = Func()
62-
cb.close()
63-
self.assertTrue(cb.top.destroy.called)
64-
self.assertTrue(cb.node.destroy.called)
65-
del cb.top.destroy, cb.node.destroy
59+
mb = self.mb
60+
mb.top.destroy = Func()
61+
mb.node.destroy = Func()
62+
mb.close()
63+
self.assertTrue(mb.top.destroy.called)
64+
self.assertTrue(mb.node.destroy.called)
65+
del mb.top.destroy, mb.node.destroy
6666

6767

6868
# Nested tree same as in test_pyclbr.py except for supers on C0. C1.

‎Lib/idlelib/mainmenu.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
('_New File', '<<open-new-window>>'),
2626
('_Open...', '<<open-window-from-file>>'),
2727
('Open _Module...', '<<open-module>>'),
28-
('Class _Browser', '<<open-class-browser>>'),
28+
('Module _Browser', '<<open-class-browser>>'),
2929
('_Path Browser', '<<open-path-browser>>'),
3030
None,
3131
('_Save', '<<save-window>>'),

‎Lib/idlelib/pathbrowser.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import os
33
import sys
44

5-
from idlelib.browser import ClassBrowser, ModuleBrowserTreeItem
5+
from idlelib.browser import ModuleBrowser, ModuleBrowserTreeItem
66
from idlelib.pyshell import PyShellFileList
77
from idlelib.tree import TreeItem
88

99

10-
class PathBrowser(ClassBrowser):
10+
class PathBrowser(ModuleBrowser):
1111

1212
def __init__(self, flist, _htest=False, _utest=False):
1313
"""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Rename IDLE's module browser from Class Browser to Module Browser.
2+
The original module-level class and method browser became a module
3+
browser, with the addition of module-level functions, years ago.
4+
Nested classes and functions were added yesterday. For back-
5+
compatibility, the virtual event <<open-class-browser>>, which
6+
appears on the Keys tab of the Settings dialog, is not changed.
7+
Patch by Cheryl Sabella.

0 commit comments

Comments
 (0)