Merged revisions 79576-79578 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79576 | florent.xicluna | 2010-04-02 10:24:52 +0300 (Fri, 02 Apr 2010) | 2 lines

  #7092: Fix additional "-3" warnings in the idlelib package, and convert to absolute imports.
........
  r79577 | florent.xicluna | 2010-04-02 11:15:26 +0300 (Fri, 02 Apr 2010) | 2 lines

  #7092: Drop the cmp argument.
........
  r79578 | florent.xicluna | 2010-04-02 11:30:21 +0300 (Fri, 02 Apr 2010) | 2 lines

  #7092: silence some py3k warnings
........
This commit is contained in:
Ezio Melotti 2010-08-02 20:40:20 +00:00
parent b55d368055
commit 4c6daf1037
37 changed files with 173 additions and 166 deletions

View File

@ -7,12 +7,7 @@ import os
import sys import sys
import string import string
from configHandler import idleConf from idlelib.configHandler import idleConf
import AutoCompleteWindow
from HyperParser import HyperParser
import __main__
# This string includes all chars that may be in a file name (without a path # This string includes all chars that may be in a file name (without a path
# separator) # separator)
@ -23,6 +18,11 @@ ID_CHARS = string.ascii_letters + string.digits + "_"
# These constants represent the two different types of completions # These constants represent the two different types of completions
COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1) COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1)
from idlelib import AutoCompleteWindow
from idlelib.HyperParser import HyperParser
import __main__
SEPS = os.sep SEPS = os.sep
if os.altsep: # e.g. '/' on Windows... if os.altsep: # e.g. '/' on Windows...
SEPS += os.altsep SEPS += os.altsep
@ -193,7 +193,7 @@ class AutoComplete:
smalll = eval("__all__", namespace) smalll = eval("__all__", namespace)
smalll.sort() smalll.sort()
else: else:
smalll = filter(lambda s: s[:1] != '_', bigl) smalll = [s for s in bigl if s[:1] != '_']
else: else:
try: try:
entity = self.get_entity(what) entity = self.get_entity(what)
@ -203,7 +203,7 @@ class AutoComplete:
smalll = entity.__all__ smalll = entity.__all__
smalll.sort() smalll.sort()
else: else:
smalll = filter(lambda s: s[:1] != '_', bigl) smalll = [s for s in bigl if s[:1] != '_']
except: except:
return [], [] return [], []
@ -214,7 +214,7 @@ class AutoComplete:
expandedpath = os.path.expanduser(what) expandedpath = os.path.expanduser(what)
bigl = os.listdir(expandedpath) bigl = os.listdir(expandedpath)
bigl.sort() bigl.sort()
smalll = filter(lambda s: s[:1] != '.', bigl) smalll = [s for s in bigl if s[:1] != '.']
except OSError: except OSError:
return [], [] return [], []

View File

@ -2,8 +2,8 @@
An auto-completion window for IDLE, used by the AutoComplete extension An auto-completion window for IDLE, used by the AutoComplete extension
""" """
from Tkinter import * from Tkinter import *
from MultiCall import MC_SHIFT from idlelib.MultiCall import MC_SHIFT
import AutoComplete from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>" HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>"
HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>") HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>")
@ -264,7 +264,7 @@ class AutoCompleteWindow:
if keysym != "Tab": if keysym != "Tab":
self.lastkey_was_tab = False self.lastkey_was_tab = False
if (len(keysym) == 1 or keysym in ("underscore", "BackSpace") 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"))) \ ("period", "minus"))) \
and not (state & ~MC_SHIFT): and not (state & ~MC_SHIFT):
# Normal editing of text # Normal editing of text
@ -292,10 +292,10 @@ class AutoCompleteWindow:
self.hide_window() self.hide_window()
return return
elif (self.mode == AutoComplete.COMPLETE_ATTRIBUTES and keysym in elif (self.mode == COMPLETE_ATTRIBUTES and keysym in
("period", "space", "parenleft", "parenright", "bracketleft", ("period", "space", "parenleft", "parenright", "bracketleft",
"bracketright")) or \ "bracketright")) or \
(self.mode == AutoComplete.COMPLETE_FILES and keysym in (self.mode == COMPLETE_FILES and keysym in
("slash", "backslash", "quotedbl", "apostrophe")) \ ("slash", "backslash", "quotedbl", "apostrophe")) \
and not (state & ~MC_SHIFT): and not (state & ~MC_SHIFT):
# If start is a prefix of the selection, but is not '' when # If start is a prefix of the selection, but is not '' when
@ -303,7 +303,7 @@ class AutoCompleteWindow:
# selected completion. Anyway, close the list. # selected completion. Anyway, close the list.
cursel = int(self.listbox.curselection()[0]) cursel = int(self.listbox.curselection()[0])
if self.completions[cursel][:len(self.start)] == self.start \ 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._change_start(self.completions[cursel])
self.hide_window() self.hide_window()
return return

View File

@ -9,8 +9,8 @@ windows.
""" """
import sys import sys
from configHandler import idleConf from idlelib.configHandler import idleConf
import macosxSupport from idlelib import macosxSupport
menudefs = [ menudefs = [
# underscore prefixes character to underscore # underscore prefixes character to underscore

View File

@ -9,8 +9,8 @@ import re
import sys import sys
import types import types
import CallTipWindow from idlelib import CallTipWindow
from HyperParser import HyperParser from idlelib.HyperParser import HyperParser
import __main__ import __main__

View File

@ -14,10 +14,10 @@ import os
import sys import sys
import pyclbr import pyclbr
import PyShell from idlelib import PyShell
from WindowList import ListedToplevel from idlelib.WindowList import ListedToplevel
from TreeWidget import TreeNode, TreeItem, ScrolledCanvas from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
from configHandler import idleConf from idlelib.configHandler import idleConf
class ClassBrowser: class ClassBrowser:

View File

@ -11,9 +11,9 @@ not open blocks are not shown in the context hints pane.
""" """
import Tkinter import Tkinter
from Tkconstants import TOP, LEFT, X, W, SUNKEN from Tkconstants import TOP, LEFT, X, W, SUNKEN
from configHandler import idleConf
import re import re
from sys import maxint as INFINITY from sys import maxint as INFINITY
from idlelib.configHandler import idleConf
BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for", BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for",
"if", "try", "while", "with"]) "if", "try", "while", "with"])

View File

@ -3,8 +3,8 @@ import re
import keyword import keyword
import __builtin__ import __builtin__
from Tkinter import * from Tkinter import *
from Delegator import Delegator from idlelib.Delegator import Delegator
from configHandler import idleConf from idlelib.configHandler import idleConf
DEBUG = False DEBUG = False
@ -248,7 +248,7 @@ class ColorDelegator(Delegator):
self.tag_remove(tag, "1.0", "end") self.tag_remove(tag, "1.0", "end")
def main(): def main():
from Percolator import Percolator from idlelib.Percolator import Percolator
root = Tk() root = Tk()
root.wm_protocol("WM_DELETE_WINDOW", root.quit) root.wm_protocol("WM_DELETE_WINDOW", root.quit)
text = Text(background="white") text = Text(background="white")

View File

@ -2,9 +2,9 @@ import os
import bdb import bdb
import types import types
from Tkinter import * from Tkinter import *
from WindowList import ListedToplevel from idlelib.WindowList import ListedToplevel
from ScrolledList import ScrolledList from idlelib.ScrolledList import ScrolledList
import macosxSupport from idlelib import macosxSupport
class Idb(bdb.Bdb): class Idb(bdb.Bdb):

View File

@ -6,18 +6,18 @@ from itertools import count
from Tkinter import * from Tkinter import *
import tkSimpleDialog import tkSimpleDialog
import tkMessageBox import tkMessageBox
from MultiCall import MultiCallCreator
import webbrowser import webbrowser
import idlever
import WindowList from idlelib.MultiCall import MultiCallCreator
import SearchDialog from idlelib import idlever
import GrepDialog from idlelib import WindowList
import ReplaceDialog from idlelib import SearchDialog
import PyParse from idlelib import GrepDialog
from configHandler import idleConf from idlelib import ReplaceDialog
import aboutDialog, textView, configDialog from idlelib import PyParse
import macosxSupport 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. # The default tab setting for a Text widget, in average-width characters.
TK_TABWIDTH_DEFAULT = 8 TK_TABWIDTH_DEFAULT = 8
@ -50,13 +50,13 @@ def _find_module(fullname, path=None):
return file, filename, descr return file, filename, descr
class EditorWindow(object): class EditorWindow(object):
from Percolator import Percolator from idlelib.Percolator import Percolator
from ColorDelegator import ColorDelegator from idlelib.ColorDelegator import ColorDelegator
from UndoDelegator import UndoDelegator from idlelib.UndoDelegator import UndoDelegator
from IOBinding import IOBinding, filesystemencoding, encoding from idlelib.IOBinding import IOBinding, filesystemencoding, encoding
import Bindings from idlelib import Bindings
from Tkinter import Toplevel from Tkinter import Toplevel
from MultiStatusBar import MultiStatusBar from idlelib.MultiStatusBar import MultiStatusBar
help_url = None help_url = None
@ -579,11 +579,11 @@ class EditorWindow(object):
return None return None
head, tail = os.path.split(filename) head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail) base, ext = os.path.splitext(tail)
import ClassBrowser from idlelib import ClassBrowser
ClassBrowser.ClassBrowser(self.flist, base, [head]) ClassBrowser.ClassBrowser(self.flist, base, [head])
def open_path_browser(self, event=None): def open_path_browser(self, event=None):
import PathBrowser from idlelib import PathBrowser
PathBrowser.PathBrowser(self.flist) PathBrowser.PathBrowser(self.flist)
def gotoline(self, lineno): def gotoline(self, lineno):
@ -1193,7 +1193,7 @@ class EditorWindow(object):
if not self.context_use_ps1: if not self.context_use_ps1:
for context in self.num_context_lines: for context in self.num_context_lines:
startat = max(lno - context, 1) startat = max(lno - context, 1)
startatindex = `startat` + ".0" startatindex = repr(startat) + ".0"
rawtext = text.get(startatindex, "insert") rawtext = text.get(startatindex, "insert")
y.set_str(rawtext) y.set_str(rawtext)
bod = y.find_good_parse_start( bod = y.find_good_parse_start(

View File

@ -5,8 +5,8 @@ import tkMessageBox
class FileList: class FileList:
from EditorWindow import EditorWindow # class variable, may be overridden # N.B. this import overridden in PyShellFileList.
# e.g. by PyShellFileList from idlelib.EditorWindow import EditorWindow
def __init__(self, root): def __init__(self, root):
self.root = root self.root = root
@ -106,7 +106,7 @@ class FileList:
def _test(): def _test():
from EditorWindow import fixwordbreaks from idlelib.EditorWindow import fixwordbreaks
import sys import sys
root = Tk() root = Tk()
fixwordbreaks(root) fixwordbreaks(root)

View File

@ -15,7 +15,7 @@
# * Fancy comments, like this bulleted list, arent handled :-) # * Fancy comments, like this bulleted list, arent handled :-)
import re import re
from configHandler import idleConf from idlelib.configHandler import idleConf
class FormatParagraph: class FormatParagraph:

View File

@ -2,8 +2,8 @@ import os
import fnmatch import fnmatch
import sys import sys
from Tkinter import * from Tkinter import *
import SearchEngine from idlelib import SearchEngine
from SearchDialogBase import SearchDialogBase from idlelib.SearchDialogBase import SearchDialogBase
def grep(text, io=None, flist=None): def grep(text, io=None, flist=None):
root = text._root() root = text._root()
@ -63,7 +63,7 @@ class GrepDialog(SearchDialogBase):
if not path: if not path:
self.top.bell() self.top.bell()
return return
from OutputWindow import OutputWindow from idlelib.OutputWindow import OutputWindow
save = sys.stdout save = sys.stdout
try: try:
sys.stdout = OutputWindow(self.flist) sys.stdout = OutputWindow(self.flist)

View File

@ -10,7 +10,7 @@ structure of code, used by extensions to help the user.
import string import string
import keyword import keyword
import PyParse from idlelib import PyParse
class HyperParser: class HyperParser:
@ -31,7 +31,7 @@ class HyperParser:
if not editwin.context_use_ps1: if not editwin.context_use_ps1:
for context in editwin.num_context_lines: for context in editwin.num_context_lines:
startat = max(lno - context, 1) startat = max(lno - context, 1)
startatindex = `startat` + ".0" startatindex = repr(startat) + ".0"
stopatindex = "%d.end" % lno stopatindex = "%d.end" % lno
# We add the newline because PyParse requires a newline at end. # 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 # We add a space so that index won't be at end of line, so that

View File

@ -16,7 +16,7 @@ import re
from Tkinter import * from Tkinter import *
from SimpleDialog import SimpleDialog from SimpleDialog import SimpleDialog
from configHandler import idleConf from idlelib.configHandler import idleConf
try: try:
from codecs import BOM_UTF8 from codecs import BOM_UTF8

View File

@ -1,4 +1,4 @@
from configHandler import idleConf from idlelib.configHandler import idleConf
class History: class History:

View File

@ -33,7 +33,7 @@ import sys
import string import string
import re import re
import Tkinter import Tkinter
import macosxSupport from idlelib import macosxSupport
# the event type constants, which define the meaning of mc_type # the event type constants, which define the meaning of mc_type
MC_KEYPRESS=0; MC_KEYRELEASE=1; MC_BUTTONPRESS=2; MC_BUTTONRELEASE=3; 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) for i, m in enumerate(_modifiers)
if (1 << i) & s) if (1 << i) & s)
for s in _states] for s in _states]
_state_subsets = map(lambda i: filter(lambda j: not (j & (~i)), _states),
_states) def expand_substates(states):
for l in _state_subsets: '''For each item of states return a list containing all combinations of
l.sort(lambda a, b, nummod = lambda x: len(filter(lambda i: (1<<i) & x, that item with individual bits reset, sorted by the number of set bits.
range(len(_modifiers)))): '''
nummod(b) - nummod(a)) 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 gives for each state, the portable code to be passed as mc_state
_state_codes = [] _state_codes = []
for s in _states: for s in _states:
@ -297,7 +312,7 @@ def MultiCallCreator(widget):
assert issubclass(widget, Tkinter.Misc) assert issubclass(widget, Tkinter.Misc)
def __init__(self, *args, **kwargs): 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: # a dictionary which maps a virtual event to a tuple with:
# 0. the function binded # 0. the function binded
# 1. a list of triplets - the sequences it is binded to # 1. a list of triplets - the sequences it is binded to

View File

@ -9,7 +9,7 @@
# XXX TO DO: # XXX TO DO:
# - for classes/modules, add "open source" to object browser # - 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 from repr import Repr

View File

@ -1,8 +1,8 @@
from Tkinter import * from Tkinter import *
from EditorWindow import EditorWindow from idlelib.EditorWindow import EditorWindow
import re import re
import tkMessageBox import tkMessageBox
import IOBinding from idlelib import IOBinding
class OutputWindow(EditorWindow): class OutputWindow(EditorWindow):
@ -47,8 +47,9 @@ class OutputWindow(EditorWindow):
self.text.see(mark) self.text.see(mark)
self.text.update() self.text.update()
def writelines(self, l): def writelines(self, lines):
map(self.write, l) for line in lines:
self.write(line)
def flush(self): def flush(self):
pass pass

View File

@ -5,8 +5,8 @@ paren. Paren here is used generically; the matching applies to
parentheses, square brackets, and curly braces. parentheses, square brackets, and curly braces.
""" """
from HyperParser import HyperParser from idlelib.HyperParser import HyperParser
from configHandler import idleConf from idlelib.configHandler import idleConf
_openers = {')':'(',']':'[','}':'{'} _openers = {')':'(',']':'[','}':'{'}
CHECK_DELAY = 100 # miliseconds CHECK_DELAY = 100 # miliseconds

View File

@ -2,8 +2,8 @@ import os
import sys import sys
import imp import imp
from TreeWidget import TreeItem from idlelib.TreeWidget import TreeItem
from ClassBrowser import ClassBrowser, ModuleBrowserTreeItem from idlelib.ClassBrowser import ClassBrowser, ModuleBrowserTreeItem
class PathBrowser(ClassBrowser): class PathBrowser(ClassBrowser):
@ -86,7 +86,7 @@ class DirBrowserTreeItem(TreeItem):
return sorted return sorted
def main(): def main():
import PyShell from idlelib import PyShell
PathBrowser(PyShell.flist) PathBrowser(PyShell.flist)
if sys.stdin is sys.__stdin__: if sys.stdin is sys.__stdin__:
mainloop() mainloop()

View File

@ -1,5 +1,5 @@
from WidgetRedirector import WidgetRedirector from idlelib.WidgetRedirector import WidgetRedirector
from Delegator import Delegator from idlelib.Delegator import Delegator
class Percolator: class Percolator:

View File

@ -11,7 +11,6 @@ import time
import threading import threading
import traceback import traceback
import types import types
import macosxSupport
import linecache import linecache
from code import InteractiveInterpreter from code import InteractiveInterpreter
@ -24,17 +23,17 @@ except ImportError:
sys.exit(1) sys.exit(1)
import tkMessageBox import tkMessageBox
from EditorWindow import EditorWindow, fixwordbreaks from idlelib.EditorWindow import EditorWindow, fixwordbreaks
from FileList import FileList from idlelib.FileList import FileList
from ColorDelegator import ColorDelegator from idlelib.ColorDelegator import ColorDelegator
from UndoDelegator import UndoDelegator from idlelib.UndoDelegator import UndoDelegator
from OutputWindow import OutputWindow from idlelib.OutputWindow import OutputWindow
from configHandler import idleConf from idlelib.configHandler import idleConf
import idlever from idlelib import idlever
from idlelib import rpc
import rpc from idlelib import Debugger
import Debugger from idlelib import RemoteDebugger
import RemoteDebugger from idlelib import macosxSupport
IDENTCHARS = string.ascii_letters + string.digits + "_" IDENTCHARS = string.ascii_letters + string.digits + "_"
LOCALHOST = '127.0.0.1' LOCALHOST = '127.0.0.1'
@ -547,13 +546,13 @@ class ModifiedInterpreter(InteractiveInterpreter):
return return
def remote_stack_viewer(self): def remote_stack_viewer(self):
import RemoteObjectBrowser from idlelib import RemoteObjectBrowser
oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {}) oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {})
if oid is None: if oid is None:
self.tkconsole.root.bell() self.tkconsole.root.bell()
return return
item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid) item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid)
from TreeWidget import ScrolledCanvas, TreeNode from idlelib.TreeWidget import ScrolledCanvas, TreeNode
top = Toplevel(self.tkconsole.root) top = Toplevel(self.tkconsole.root)
theme = idleConf.GetOption('main','Theme','name') theme = idleConf.GetOption('main','Theme','name')
background = idleConf.GetHighlight(theme, 'normal')['background'] background = idleConf.GetHighlight(theme, 'normal')['background']
@ -593,7 +592,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.save_warnings_filters = warnings.filters[:] self.save_warnings_filters = warnings.filters[:]
warnings.filterwarnings(action="error", category=SyntaxWarning) warnings.filterwarnings(action="error", category=SyntaxWarning)
if isinstance(source, types.UnicodeType): if isinstance(source, types.UnicodeType):
import IOBinding from idlelib import IOBinding
try: try:
source = source.encode(IOBinding.encoding) source = source.encode(IOBinding.encoding)
except UnicodeError: except UnicodeError:
@ -803,7 +802,7 @@ class PyShell(OutputWindow):
# New classes # New classes
from IdleHistory import History from idlelib.IdleHistory import History
def __init__(self, flist=None): def __init__(self, flist=None):
if use_subprocess: if use_subprocess:
@ -841,7 +840,7 @@ class PyShell(OutputWindow):
self.save_stdout = sys.stdout self.save_stdout = sys.stdout
self.save_stderr = sys.stderr self.save_stderr = sys.stderr
self.save_stdin = sys.stdin self.save_stdin = sys.stdin
import IOBinding from idlelib import IOBinding
self.stdout = PseudoFile(self, "stdout", IOBinding.encoding) self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
self.stderr = PseudoFile(self, "stderr", IOBinding.encoding) self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
self.console = PseudoFile(self, "console", IOBinding.encoding) self.console = PseudoFile(self, "console", IOBinding.encoding)
@ -1011,7 +1010,7 @@ class PyShell(OutputWindow):
if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C
line = "\n" line = "\n"
if isinstance(line, unicode): if isinstance(line, unicode):
import IOBinding from idlelib import IOBinding
try: try:
line = line.encode(IOBinding.encoding) line = line.encode(IOBinding.encoding)
except UnicodeError: except UnicodeError:
@ -1189,7 +1188,7 @@ class PyShell(OutputWindow):
"(sys.last_traceback is not defined)", "(sys.last_traceback is not defined)",
master=self.text) master=self.text)
return return
from StackViewer import StackBrowser from idlelib.StackViewer import StackBrowser
sv = StackBrowser(self.root, self.flist) sv = StackBrowser(self.root, self.flist)
def view_restart_mark(self, event=None): def view_restart_mark(self, event=None):
@ -1243,8 +1242,9 @@ class PseudoFile(object):
def write(self, s): def write(self, s):
self.shell.write(s, self.tags) self.shell.write(s, self.tags)
def writelines(self, l): def writelines(self, lines):
map(self.write, l) for line in lines:
self.write(line)
def flush(self): def flush(self):
pass pass
@ -1371,7 +1371,7 @@ def main():
pathx.append(os.path.dirname(filename)) pathx.append(os.path.dirname(filename))
for dir in pathx: for dir in pathx:
dir = os.path.abspath(dir) dir = os.path.abspath(dir)
if not dir in sys.path: if dir not in sys.path:
sys.path.insert(0, dir) sys.path.insert(0, dir)
else: else:
dir = os.getcwd() dir = os.getcwd()

View File

@ -21,8 +21,8 @@ barrier, in particular frame and traceback objects.
""" """
import types import types
import rpc from idlelib import rpc
import Debugger from idlelib import Debugger
debugging = 0 debugging = 0

View File

@ -1,4 +1,4 @@
import rpc from idlelib import rpc
def remote_object_tree_item(item): def remote_object_tree_item(item):
wrapper = WrappedObjectTreeItem(item) wrapper = WrappedObjectTreeItem(item)

View File

@ -1,6 +1,7 @@
from Tkinter import * from Tkinter import *
import SearchEngine
from SearchDialogBase import SearchDialogBase from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
def replace(text): def replace(text):
root = text._root() root = text._root()

View File

@ -23,9 +23,9 @@ import string
import tabnanny import tabnanny
import tokenize import tokenize
import tkMessageBox import tkMessageBox
import PyShell from idlelib import PyShell
from configHandler import idleConf from idlelib.configHandler import idleConf
IDENTCHARS = string.ascii_letters + string.digits + "_" IDENTCHARS = string.ascii_letters + string.digits + "_"

View File

@ -1,7 +1,7 @@
from Tkinter import * from Tkinter import *
import SearchEngine
from SearchDialogBase import SearchDialogBase
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
def _setup(text): def _setup(text):
root = text._root() root = text._root()

View File

@ -2,8 +2,8 @@ import os
import sys import sys
import linecache import linecache
from TreeWidget import TreeNode, TreeItem, ScrolledCanvas from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
from ObjectBrowser import ObjectTreeItem, make_objecttreeitem from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem
def StackBrowser(root, flist=None, tb=None, top=None): def StackBrowser(root, flist=None, tb=None, top=None):
if top is None: if top is None:

View File

@ -18,8 +18,8 @@ import os
from Tkinter import * from Tkinter import *
import imp import imp
import ZoomHeight from idlelib import ZoomHeight
from configHandler import idleConf from idlelib.configHandler import idleConf
ICONDIR = "Icons" ICONDIR = "Icons"
@ -397,7 +397,7 @@ class FileTreeItem(TreeItem):
names = os.listdir(self.path) names = os.listdir(self.path)
except os.error: except os.error:
return [] return []
names.sort(lambda a, b: cmp(os.path.normcase(a), os.path.normcase(b))) names.sort(key = os.path.normcase)
sublist = [] sublist = []
for name in names: for name in names:
item = FileTreeItem(os.path.join(self.path, name)) item = FileTreeItem(os.path.join(self.path, name))
@ -452,7 +452,7 @@ class ScrolledCanvas:
# Testing functions # Testing functions
def test(): def test():
import PyShell from idlelib import PyShell
root = Toplevel(PyShell.root) root = Toplevel(PyShell.root)
root.configure(bd=0, bg="yellow") root.configure(bd=0, bg="yellow")
root.focus_set() root.focus_set()

View File

@ -1,6 +1,7 @@
import string import string
from Tkinter import * from Tkinter import *
from Delegator import Delegator
from idlelib.Delegator import Delegator
#$ event <<redo>> #$ event <<redo>>
#$ win <Control-y> #$ win <Control-y>
@ -336,7 +337,7 @@ class CommandSequence(Command):
return self.depth return self.depth
def main(): def main():
from Percolator import Percolator from idlelib.Percolator import Percolator
root = Tk() root = Tk()
root.wm_protocol("WM_DELETE_WINDOW", root.quit) root.wm_protocol("WM_DELETE_WINDOW", root.quit)
text = Text() text = Text()

View File

@ -2,7 +2,8 @@
import re import re
import sys import sys
import macosxSupport
from idlelib import macosxSupport
class ZoomHeight: class ZoomHeight:

View File

@ -4,9 +4,9 @@
from Tkinter import * from Tkinter import *
import os import os
import os.path
import textView from idlelib import textView
import idlever from idlelib import idlever
class AboutDialog(Toplevel): class AboutDialog(Toplevel):
"""Modal about dialog for idle """Modal about dialog for idle
@ -144,7 +144,7 @@ if __name__ == '__main__':
# test the dialog # test the dialog
root = Tk() root = Tk()
def run(): def run():
import aboutDialog from idlelib import aboutDialog
aboutDialog.AboutDialog(root, 'About') aboutDialog.AboutDialog(root, 'About')
Button(root, text='Dialog', command=run).pack() Button(root, text='Dialog', command=run).pack()
root.mainloop() root.mainloop()

View File

@ -13,13 +13,13 @@ from Tkinter import *
import tkMessageBox, tkColorChooser, tkFont import tkMessageBox, tkColorChooser, tkFont
import string import string
from configHandler import idleConf from idlelib.configHandler import idleConf
from dynOptionMenuWidget import DynOptionMenu from idlelib.dynOptionMenuWidget import DynOptionMenu
from tabbedpages import TabbedPageSet from idlelib.tabbedpages import TabbedPageSet
from keybindingDialog import GetKeysDialog from idlelib.keybindingDialog import GetKeysDialog
from configSectionNameDialog import GetCfgSectionNameDialog from idlelib.configSectionNameDialog import GetCfgSectionNameDialog
from configHelpSourceEdit import GetHelpSourceDialog from idlelib.configHelpSourceEdit import GetHelpSourceDialog
import macosxSupport from idlelib import macosxSupport
class ConfigDialog(Toplevel): class ConfigDialog(Toplevel):
@ -988,16 +988,11 @@ class ConfigDialog(Toplevel):
self.SetThemeType() self.SetThemeType()
##load theme element option menu ##load theme element option menu
themeNames=self.themeElements.keys() themeNames=self.themeElements.keys()
themeNames.sort(self.__ThemeNameIndexCompare) themeNames.sort(key=lambda x: self.themeElements[x][1])
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0]) self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
self.PaintThemeSample() self.PaintThemeSample()
self.SetHighlightTarget() self.SetHighlightTarget()
def __ThemeNameIndexCompare(self,a,b):
if self.themeElements[a][1]<self.themeElements[b][1]: return -1
elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
else: return 1
def LoadKeyCfg(self): def LoadKeyCfg(self):
##current keys type radiobutton ##current keys type radiobutton
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default', self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',

View File

@ -20,7 +20,7 @@ configuration problem notification and resolution.
import os import os
import sys import sys
import string import string
import macosxSupport from idlelib import macosxSupport
from ConfigParser import ConfigParser, NoOptionError, NoSectionError from ConfigParser import ConfigParser, NoOptionError, NoSectionError
class InvalidConfigType(Exception): pass class InvalidConfigType(Exception): pass
@ -654,17 +654,9 @@ class IdleConf:
helpPath=value[1].strip() helpPath=value[1].strip()
if menuItem and helpPath: #neither are empty strings if menuItem and helpPath: #neither are empty strings
helpSources.append( (menuItem,helpPath,option) ) helpSources.append( (menuItem,helpPath,option) )
helpSources.sort(self.__helpsort) helpSources.sort(key=lambda x: int(x[2]))
return helpSources return helpSources
def __helpsort(self, h1, h2):
if int(h1[2]) < int(h2[2]):
return -1
elif int(h1[2]) > int(h2[2]):
return 1
else:
return 0
def GetAllExtraHelpSourcesList(self): def GetAllExtraHelpSourcesList(self):
""" """
Returns a list of tuples containing the details of all additional help Returns a list of tuples containing the details of all additional help

View File

@ -132,7 +132,7 @@ class GetKeysDialog(Toplevel):
order is also important: key binding equality depends on it, so order is also important: key binding equality depends on it, so
config-keys.def must use the same ordering. config-keys.def must use the same ordering.
""" """
import macosxSupport from idlelib import macosxSupport
if macosxSupport.runningAsOSXApp(): if macosxSupport.runningAsOSXApp():
self.modifiers = ['Shift', 'Control', 'Option', 'Command'] self.modifiers = ['Shift', 'Control', 'Option', 'Command']
else: else:
@ -167,7 +167,7 @@ class GetKeysDialog(Toplevel):
def GetModifiers(self): def GetModifiers(self):
modList = [variable.get() for variable in self.modifier_vars] modList = [variable.get() for variable in self.modifier_vars]
return filter(None, modList) return [mod for mod in modList if mod]
def ClearKeySeq(self): def ClearKeySeq(self):
self.listKeysFinal.select_clear(0,END) self.listKeysFinal.select_clear(0,END)

View File

@ -51,10 +51,10 @@ def overrideRootMenu(root, flist):
# Due to a (mis-)feature of TkAqua the user will also see an empty Help # Due to a (mis-)feature of TkAqua the user will also see an empty Help
# menu. # menu.
from Tkinter import Menu, Text, Text from Tkinter import Menu, Text, Text
from EditorWindow import prepstr, get_accelerator from idlelib.EditorWindow import prepstr, get_accelerator
import Bindings from idlelib import Bindings
import WindowList from idlelib import WindowList
from MultiCall import MultiCallCreator from idlelib.MultiCall import MultiCallCreator
menubar = Menu(root) menubar = Menu(root)
root.configure(menu=menubar) root.configure(menu=menubar)
@ -77,11 +77,11 @@ def overrideRootMenu(root, flist):
menubar.add_cascade(label='IDLE', menu=menu) menubar.add_cascade(label='IDLE', menu=menu)
def about_dialog(event=None): def about_dialog(event=None):
import aboutDialog from idlelib import aboutDialog
aboutDialog.AboutDialog(root, 'About IDLE') aboutDialog.AboutDialog(root, 'About IDLE')
def config_dialog(event=None): def config_dialog(event=None):
import configDialog from idlelib import configDialog
root.instance_dict = flist.inversedict root.instance_dict = flist.inversedict
configDialog.ConfigDialog(root, 'Settings') configDialog.ConfigDialog(root, 'Settings')

View File

@ -7,13 +7,13 @@ import thread
import threading import threading
import Queue import Queue
import CallTips from idlelib import CallTips
import AutoComplete from idlelib import AutoComplete
import RemoteDebugger from idlelib import RemoteDebugger
import RemoteObjectBrowser from idlelib import RemoteObjectBrowser
import StackViewer from idlelib import StackViewer
import rpc from idlelib import rpc
import __main__ import __main__
@ -118,7 +118,7 @@ def manage_socket(address):
break break
except socket.error, err: except socket.error, err:
print>>sys.__stderr__,"IDLE Subprocess: socket error: "\ print>>sys.__stderr__,"IDLE Subprocess: socket error: "\
+ err[1] + ", retrying...." + err.args[1] + ", retrying...."
else: else:
print>>sys.__stderr__, "IDLE Subprocess: Connection to "\ print>>sys.__stderr__, "IDLE Subprocess: Connection to "\
"IDLE GUI failed, exiting." "IDLE GUI failed, exiting."
@ -133,14 +133,15 @@ def show_socket_error(err, address):
import tkMessageBox import tkMessageBox
root = Tkinter.Tk() root = Tkinter.Tk()
root.withdraw() 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 "\ msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\
"to your personal firewall configuration. It is safe to "\ "to your personal firewall configuration. It is safe to "\
"allow this internal connection because no data is visible on "\ "allow this internal connection because no data is visible on "\
"external ports." % address "external ports." % address
tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root) tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root)
else: else:
tkMessageBox.showerror("IDLE Subprocess Error", "Socket Error: %s" % err[1]) tkMessageBox.showerror("IDLE Subprocess Error",
"Socket Error: %s" % err.args[1])
root.destroy() root.destroy()
def print_exception(): def print_exception():
@ -253,7 +254,7 @@ class MyHandler(rpc.RPCHandler):
sys.stdin = self.console = self.get_remote_proxy("stdin") sys.stdin = self.console = self.get_remote_proxy("stdin")
sys.stdout = self.get_remote_proxy("stdout") sys.stdout = self.get_remote_proxy("stdout")
sys.stderr = self.get_remote_proxy("stderr") sys.stderr = self.get_remote_proxy("stderr")
import IOBinding from idlelib import IOBinding
sys.stdin.encoding = sys.stdout.encoding = \ sys.stdin.encoding = sys.stdout.encoding = \
sys.stderr.encoding = IOBinding.encoding sys.stderr.encoding = IOBinding.encoding
self.interp = self.get_remote_proxy("interp") self.interp = self.get_remote_proxy("interp")