Commit 2d7f6a07 authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

Switch to absolute imports to support direct execution of modules. Many

IDLE modules have main() or test() functions which are essential for testing.


M    idlelib/AutoCompleteWindow.py
M    idlelib/UndoDelegator.py
M    idlelib/Bindings.py
M    idlelib/AutoComplete.py
M    idlelib/configHandler.py
M    idlelib/HyperParser.py
M    idlelib/ColorDelegator.py
M    idlelib/ObjectBrowser.py
M    idlelib/ZoomHeight.py
M    idlelib/PyShell.py
M    idlelib/ParenMatch.py
M    idlelib/Debugger.py
M    idlelib/configDialog.py
M    idlelib/StackViewer.py
M    idlelib/ReplaceDialog.py
M    idlelib/ScriptBinding.py
M    idlelib/GrepDialog.py
M    idlelib/EditorWindow.py
M    idlelib/FormatParagraph.py
M    idlelib/OutputWindow.py
M    idlelib/aboutDialog.py
M    idlelib/IdleHistory.py
M    idlelib/PathBrowser.py
M    idlelib/ClassBrowser.py
M    idlelib/CallTips.py
M    idlelib/FileList.py
M    idlelib/idle.py
M    idlelib/CodeContext.py
M    idlelib/SearchDialog.py
M    idlelib/RemoteObjectBrowser.py
M    idlelib/RemoteDebugger.py
M    idlelib/TreeWidget.py
M    idlelib/run.py
M    idlelib/Percolator.py
M    idlelib/macosxSupport.py
parent 86d8b349
......@@ -7,7 +7,7 @@ import os
import sys
import string
from .configHandler import idleConf
from idlelib.configHandler import idleConf
# This string includes all chars that may be in a file name (without a path
# separator)
......@@ -18,8 +18,8 @@ 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 . import AutoCompleteWindow
from .HyperParser import HyperParser
from idlelib import AutoCompleteWindow
from idlelib.HyperParser import HyperParser
import __main__
......
......@@ -2,8 +2,8 @@
An auto-completion window for IDLE, used by the AutoComplete extension
"""
from Tkinter import *
from .MultiCall import MC_SHIFT
from .AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
from idlelib.MultiCall import MC_SHIFT
from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>"
HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>")
......
......@@ -9,7 +9,7 @@ windows.
"""
import sys
from .configHandler import idleConf
from idlelib.configHandler import idleConf
menudefs = [
# underscore prefixes character to underscore
......
......@@ -9,8 +9,8 @@ import re
import sys
import types
from . import CallTipWindow
from .HyperParser import HyperParser
from idlelib import CallTipWindow
from idlelib.HyperParser import HyperParser
import __main__
......
......@@ -14,10 +14,10 @@ import os
import sys
import pyclbr
from . 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:
......
......@@ -13,7 +13,7 @@ import Tkinter
from Tkconstants import TOP, LEFT, X, W, SUNKEN
import re
from sys import maxint as INFINITY
from .configHandler import idleConf
from idlelib.configHandler import idleConf
BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for",
"if", "try", "while", "with"])
......
......@@ -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")
......
......@@ -2,9 +2,9 @@ import os
import bdb
import types
from Tkinter import *
from .WindowList import ListedToplevel
from .ScrolledList import ScrolledList
from . import macosxSupport
from idlelib.WindowList import ListedToplevel
from idlelib.ScrolledList import ScrolledList
from idlelib import macosxSupport
class Idb(bdb.Bdb):
......
......@@ -10,16 +10,16 @@ import tkMessageBox
import traceback
import webbrowser
from .MultiCall import MultiCallCreator
from . import idlever
from . import WindowList
from . import SearchDialog
from . import GrepDialog
from . import ReplaceDialog
from . import PyParse
from .configHandler import idleConf
from . import aboutDialog, textView, configDialog
from . 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
......@@ -42,13 +42,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
from . 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
......@@ -532,11 +532,11 @@ class EditorWindow(object):
return None
head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail)
from . import ClassBrowser
from idlelib import ClassBrowser
ClassBrowser.ClassBrowser(self.flist, base, [head])
def open_path_browser(self, event=None):
from . import PathBrowser
from idlelib import PathBrowser
PathBrowser.PathBrowser(self.flist)
def gotoline(self, lineno):
......
......@@ -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)
......
......@@ -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:
......
......@@ -2,8 +2,8 @@ import os
import fnmatch
import sys
from Tkinter import *
from . 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)
......
......@@ -10,7 +10,7 @@ structure of code, used by extensions to help the user.
import string
import keyword
from . import PyParse
from idlelib import PyParse
class HyperParser:
......
from .configHandler import idleConf
from idlelib.configHandler import idleConf
class History:
......
......@@ -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
......
from Tkinter import *
from .EditorWindow import EditorWindow
from idlelib.EditorWindow import EditorWindow
import re
import tkMessageBox
from . import IOBinding
from idlelib import IOBinding
class OutputWindow(EditorWindow):
......
......@@ -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
......
......@@ -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():
from . import PyShell
from idlelib import PyShell
PathBrowser(PyShell.flist)
if sys.stdin is sys.__stdin__:
mainloop()
......
from .WidgetRedirector import WidgetRedirector
from .Delegator import Delegator
from idlelib.WidgetRedirector import WidgetRedirector
from idlelib.Delegator import Delegator
class Percolator:
......
......@@ -18,21 +18,21 @@ try:
from Tkinter import *
except ImportError:
print("** IDLE can't import Tkinter. " \
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
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
from . import idlever
from . import rpc
from . import Debugger
from . import RemoteDebugger
from . import macosxSupport
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
LOCALHOST = '127.0.0.1'
......@@ -541,13 +541,13 @@ class ModifiedInterpreter(InteractiveInterpreter):
return
def remote_stack_viewer(self):
from . 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']
......@@ -589,7 +589,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
# at the moment, InteractiveInterpreter expects str
assert isinstance(source, str)
#if isinstance(source, str):
# from . import IOBinding
# from idlelib import IOBinding
# try:
# source = source.encode(IOBinding.encoding)
# except UnicodeError:
......@@ -782,7 +782,7 @@ class PyShell(OutputWindow):
# New classes
from .IdleHistory import History
from idlelib.IdleHistory import History
def __init__(self, flist=None):
if use_subprocess:
......@@ -821,7 +821,7 @@ class PyShell(OutputWindow):
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
self.save_stdin = sys.stdin
from . 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)
......@@ -992,7 +992,7 @@ class PyShell(OutputWindow):
if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C
line = "\n"
if isinstance(line, str):
from . import IOBinding
from idlelib import IOBinding
try:
line = line.encode(IOBinding.encoding)
except UnicodeError:
......@@ -1180,7 +1180,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):
......
......@@ -22,8 +22,8 @@ barrier, in particular frame and traceback objects.
import sys
import types
from . import rpc
from . import Debugger
from idlelib import rpc
from idlelib import Debugger
debugging = 0
......
from . import rpc
from idlelib import rpc
def remote_object_tree_item(item):
wrapper = WrappedObjectTreeItem(item)
......
from Tkinter import *
from . import SearchEngine
from .SearchDialogBase import SearchDialogBase
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
def replace(text):
root = text._root()
......
......@@ -23,10 +23,10 @@ import string
import tabnanny
import tokenize
import tkMessageBox
from .EditorWindow import EditorWindow
from . import PyShell
from idlelib.EditorWindow import EditorWindow
from idlelib import PyShell
from .configHandler import idleConf
from idlelib.configHandler import idleConf
indent_message = """Error: Inconsistent indentation detected!
......
from Tkinter import *
from . import SearchEngine
from .SearchDialogBase import SearchDialogBase
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
def _setup(text):
root = text._root()
......
......@@ -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:
......
......@@ -19,8 +19,8 @@ import sys
from Tkinter import *
import imp
from . import ZoomHeight
from .configHandler import idleConf
from idlelib import ZoomHeight
from idlelib.configHandler import idleConf
ICONDIR = "Icons"
......@@ -453,7 +453,7 @@ class ScrolledCanvas:
# Testing functions
def test():
from . import PyShell
from idlelib import PyShell
root = Toplevel(PyShell.root)
root.configure(bd=0, bg="yellow")
root.focus_set()
......
......@@ -2,7 +2,7 @@ import sys
import string
from Tkinter import *
from .Delegator import Delegator
from idlelib.Delegator import Delegator
#$ event <<redo>>
#$ win <Control-y>
......@@ -338,7 +338,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()
......
......@@ -3,7 +3,7 @@
import re
import sys
from . import macosxSupport
from idlelib import macosxSupport
class ZoomHeight:
......
......@@ -5,8 +5,8 @@
from Tkinter import *
import os
from . import textView
from . import idlever
from idlelib import textView
from idlelib import idlever
class AboutDialog(Toplevel):
"""Modal about dialog for idle
......@@ -158,7 +158,7 @@ if __name__ == '__main__':
# test the dialog
root = Tk()
def run():
from . import aboutDialog
from idlelib import aboutDialog
aboutDialog.AboutDialog(root, 'About')
Button(root, text='Dialog', command=run).pack()
root.mainloop()
......@@ -13,12 +13,12 @@ from Tkinter import *
import tkMessageBox, tkColorChooser, tkFont
import copy
from .configHandler import idleConf
from .dynOptionMenuWidget import DynOptionMenu
from .tabpage import TabPageSet
from .keybindingDialog import GetKeysDialog
from .configSectionNameDialog import GetCfgSectionNameDialog
from .configHelpSourceEdit import GetHelpSourceDialog
from idlelib.configHandler import idleConf
from idlelib.dynOptionMenuWidget import DynOptionMenu
from idlelib.tabpage import TabPageSet
from idlelib.keybindingDialog import GetKeysDialog
from idlelib.configSectionNameDialog import GetCfgSectionNameDialog
from idlelib.configHelpSourceEdit import GetHelpSourceDialog
class ConfigDialog(Toplevel):
......
......@@ -20,8 +20,8 @@ configuration problem notification and resolution.
import os
import sys
from . import macosxSupport
from .ConfigParser import ConfigParser, NoOptionError, NoSectionError
from idlelib import macosxSupport
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
......
try:
import idlelib.PyShell
import idlelib, idlelib.PyShell
except ImportError:
# IDLE is not installed, but maybe PyShell is on sys.path:
print("*** idle.py import error! Trying alternate approach....")
try:
from . import PyShell
import PyShell
except ImportError:
raise
else:
......
......@@ -47,10 +47,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
from . import Bindings
from . 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)
......@@ -73,11 +73,11 @@ def overrideRootMenu(root, flist):
menubar.add_cascade(label='IDLE', menu=menu)
def about_dialog(event=None):
from . import aboutDialog
from idlelib import aboutDialog
aboutDialog.AboutDialog(root, 'About IDLE')
def config_dialog(event=None):
from . import configDialog
from idlelib import configDialog
configDialog.ConfigDialog(root, 'Settings')
......
......@@ -8,13 +8,13 @@ import thread
import threading
import Queue
from . import CallTips
from . import AutoComplete
from idlelib import CallTips
from idlelib import AutoComplete
from . import RemoteDebugger
from . import RemoteObjectBrowser
from . import StackViewer
from . import rpc
from idlelib import RemoteDebugger
from idlelib import RemoteObjectBrowser
from idlelib import StackViewer
from idlelib import rpc
import __main__
......@@ -245,7 +245,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")
from . import IOBinding
from idlelib import IOBinding
sys.stdin.encoding = sys.stdout.encoding = \
sys.stderr.encoding = IOBinding.encoding
self.interp = self.get_remote_proxy("interp")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment