summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheryl Sabella <cheryl.sabella@gmail.com>2017-09-23 20:46:01 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2017-09-23 20:46:01 (GMT)
commitcd99e79dc74c9d9dea83a5551d657c334b2cc6c9 (patch)
tree23aa523413523630c5676cf732476dc7e8dd47fd
parent99167f85b7373c8082b30a74211f009627bdedfa (diff)
downloadcpython-cd99e79dc74c9d9dea83a5551d657c334b2cc6c9.zip
cpython-cd99e79dc74c9d9dea83a5551d657c334b2cc6c9.tar.gz
cpython-cd99e79dc74c9d9dea83a5551d657c334b2cc6c9.tar.bz2
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.
-rw-r--r--Lib/idlelib/browser.py14
-rw-r--r--Lib/idlelib/editor.py10
-rw-r--r--Lib/idlelib/idle_test/htest.py2
-rw-r--r--Lib/idlelib/idle_test/test_browser.py42
-rw-r--r--Lib/idlelib/mainmenu.py2
-rw-r--r--Lib/idlelib/pathbrowser.py4
-rw-r--r--Misc/NEWS.d/next/IDLE/2017-09-22-20-26-23.bpo-31459.L0pnH9.rst7
7 files changed, 44 insertions, 37 deletions
diff --git a/Lib/idlelib/browser.py b/Lib/idlelib/browser.py
index 1fc04d8..603d299 100644
--- a/Lib/idlelib/browser.py
+++ b/Lib/idlelib/browser.py
@@ -1,4 +1,4 @@
-"""Class browser.
+"""Module browser.
XXX TO DO:
@@ -55,7 +55,7 @@ def transform_children(child_dict, modname=None):
return sorted(obs, key=lambda o: o.lineno)
-class ClassBrowser:
+class ModuleBrowser:
"""Browse module classes and functions in IDLE.
"""
# This class is the base class for pathbrowser.PathBrowser.
@@ -122,8 +122,8 @@ class ClassBrowser:
def settitle(self):
"Set the window title."
- self.top.wm_title("Class Browser - " + self.name)
- self.top.wm_iconname("Class Browser")
+ self.top.wm_title("Module Browser - " + self.name)
+ self.top.wm_iconname("Module Browser")
def rootnode(self):
"Return a ModuleBrowserTreeItem as the root of the tree."
@@ -226,7 +226,7 @@ class ChildBrowserTreeItem(TreeItem):
pass
-def _class_browser(parent): # htest #
+def _module_browser(parent): # htest #
try:
file = sys.argv[1] # If pass file on command line
# If this succeeds, unittest will fail.
@@ -242,10 +242,10 @@ def _class_browser(parent): # htest #
flist = pyshell.PyShellFileList(parent)
global file_open
file_open = flist.open
- ClassBrowser(flist, name, [dir], _htest=True)
+ ModuleBrowser(flist, name, [dir], _htest=True)
if __name__ == "__main__":
from unittest import main
main('idlelib.idle_test.test_browser', verbosity=2, exit=False)
from idlelib.idle_test.htest import run
- run(_class_browser)
+ run(_module_browser)
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 855d375..5b16cce 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -190,7 +190,7 @@ class EditorWindow(object):
flist.dict[key] = self
text.bind("<<open-new-window>>", self.new_callback)
text.bind("<<close-all-windows>>", self.flist.close_all_callback)
- text.bind("<<open-class-browser>>", self.open_class_browser)
+ text.bind("<<open-class-browser>>", self.open_module_browser)
text.bind("<<open-path-browser>>", self.open_path_browser)
text.bind("<<open-turtle-demo>>", self.open_turtle_demo)
@@ -632,10 +632,10 @@ class EditorWindow(object):
def open_module(self):
"""Get module name from user and open it.
- Return module path or None for calls by open_class_browser
+ Return module path or None for calls by open_module_browser
when latter is not invoked in named editor window.
"""
- # XXX This, open_class_browser, and open_path_browser
+ # XXX This, open_module_browser, and open_path_browser
# would fit better in iomenu.IOBinding.
try:
name = self.text.get("sel.first", "sel.last").strip()
@@ -657,7 +657,7 @@ class EditorWindow(object):
self.open_module()
return "break"
- def open_class_browser(self, event=None):
+ def open_module_browser(self, event=None):
filename = self.io.filename
if not (self.__class__.__name__ == 'PyShellEditorWindow'
and filename):
@@ -667,7 +667,7 @@ class EditorWindow(object):
head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail)
from idlelib import browser
- browser.ClassBrowser(self.flist, base, [head])
+ browser.ModuleBrowser(self.flist, base, [head])
return "break"
def open_path_browser(self, event=None):
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index e483bbc..442f55e 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -86,7 +86,7 @@ _calltip_window_spec = {
"Typing ') should hide the calltip.\n"
}
-_class_browser_spec = {
+_module_browser_spec = {
'file': 'browser',
'kwds': {},
'msg': "Inspect names of module, class(with superclass if "
diff --git a/Lib/idlelib/idle_test/test_browser.py b/Lib/idlelib/idle_test/test_browser.py
index 3b1ece9..a4add89 100644
--- a/Lib/idlelib/idle_test/test_browser.py
+++ b/Lib/idlelib/idle_test/test_browser.py
@@ -17,7 +17,7 @@ from idlelib.idle_test.mock_idle import Func
from collections import deque
-class ClassBrowserTest(unittest.TestCase):
+class ModuleBrowserTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
@@ -28,41 +28,41 @@ class ClassBrowserTest(unittest.TestCase):
cls.file = __file__
cls.path = os.path.dirname(cls.file)
cls.module = os.path.basename(cls.file).rstrip('.py')
- cls.cb = browser.ClassBrowser(cls.flist, cls.module, [cls.path], _utest=True)
+ cls.mb = browser.ModuleBrowser(cls.flist, cls.module, [cls.path], _utest=True)
@classmethod
def tearDownClass(cls):
- cls.cb.close()
+ cls.mb.close()
cls.root.destroy()
- del cls.root, cls.flist, cls.cb
+ del cls.root, cls.flist, cls.mb
def test_init(self):
- cb = self.cb
+ mb = self.mb
eq = self.assertEqual
- eq(cb.name, self.module)
- eq(cb.file, self.file)
- eq(cb.flist, self.flist)
+ eq(mb.name, self.module)
+ eq(mb.file, self.file)
+ eq(mb.flist, self.flist)
eq(pyclbr._modules, {})
- self.assertIsInstance(cb.node, TreeNode)
+ self.assertIsInstance(mb.node, TreeNode)
def test_settitle(self):
- cb = self.cb
- self.assertIn(self.module, cb.top.title())
- self.assertEqual(cb.top.iconname(), 'Class Browser')
+ mb = self.mb
+ self.assertIn(self.module, mb.top.title())
+ self.assertEqual(mb.top.iconname(), 'Module Browser')
def test_rootnode(self):
- cb = self.cb
- rn = cb.rootnode()
+ mb = self.mb
+ rn = mb.rootnode()
self.assertIsInstance(rn, browser.ModuleBrowserTreeItem)
def test_close(self):
- cb = self.cb
- cb.top.destroy = Func()
- cb.node.destroy = Func()
- cb.close()
- self.assertTrue(cb.top.destroy.called)
- self.assertTrue(cb.node.destroy.called)
- del cb.top.destroy, cb.node.destroy
+ mb = self.mb
+ mb.top.destroy = Func()
+ mb.node.destroy = Func()
+ mb.close()
+ self.assertTrue(mb.top.destroy.called)
+ self.assertTrue(mb.node.destroy.called)
+ del mb.top.destroy, mb.node.destroy
# Nested tree same as in test_pyclbr.py except for supers on C0. C1.
diff --git a/Lib/idlelib/mainmenu.py b/Lib/idlelib/mainmenu.py
index d1dcb83..143570d 100644
--- a/Lib/idlelib/mainmenu.py
+++ b/Lib/idlelib/mainmenu.py
@@ -25,7 +25,7 @@ menudefs = [
('_New File', '<<open-new-window>>'),
('_Open...', '<<open-window-from-file>>'),
('Open _Module...', '<<open-module>>'),
- ('Class _Browser', '<<open-class-browser>>'),
+ ('Module _Browser', '<<open-class-browser>>'),
('_Path Browser', '<<open-path-browser>>'),
None,
('_Save', '<<save-window>>'),
diff --git a/Lib/idlelib/pathbrowser.py b/Lib/idlelib/pathbrowser.py
index 598dff8..b0c8c6d 100644
--- a/Lib/idlelib/pathbrowser.py
+++ b/Lib/idlelib/pathbrowser.py
@@ -2,12 +2,12 @@ import importlib.machinery
import os
import sys
-from idlelib.browser import ClassBrowser, ModuleBrowserTreeItem
+from idlelib.browser import ModuleBrowser, ModuleBrowserTreeItem
from idlelib.pyshell import PyShellFileList
from idlelib.tree import TreeItem
-class PathBrowser(ClassBrowser):
+class PathBrowser(ModuleBrowser):
def __init__(self, flist, _htest=False, _utest=False):
"""
diff --git a/Misc/NEWS.d/next/IDLE/2017-09-22-20-26-23.bpo-31459.L0pnH9.rst b/Misc/NEWS.d/next/IDLE/2017-09-22-20-26-23.bpo-31459.L0pnH9.rst
new file mode 100644
index 0000000..b53c009
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2017-09-22-20-26-23.bpo-31459.L0pnH9.rst
@@ -0,0 +1,7 @@
+Rename IDLE's module browser from Class Browser to Module Browser.
+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.