diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-04-02 07:24:52 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-04-02 07:24:52 (GMT) |
commit | d630c04ab1ab35e2ec6eeeaba9bdcb9f8e730e78 (patch) | |
tree | f3dbe58315387ba5b3c26e7ed37d37b5ebf3d711 | |
parent | f28dd0d1bfd85e5285894bfac54f6668d7217210 (diff) | |
download | cpython-d630c04ab1ab35e2ec6eeeaba9bdcb9f8e730e78.zip cpython-d630c04ab1ab35e2ec6eeeaba9bdcb9f8e730e78.tar.gz cpython-d630c04ab1ab35e2ec6eeeaba9bdcb9f8e730e78.tar.bz2 |
#7092: Fix additional "-3" warnings in the idlelib package, and convert to absolute imports.
37 files changed, 169 insertions, 149 deletions
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py index d55b799..fa1733f 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 81eeec1..298177f 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 = "<<autocompletewindow-hide>>" HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>") @@ -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 1853ff9..74a93d3 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 bd51b7f..f8f31e2 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 e5a60a5..095b30d 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 420ec33..2f6f737 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 e55f9e6..7f4d740 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 f56460a..04eea32 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 d659cff..9ac70ac 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -5,18 +5,18 @@ import imp 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 @@ -51,13 +51,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 @@ -580,11 +580,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): diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py index d69b0e3..475cd3d 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 f30898e..02f96d4 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 ab136bc..e40e546 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 519de74..94f1496 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: diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py index 01d278e..cbc1c33 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 960242f..983a140 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 53276d9..b81c5ed 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<<i) & x, - range(len(_modifiers)))): - nummod(b) - nummod(a)) + +def expand_substates(states): + '''For each item of states return a list containing all combinations of + that item with individual bits reset, sorted by the number of set bits. + ''' + def nbits(n): + "number of bits set in n base 2" + nb = 0 + while n: + n, rem = divmod(n, 2) + nb += rem + return nb + statelist = [] + for state in states: + substates = list(set(state & x for x in states)) + substates.sort(key=nbits, reverse=True) + statelist.append(substates) + return statelist + +_state_subsets = expand_substates(_states) + # _state_codes gives for each state, the portable code to be passed as mc_state _state_codes = [] for s in _states: @@ -297,7 +312,7 @@ def MultiCallCreator(widget): assert issubclass(widget, Tkinter.Misc) def __init__(self, *args, **kwargs): - apply(widget.__init__, (self,)+args, kwargs) + widget.__init__(self, *args, **kwargs) # a dictionary which maps a virtual event to a tuple with: # 0. the function binded # 1. a list of triplets - the sequences it is binded to diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/ObjectBrowser.py index b4f64b6..7de6988 100644 --- a/Lib/idlelib/ObjectBrowser.py +++ b/Lib/idlelib/ObjectBrowser.py @@ -9,7 +9,7 @@ # XXX TO DO: # - for classes/modules, add "open source" to object browser -from TreeWidget import TreeItem, TreeNode, ScrolledCanvas +from idlelib.TreeWidget import TreeItem, TreeNode, ScrolledCanvas from repr import Repr diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py index f6b379b..60d09c0 100644 --- a/Lib/idlelib/OutputWindow.py +++ b/Lib/idlelib/OutputWindow.py @@ -1,8 +1,8 @@ from Tkinter import * -from EditorWindow import EditorWindow +from idlelib.EditorWindow import EditorWindow import re import tkMessageBox -import IOBinding +from idlelib import IOBinding class OutputWindow(EditorWindow): @@ -47,8 +47,9 @@ class OutputWindow(EditorWindow): self.text.see(mark) self.text.update() - def writelines(self, l): - map(self.write, l) + def writelines(self, lines): + for line in lines: + self.write(line) def flush(self): pass diff --git a/Lib/idlelib/ParenMatch.py b/Lib/idlelib/ParenMatch.py index 250ae8b..6d91b39 100644 --- a/Lib/idlelib/ParenMatch.py +++ b/Lib/idlelib/ParenMatch.py @@ -5,8 +5,8 @@ paren. Paren here is used generically; the matching applies to parentheses, square brackets, and curly braces. """ -from HyperParser import HyperParser -from configHandler import idleConf +from idlelib.HyperParser import HyperParser +from idlelib.configHandler import idleConf _openers = {')':'(',']':'[','}':'{'} CHECK_DELAY = 100 # miliseconds diff --git a/Lib/idlelib/PathBrowser.py b/Lib/idlelib/PathBrowser.py index 8c73587..d88a48e 100644 --- a/Lib/idlelib/PathBrowser.py +++ b/Lib/idlelib/PathBrowser.py @@ -2,8 +2,8 @@ import os import sys import imp -from TreeWidget import TreeItem -from ClassBrowser import ClassBrowser, ModuleBrowserTreeItem +from idlelib.TreeWidget import TreeItem +from idlelib.ClassBrowser import ClassBrowser, ModuleBrowserTreeItem class PathBrowser(ClassBrowser): @@ -86,7 +86,7 @@ class DirBrowserTreeItem(TreeItem): return sorted def main(): - import PyShell + from idlelib import PyShell PathBrowser(PyShell.flist) if sys.stdin is sys.__stdin__: mainloop() diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/Percolator.py index ebbcba9..e24689b 100644 --- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/Percolator.py @@ -1,5 +1,5 @@ -from WidgetRedirector import WidgetRedirector -from Delegator import Delegator +from idlelib.WidgetRedirector import WidgetRedirector +from idlelib.Delegator import Delegator class Percolator: diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 271310a..5491a75 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -11,7 +11,6 @@ import time import threading import traceback import types -import macosxSupport import linecache from code import InteractiveInterpreter @@ -24,17 +23,17 @@ except ImportError: sys.exit(1) import tkMessageBox -from EditorWindow import EditorWindow, fixwordbreaks -from FileList import FileList -from ColorDelegator import ColorDelegator -from UndoDelegator import UndoDelegator -from OutputWindow import OutputWindow -from configHandler import idleConf -import idlever - -import rpc -import Debugger -import RemoteDebugger +from idlelib.EditorWindow import EditorWindow, fixwordbreaks +from idlelib.FileList import FileList +from idlelib.ColorDelegator import ColorDelegator +from idlelib.UndoDelegator import UndoDelegator +from idlelib.OutputWindow import OutputWindow +from idlelib.configHandler import idleConf +from idlelib import idlever +from idlelib import rpc +from idlelib import Debugger +from idlelib import RemoteDebugger +from idlelib import macosxSupport IDENTCHARS = string.ascii_letters + string.digits + "_" HOST = '127.0.0.1' # python execution server on localhost loopback @@ -561,13 +560,13 @@ class ModifiedInterpreter(InteractiveInterpreter): return def remote_stack_viewer(self): - import RemoteObjectBrowser + from idlelib import RemoteObjectBrowser oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {}) if oid is None: self.tkconsole.root.bell() return item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid) - from TreeWidget import ScrolledCanvas, TreeNode + from idlelib.TreeWidget import ScrolledCanvas, TreeNode top = Toplevel(self.tkconsole.root) theme = idleConf.GetOption('main','Theme','name') background = idleConf.GetHighlight(theme, 'normal')['background'] @@ -607,7 +606,7 @@ class ModifiedInterpreter(InteractiveInterpreter): self.save_warnings_filters = warnings.filters[:] warnings.filterwarnings(action="error", category=SyntaxWarning) if isinstance(source, types.UnicodeType): - import IOBinding + from idlelib import IOBinding try: source = source.encode(IOBinding.encoding) except UnicodeError: @@ -816,7 +815,7 @@ class PyShell(OutputWindow): # New classes - from IdleHistory import History + from idlelib.IdleHistory import History def __init__(self, flist=None): if use_subprocess: @@ -854,7 +853,7 @@ class PyShell(OutputWindow): self.save_stdout = sys.stdout self.save_stderr = sys.stderr self.save_stdin = sys.stdin - import IOBinding + from idlelib import IOBinding self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) self.console = PseudoFile(self, "console", IOBinding.encoding) @@ -1014,7 +1013,7 @@ class PyShell(OutputWindow): if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C line = "\n" if isinstance(line, unicode): - import IOBinding + from idlelib import IOBinding try: line = line.encode(IOBinding.encoding) except UnicodeError: @@ -1192,7 +1191,7 @@ class PyShell(OutputWindow): "(sys.last_traceback is not defined)", master=self.text) return - from StackViewer import StackBrowser + from idlelib.StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) def view_restart_mark(self, event=None): @@ -1246,8 +1245,9 @@ class PseudoFile(object): def write(self, s): self.shell.write(s, self.tags) - def writelines(self, l): - map(self.write, l) + def writelines(self, lines): + for line in lines: + self.write(line) def flush(self): pass @@ -1375,7 +1375,7 @@ def main(): pathx.append(os.path.dirname(filename)) for dir in pathx: dir = os.path.abspath(dir) - if not dir in sys.path: + if dir not in sys.path: sys.path.insert(0, dir) else: dir = os.getcwd() diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py index 0b89168..647285f 100644 --- a/Lib/idlelib/RemoteDebugger.py +++ b/Lib/idlelib/RemoteDebugger.py @@ -21,8 +21,8 @@ barrier, in particular frame and traceback objects. """ import types -import rpc -import Debugger +from idlelib import rpc +from idlelib import Debugger debugging = 0 diff --git a/Lib/idlelib/RemoteObjectBrowser.py b/Lib/idlelib/RemoteObjectBrowser.py index 6ba3391..43e2c68 100644 --- a/Lib/idlelib/RemoteObjectBrowser.py +++ b/Lib/idlelib/RemoteObjectBrowser.py @@ -1,4 +1,4 @@ -import rpc +from idlelib import rpc def remote_object_tree_item(item): wrapper = WrappedObjectTreeItem(item) diff --git a/Lib/idlelib/ReplaceDialog.py b/Lib/idlelib/ReplaceDialog.py index c8eb1c8..2d6c802 100644 --- a/Lib/idlelib/ReplaceDialog.py +++ b/Lib/idlelib/ReplaceDialog.py @@ -1,6 +1,7 @@ from Tkinter import * -import SearchEngine -from SearchDialogBase import SearchDialogBase + +from idlelib import SearchEngine +from idlelib.SearchDialogBase import SearchDialogBase def replace(text): root = text._root() diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index cb01110..3a44165 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -23,9 +23,9 @@ import string import tabnanny import tokenize import tkMessageBox -import PyShell +from idlelib import PyShell -from configHandler import idleConf +from idlelib.configHandler import idleConf IDENTCHARS = string.ascii_letters + string.digits + "_" diff --git a/Lib/idlelib/SearchDialog.py b/Lib/idlelib/SearchDialog.py index d7124d6..7c70b84 100644 --- a/Lib/idlelib/SearchDialog.py +++ b/Lib/idlelib/SearchDialog.py @@ -1,7 +1,7 @@ from Tkinter import * -import SearchEngine -from SearchDialogBase import SearchDialogBase +from idlelib import SearchEngine +from idlelib.SearchDialogBase import SearchDialogBase def _setup(text): root = text._root() diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/StackViewer.py index 6b7730b..732773f 100644 --- a/Lib/idlelib/StackViewer.py +++ b/Lib/idlelib/StackViewer.py @@ -2,8 +2,8 @@ import os import sys import linecache -from TreeWidget import TreeNode, TreeItem, ScrolledCanvas -from ObjectBrowser import ObjectTreeItem, make_objecttreeitem +from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas +from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem def StackBrowser(root, flist=None, tb=None, top=None): if top is None: diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py index 842f788..0feca01 100644 --- a/Lib/idlelib/TreeWidget.py +++ b/Lib/idlelib/TreeWidget.py @@ -18,8 +18,8 @@ import os from Tkinter import * import imp -import ZoomHeight -from configHandler import idleConf +from idlelib import ZoomHeight +from idlelib.configHandler import idleConf ICONDIR = "Icons" @@ -397,7 +397,7 @@ class FileTreeItem(TreeItem): names = os.listdir(self.path) except os.error: return [] - names.sort(lambda a, b: cmp(os.path.normcase(a), os.path.normcase(b))) + names.sort(key = os.path.normcase) sublist = [] for name in names: item = FileTreeItem(os.path.join(self.path, name)) @@ -452,7 +452,7 @@ class ScrolledCanvas: # Testing functions def test(): - import PyShell + from idlelib import PyShell root = Toplevel(PyShell.root) root.configure(bd=0, bg="yellow") root.focus_set() diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py index 5896bd5..16d3ae1 100644 --- a/Lib/idlelib/UndoDelegator.py +++ b/Lib/idlelib/UndoDelegator.py @@ -1,6 +1,7 @@ import string from Tkinter import * -from Delegator import Delegator + +from idlelib.Delegator import Delegator #$ event <<redo>> #$ win <Control-y> @@ -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 83ca3a6..e8d1710 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 008602c..43a1313 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 80c54b6..d0b2155 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): diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 2947873..8a04745 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -20,7 +20,7 @@ configuration problem notification and resolution. import os import sys import string -import macosxSupport +from idlelib import macosxSupport from ConfigParser import ConfigParser, NoOptionError, NoSectionError class InvalidConfigType(Exception): pass diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py index d6d1f18..5339f88 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 03a1458..7d3d57b 100644 --- a/Lib/idlelib/macosxSupport.py +++ b/Lib/idlelib/macosxSupport.py @@ -57,10 +57,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) @@ -83,11 +83,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 b5a6af3..642b979 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__ @@ -122,7 +122,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." @@ -137,14 +137,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(): @@ -257,7 +258,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") |