From cd99e79dc74c9d9dea83a5551d657c334b2cc6c9 Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Sat, 23 Sep 2017 16:46:01 -0400 Subject: [PATCH] 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 <>, which appears on the Keys tab of the Settings dialog, is not changed. Patch by Cheryl Sabella. --- Lib/idlelib/browser.py | 14 +++---- Lib/idlelib/editor.py | 10 ++--- Lib/idlelib/idle_test/htest.py | 2 +- Lib/idlelib/idle_test/test_browser.py | 42 +++++++++---------- Lib/idlelib/mainmenu.py | 2 +- Lib/idlelib/pathbrowser.py | 4 +- .../2017-09-22-20-26-23.bpo-31459.L0pnH9.rst | 7 ++++ 7 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2017-09-22-20-26-23.bpo-31459.L0pnH9.rst diff --git a/Lib/idlelib/browser.py b/Lib/idlelib/browser.py index 1fc04d873a8..603d299518d 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 855d3750556..5b16ccee8a6 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -190,7 +190,7 @@ class EditorWindow(object): flist.dict[key] = self text.bind("<>", self.new_callback) text.bind("<>", self.flist.close_all_callback) - text.bind("<>", self.open_class_browser) + text.bind("<>", self.open_module_browser) text.bind("<>", self.open_path_browser) text.bind("<>", 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 e483bbc93a2..442f55e283a 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 3b1ece99528..a4add89b93b 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 d1dcb83d932..143570d6b11 100644 --- a/Lib/idlelib/mainmenu.py +++ b/Lib/idlelib/mainmenu.py @@ -25,7 +25,7 @@ menudefs = [ ('_New File', '<>'), ('_Open...', '<>'), ('Open _Module...', '<>'), - ('Class _Browser', '<>'), + ('Module _Browser', '<>'), ('_Path Browser', '<>'), None, ('_Save', '<>'), diff --git a/Lib/idlelib/pathbrowser.py b/Lib/idlelib/pathbrowser.py index 598dff8d56b..b0c8c6d3055 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 00000000000..b53c009dfcd --- /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 <>, which +appears on the Keys tab of the Settings dialog, is not changed. +Patch by Cheryl Sabella.