diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py index d55b799256a..fa1733f9a6e 100644 --- a/Lib/idlelib/AutoComplete.py +++ b/Lib/idlelib/AutoComplete.py @@ -7,12 +7,7 @@ import os import sys import string -from configHandler import idleConf - -import AutoCompleteWindow -from HyperParser import HyperParser - -import __main__ +from idlelib.configHandler import idleConf # This string includes all chars that may be in a file name (without a path # separator) @@ -23,6 +18,11 @@ ID_CHARS = string.ascii_letters + string.digits + "_" # These constants represent the two different types of completions COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1) +from idlelib import AutoCompleteWindow +from idlelib.HyperParser import HyperParser + +import __main__ + SEPS = os.sep if os.altsep: # e.g. '/' on Windows... SEPS += os.altsep @@ -193,7 +193,7 @@ class AutoComplete: smalll = eval("__all__", namespace) smalll.sort() else: - smalll = filter(lambda s: s[:1] != '_', bigl) + smalll = [s for s in bigl if s[:1] != '_'] else: try: entity = self.get_entity(what) @@ -203,7 +203,7 @@ class AutoComplete: smalll = entity.__all__ smalll.sort() else: - smalll = filter(lambda s: s[:1] != '_', bigl) + smalll = [s for s in bigl if s[:1] != '_'] except: return [], [] @@ -214,7 +214,7 @@ class AutoComplete: expandedpath = os.path.expanduser(what) bigl = os.listdir(expandedpath) bigl.sort() - smalll = filter(lambda s: s[:1] != '.', bigl) + smalll = [s for s in bigl if s[:1] != '.'] except OSError: return [], [] diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/AutoCompleteWindow.py index 81eeec1bf0c..298177fc847 100644 --- a/Lib/idlelib/AutoCompleteWindow.py +++ b/Lib/idlelib/AutoCompleteWindow.py @@ -2,8 +2,8 @@ An auto-completion window for IDLE, used by the AutoComplete extension """ from Tkinter import * -from MultiCall import MC_SHIFT -import AutoComplete +from idlelib.MultiCall import MC_SHIFT +from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES HIDE_VIRTUAL_EVENT_NAME = "<>" HIDE_SEQUENCES = ("", "") @@ -264,7 +264,7 @@ class AutoCompleteWindow: if keysym != "Tab": self.lastkey_was_tab = False if (len(keysym) == 1 or keysym in ("underscore", "BackSpace") - or (self.mode==AutoComplete.COMPLETE_FILES and keysym in + or (self.mode == COMPLETE_FILES and keysym in ("period", "minus"))) \ and not (state & ~MC_SHIFT): # Normal editing of text @@ -292,10 +292,10 @@ class AutoCompleteWindow: self.hide_window() return - elif (self.mode == AutoComplete.COMPLETE_ATTRIBUTES and keysym in + elif (self.mode == COMPLETE_ATTRIBUTES and keysym in ("period", "space", "parenleft", "parenright", "bracketleft", "bracketright")) or \ - (self.mode == AutoComplete.COMPLETE_FILES and keysym in + (self.mode == COMPLETE_FILES and keysym in ("slash", "backslash", "quotedbl", "apostrophe")) \ and not (state & ~MC_SHIFT): # If start is a prefix of the selection, but is not '' when @@ -303,7 +303,7 @@ class AutoCompleteWindow: # selected completion. Anyway, close the list. cursel = int(self.listbox.curselection()[0]) if self.completions[cursel][:len(self.start)] == self.start \ - and (self.mode==AutoComplete.COMPLETE_ATTRIBUTES or self.start): + and (self.mode == COMPLETE_ATTRIBUTES or self.start): self._change_start(self.completions[cursel]) self.hide_window() return diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/Bindings.py index 1853ff93df3..74a93d3b141 100644 --- a/Lib/idlelib/Bindings.py +++ b/Lib/idlelib/Bindings.py @@ -9,8 +9,8 @@ windows. """ import sys -from configHandler import idleConf -import macosxSupport +from idlelib.configHandler import idleConf +from idlelib import macosxSupport menudefs = [ # underscore prefixes character to underscore diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py index bd51b7f6a55..f8f31e2fcb4 100644 --- a/Lib/idlelib/CallTips.py +++ b/Lib/idlelib/CallTips.py @@ -9,8 +9,8 @@ import re import sys import types -import CallTipWindow -from HyperParser import HyperParser +from idlelib import CallTipWindow +from idlelib.HyperParser import HyperParser import __main__ diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/ClassBrowser.py index e5a60a51341..095b30dad8f 100644 --- a/Lib/idlelib/ClassBrowser.py +++ b/Lib/idlelib/ClassBrowser.py @@ -14,10 +14,10 @@ import os import sys import pyclbr -import PyShell -from WindowList import ListedToplevel -from TreeWidget import TreeNode, TreeItem, ScrolledCanvas -from configHandler import idleConf +from idlelib import PyShell +from idlelib.WindowList import ListedToplevel +from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas +from idlelib.configHandler import idleConf class ClassBrowser: diff --git a/Lib/idlelib/CodeContext.py b/Lib/idlelib/CodeContext.py index 420ec339ca2..2f6f737b670 100644 --- a/Lib/idlelib/CodeContext.py +++ b/Lib/idlelib/CodeContext.py @@ -11,9 +11,9 @@ not open blocks are not shown in the context hints pane. """ import Tkinter from Tkconstants import TOP, LEFT, X, W, SUNKEN -from configHandler import idleConf import re from sys import maxint as INFINITY +from idlelib.configHandler import idleConf BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for", "if", "try", "while", "with"]) diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py index e55f9e6b77b..7f4d740ffac 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -3,8 +3,8 @@ import re import keyword import __builtin__ from Tkinter import * -from Delegator import Delegator -from configHandler import idleConf +from idlelib.Delegator import Delegator +from idlelib.configHandler import idleConf DEBUG = False @@ -248,7 +248,7 @@ class ColorDelegator(Delegator): self.tag_remove(tag, "1.0", "end") def main(): - from Percolator import Percolator + from idlelib.Percolator import Percolator root = Tk() root.wm_protocol("WM_DELETE_WINDOW", root.quit) text = Text(background="white") diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py index f56460aad09..04eea3235b6 100644 --- a/Lib/idlelib/Debugger.py +++ b/Lib/idlelib/Debugger.py @@ -2,9 +2,9 @@ import os import bdb import types from Tkinter import * -from WindowList import ListedToplevel -from ScrolledList import ScrolledList -import macosxSupport +from idlelib.WindowList import ListedToplevel +from idlelib.ScrolledList import ScrolledList +from idlelib import macosxSupport class Idb(bdb.Bdb): diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index da051ed6d0b..7cc69cbf004 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -6,18 +6,18 @@ from itertools import count from Tkinter import * import tkSimpleDialog import tkMessageBox -from MultiCall import MultiCallCreator - import webbrowser -import idlever -import WindowList -import SearchDialog -import GrepDialog -import ReplaceDialog -import PyParse -from configHandler import idleConf -import aboutDialog, textView, configDialog -import macosxSupport + +from idlelib.MultiCall import MultiCallCreator +from idlelib import idlever +from idlelib import WindowList +from idlelib import SearchDialog +from idlelib import GrepDialog +from idlelib import ReplaceDialog +from idlelib import PyParse +from idlelib.configHandler import idleConf +from idlelib import aboutDialog, textView, configDialog +from idlelib import macosxSupport # The default tab setting for a Text widget, in average-width characters. TK_TABWIDTH_DEFAULT = 8 @@ -50,13 +50,13 @@ def _find_module(fullname, path=None): return file, filename, descr class EditorWindow(object): - from Percolator import Percolator - from ColorDelegator import ColorDelegator - from UndoDelegator import UndoDelegator - from IOBinding import IOBinding, filesystemencoding, encoding - import Bindings + from idlelib.Percolator import Percolator + from idlelib.ColorDelegator import ColorDelegator + from idlelib.UndoDelegator import UndoDelegator + from idlelib.IOBinding import IOBinding, filesystemencoding, encoding + from idlelib import Bindings from Tkinter import Toplevel - from MultiStatusBar import MultiStatusBar + from idlelib.MultiStatusBar import MultiStatusBar help_url = None @@ -579,11 +579,11 @@ class EditorWindow(object): return None head, tail = os.path.split(filename) base, ext = os.path.splitext(tail) - import ClassBrowser + from idlelib import ClassBrowser ClassBrowser.ClassBrowser(self.flist, base, [head]) def open_path_browser(self, event=None): - import PathBrowser + from idlelib import PathBrowser PathBrowser.PathBrowser(self.flist) def gotoline(self, lineno): @@ -1193,7 +1193,7 @@ class EditorWindow(object): if not self.context_use_ps1: for context in self.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" rawtext = text.get(startatindex, "insert") y.set_str(rawtext) bod = y.find_good_parse_start( diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py index e40c7a7a849..5622805524a 100644 --- a/Lib/idlelib/FileList.py +++ b/Lib/idlelib/FileList.py @@ -5,8 +5,8 @@ import tkMessageBox class FileList: - from EditorWindow import EditorWindow # class variable, may be overridden - # e.g. by PyShellFileList + # N.B. this import overridden in PyShellFileList. + from idlelib.EditorWindow import EditorWindow def __init__(self, root): self.root = root @@ -106,7 +106,7 @@ class FileList: def _test(): - from EditorWindow import fixwordbreaks + from idlelib.EditorWindow import fixwordbreaks import sys root = Tk() fixwordbreaks(root) diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py index f30898e8ffd..02f96d493a3 100644 --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -15,7 +15,7 @@ # * Fancy comments, like this bulleted list, arent handled :-) import re -from configHandler import idleConf +from idlelib.configHandler import idleConf class FormatParagraph: diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py index ab136bc1128..e40e5468c0f 100644 --- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/GrepDialog.py @@ -2,8 +2,8 @@ import os import fnmatch import sys from Tkinter import * -import SearchEngine -from SearchDialogBase import SearchDialogBase +from idlelib import SearchEngine +from idlelib.SearchDialogBase import SearchDialogBase def grep(text, io=None, flist=None): root = text._root() @@ -63,7 +63,7 @@ class GrepDialog(SearchDialogBase): if not path: self.top.bell() return - from OutputWindow import OutputWindow + from idlelib.OutputWindow import OutputWindow save = sys.stdout try: sys.stdout = OutputWindow(self.flist) diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py index 519de74d158..38a19f2189c 100644 --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -10,7 +10,7 @@ structure of code, used by extensions to help the user. import string import keyword -import PyParse +from idlelib import PyParse class HyperParser: @@ -31,7 +31,7 @@ class HyperParser: if not editwin.context_use_ps1: for context in editwin.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" stopatindex = "%d.end" % lno # We add the newline because PyParse requires a newline at end. # We add a space so that index won't be at end of line, so that diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py index 01d278e87cd..cbc1c3343ed 100644 --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -16,7 +16,7 @@ import re from Tkinter import * from SimpleDialog import SimpleDialog -from configHandler import idleConf +from idlelib.configHandler import idleConf try: from codecs import BOM_UTF8 diff --git a/Lib/idlelib/IdleHistory.py b/Lib/idlelib/IdleHistory.py index 960242f7817..983a1406d44 100644 --- a/Lib/idlelib/IdleHistory.py +++ b/Lib/idlelib/IdleHistory.py @@ -1,4 +1,4 @@ -from configHandler import idleConf +from idlelib.configHandler import idleConf class History: diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py index e8a3191f5a2..5b73481535f 100644 --- a/Lib/idlelib/MultiCall.py +++ b/Lib/idlelib/MultiCall.py @@ -33,7 +33,7 @@ import sys import string import re import Tkinter -import macosxSupport +from idlelib import macosxSupport # the event type constants, which define the meaning of mc_type MC_KEYPRESS=0; MC_KEYRELEASE=1; MC_BUTTONPRESS=2; MC_BUTTONRELEASE=3; @@ -111,12 +111,27 @@ _state_names = [''.join(m[0]+'-' for i, m in enumerate(_modifiers) if (1 << i) & s) for s in _states] -_state_subsets = map(lambda i: filter(lambda j: not (j & (~i)), _states), - _states) -for l in _state_subsets: - l.sort(lambda a, b, nummod = lambda x: len(filter(lambda i: (1<> #$ win @@ -336,7 +337,7 @@ class CommandSequence(Command): return self.depth def main(): - from Percolator import Percolator + from idlelib.Percolator import Percolator root = Tk() root.wm_protocol("WM_DELETE_WINDOW", root.quit) text = Text() diff --git a/Lib/idlelib/ZoomHeight.py b/Lib/idlelib/ZoomHeight.py index 83ca3a69709..e8d17107510 100644 --- a/Lib/idlelib/ZoomHeight.py +++ b/Lib/idlelib/ZoomHeight.py @@ -2,7 +2,8 @@ import re import sys -import macosxSupport + +from idlelib import macosxSupport class ZoomHeight: diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py index 008602cd269..43a13135aee 100644 --- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/aboutDialog.py @@ -4,9 +4,9 @@ from Tkinter import * import os -import os.path -import textView -import idlever + +from idlelib import textView +from idlelib import idlever class AboutDialog(Toplevel): """Modal about dialog for idle @@ -144,7 +144,7 @@ if __name__ == '__main__': # test the dialog root = Tk() def run(): - import aboutDialog + from idlelib import aboutDialog aboutDialog.AboutDialog(root, 'About') Button(root, text='Dialog', command=run).pack() root.mainloop() diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index 2f66d09520c..8d3a49dff7e 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -13,13 +13,13 @@ from Tkinter import * import tkMessageBox, tkColorChooser, tkFont import string -from configHandler import idleConf -from dynOptionMenuWidget import DynOptionMenu -from tabbedpages import TabbedPageSet -from keybindingDialog import GetKeysDialog -from configSectionNameDialog import GetCfgSectionNameDialog -from configHelpSourceEdit import GetHelpSourceDialog -import macosxSupport +from idlelib.configHandler import idleConf +from idlelib.dynOptionMenuWidget import DynOptionMenu +from idlelib.tabbedpages import TabbedPageSet +from idlelib.keybindingDialog import GetKeysDialog +from idlelib.configSectionNameDialog import GetCfgSectionNameDialog +from idlelib.configHelpSourceEdit import GetHelpSourceDialog +from idlelib import macosxSupport class ConfigDialog(Toplevel): @@ -988,16 +988,11 @@ class ConfigDialog(Toplevel): self.SetThemeType() ##load theme element option menu themeNames=self.themeElements.keys() - themeNames.sort(self.__ThemeNameIndexCompare) + themeNames.sort(key=lambda x: self.themeElements[x][1]) self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0]) self.PaintThemeSample() self.SetHighlightTarget() - def __ThemeNameIndexCompare(self,a,b): - if self.themeElements[a][1] int(h2[2]): - return 1 - else: - return 0 - def GetAllExtraHelpSourcesList(self): """ Returns a list of tuples containing the details of all additional help diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py index d6d1f18126d..5339f88f61c 100644 --- a/Lib/idlelib/keybindingDialog.py +++ b/Lib/idlelib/keybindingDialog.py @@ -132,7 +132,7 @@ class GetKeysDialog(Toplevel): order is also important: key binding equality depends on it, so config-keys.def must use the same ordering. """ - import macosxSupport + from idlelib import macosxSupport if macosxSupport.runningAsOSXApp(): self.modifiers = ['Shift', 'Control', 'Option', 'Command'] else: @@ -167,7 +167,7 @@ class GetKeysDialog(Toplevel): def GetModifiers(self): modList = [variable.get() for variable in self.modifier_vars] - return filter(None, modList) + return [mod for mod in modList if mod] def ClearKeySeq(self): self.listKeysFinal.select_clear(0,END) diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py index bf472c22d2d..7ef56f3440a 100644 --- a/Lib/idlelib/macosxSupport.py +++ b/Lib/idlelib/macosxSupport.py @@ -51,10 +51,10 @@ def overrideRootMenu(root, flist): # Due to a (mis-)feature of TkAqua the user will also see an empty Help # menu. from Tkinter import Menu, Text, Text - from EditorWindow import prepstr, get_accelerator - import Bindings - import WindowList - from MultiCall import MultiCallCreator + from idlelib.EditorWindow import prepstr, get_accelerator + from idlelib import Bindings + from idlelib import WindowList + from idlelib.MultiCall import MultiCallCreator menubar = Menu(root) root.configure(menu=menubar) @@ -77,11 +77,11 @@ def overrideRootMenu(root, flist): menubar.add_cascade(label='IDLE', menu=menu) def about_dialog(event=None): - import aboutDialog + from idlelib import aboutDialog aboutDialog.AboutDialog(root, 'About IDLE') def config_dialog(event=None): - import configDialog + from idlelib import configDialog root.instance_dict = flist.inversedict configDialog.ConfigDialog(root, 'Settings') diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index abe94abc8b9..270ea15d6db 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -7,13 +7,13 @@ import thread import threading import Queue -import CallTips -import AutoComplete +from idlelib import CallTips +from idlelib import AutoComplete -import RemoteDebugger -import RemoteObjectBrowser -import StackViewer -import rpc +from idlelib import RemoteDebugger +from idlelib import RemoteObjectBrowser +from idlelib import StackViewer +from idlelib import rpc import __main__ @@ -118,7 +118,7 @@ def manage_socket(address): break except socket.error, err: print>>sys.__stderr__,"IDLE Subprocess: socket error: "\ - + err[1] + ", retrying...." + + err.args[1] + ", retrying...." else: print>>sys.__stderr__, "IDLE Subprocess: Connection to "\ "IDLE GUI failed, exiting." @@ -133,14 +133,15 @@ def show_socket_error(err, address): import tkMessageBox root = Tkinter.Tk() root.withdraw() - if err[0] == 61: # connection refused + if err.args[0] == 61: # connection refused msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\ "to your personal firewall configuration. It is safe to "\ "allow this internal connection because no data is visible on "\ "external ports." % address tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root) else: - tkMessageBox.showerror("IDLE Subprocess Error", "Socket Error: %s" % err[1]) + tkMessageBox.showerror("IDLE Subprocess Error", + "Socket Error: %s" % err.args[1]) root.destroy() def print_exception(): @@ -253,7 +254,7 @@ class MyHandler(rpc.RPCHandler): sys.stdin = self.console = self.get_remote_proxy("stdin") sys.stdout = self.get_remote_proxy("stdout") sys.stderr = self.get_remote_proxy("stderr") - import IOBinding + from idlelib import IOBinding sys.stdin.encoding = sys.stdout.encoding = \ sys.stderr.encoding = IOBinding.encoding self.interp = self.get_remote_proxy("interp")