/usr/lib/python2.6/idlelib
NameSizeModeActions
Icons/-0755rm
aboutDialog.py68250644editdlrm
aboutDialog.pyc69370644editdlrm
aboutDialog.pyo69370644editdlrm
AutoComplete.py90610644editdlrm
AutoComplete.pyc79970644editdlrm
AutoComplete.pyo79970644editdlrm
AutoCompleteWindow.py172010644editdlrm
AutoCompleteWindow.pyc125440644editdlrm
AutoCompleteWindow.pyo124810644editdlrm
AutoExpand.py24830644editdlrm
AutoExpand.pyc25750644editdlrm
AutoExpand.pyo25750644editdlrm
Bindings.py35020644editdlrm
Bindings.pyc50620644editdlrm
Bindings.pyo50620644editdlrm
CallTips.py76080644editdlrm
CallTips.pyc102190644editdlrm
CallTips.pyo102190644editdlrm
CallTipWindow.py59240644editdlrm
CallTipWindow.pyc61890644editdlrm
CallTipWindow.pyo61890644editdlrm
ChangeLog563930644editdlrm
ClassBrowser.py63690644editdlrm
ClassBrowser.pyc91600644editdlrm
ClassBrowser.pyo91600644editdlrm
CodeContext.py83470644editdlrm
CodeContext.pyc67130644editdlrm
CodeContext.pyo66670644editdlrm
ColorDelegator.py101500644editdlrm
ColorDelegator.pyc89420644editdlrm
ColorDelegator.pyo89420644editdlrm
config-extensions.def26970644editdlrm
config-highlight.def17400644editdlrm
config-keys.def75170644editdlrm
config-main.def25120644editdlrm
configDialog.py532290644editdlrm
configDialog.pyc448280644editdlrm
configDialog.pyo448280644editdlrm
configHandler.py288030644editdlrm
configHandler.pyc272680644editdlrm
configHandler.pyo272680644editdlrm
configHelpSourceEdit.py66800644editdlrm
configHelpSourceEdit.pyc67310644editdlrm
configHelpSourceEdit.pyo67310644editdlrm
configSectionNameDialog.py37200644editdlrm
configSectionNameDialog.pyc43050644editdlrm
configSectionNameDialog.pyo43050644editdlrm
CREDITS.txt18560644editdlrm
Debugger.py158180644editdlrm
Debugger.pyc169860644editdlrm
Debugger.pyo169860644editdlrm
Delegator.py8310644editdlrm
Delegator.pyc16070644editdlrm
Delegator.pyo16070644editdlrm
dynOptionMenuWidget.py13020644editdlrm
dynOptionMenuWidget.pyc16990644editdlrm
dynOptionMenuWidget.pyo16990644editdlrm
EditorWindow.py597340644editdlrm
EditorWindow.pyc527690644editdlrm
EditorWindow.pyo526660644editdlrm
extend.txt36520644editdlrm
FileList.py36600644editdlrm
FileList.pyc39880644editdlrm
FileList.pyo39530644editdlrm
FormatParagraph.py57340644editdlrm
FormatParagraph.pyc48030644editdlrm
FormatParagraph.pyo48030644editdlrm
GrepDialog.py40520644editdlrm
GrepDialog.pyc50370644editdlrm
GrepDialog.pyo50370644editdlrm
help.txt112230644editdlrm
HISTORY.txt103170644editdlrm
HyperParser.py103100644editdlrm
HyperParser.pyc66200644editdlrm
HyperParser.pyo66200644editdlrm
idle.py6640644editdlrm
idle.pyc5940644editdlrm
idle.pyo5940644editdlrm
idle.pyw6640644editdlrm
IdleHistory.py31450644editdlrm
IdleHistory.pyc32130644editdlrm
IdleHistory.pyo32130644editdlrm
idlever.py230644editdlrm
idlever.pyc1570644editdlrm
idlever.pyo1570644editdlrm
IOBinding.py209720644editdlrm
IOBinding.pyc177130644editdlrm
IOBinding.pyo177130644editdlrm
keybindingDialog.py124070644editdlrm
keybindingDialog.pyc123840644editdlrm
keybindingDialog.pyo123840644editdlrm
macosxSupport.py47240644editdlrm
macosxSupport.pyc48640644editdlrm
macosxSupport.pyo48640644editdlrm
MultiCall.py174700644editdlrm
MultiCall.pyc161420644editdlrm
MultiCall.pyo160660644editdlrm
MultiStatusBar.py7890644editdlrm
MultiStatusBar.pyc15380644editdlrm
MultiStatusBar.pyo15380644editdlrm
NEWS.txt271650644editdlrm
ObjectBrowser.py41560644editdlrm
ObjectBrowser.pyc66910644editdlrm
ObjectBrowser.pyo66910644editdlrm
OutputWindow.py43920644editdlrm
OutputWindow.pyc49900644editdlrm
OutputWindow.pyo49900644editdlrm
ParenMatch.py66270644editdlrm
ParenMatch.pyc69730644editdlrm
ParenMatch.pyo69730644editdlrm
PathBrowser.py26460644editdlrm
PathBrowser.pyc41350644editdlrm
PathBrowser.pyo41350644editdlrm
Percolator.py26160644editdlrm
Percolator.pyc36340644editdlrm
Percolator.pyo34400644editdlrm
PyParse.py195100644editdlrm
PyParse.pyc101790644editdlrm
PyParse.pyo97110644editdlrm
PyShell.py519090644editdlrm
PyShell.pyc464940644editdlrm
PyShell.pyo463930644editdlrm
README.txt26230644editdlrm
RemoteDebugger.py116600644editdlrm
RemoteDebugger.pyc162900644editdlrm
RemoteDebugger.pyo161350644editdlrm
RemoteObjectBrowser.py9420644editdlrm
RemoteObjectBrowser.pyc21470644editdlrm
RemoteObjectBrowser.pyo21470644editdlrm
ReplaceDialog.py51340644editdlrm
ReplaceDialog.pyc59540644editdlrm
ReplaceDialog.pyo59540644editdlrm
rpc.py202150644editdlrm
rpc.pyc218190644editdlrm
rpc.pyo217090644editdlrm
run.py113370644editdlrm
run.pyc121640644editdlrm
run.pyo121640644editdlrm
ScriptBinding.py77830644editdlrm
ScriptBinding.pyc75850644editdlrm
ScriptBinding.pyo75850644editdlrm
ScrolledList.py39950644editdlrm
ScrolledList.pyc61470644editdlrm
ScrolledList.pyo61470644editdlrm
SearchDialog.py20400644editdlrm
SearchDialog.pyc30060644editdlrm
SearchDialog.pyo30060644editdlrm
SearchDialogBase.py43850644editdlrm
SearchDialogBase.pyc54920644editdlrm
SearchDialogBase.pyo54920644editdlrm
SearchEngine.py67310644editdlrm
SearchEngine.pyc72150644editdlrm
SearchEngine.pyo72150644editdlrm
StackViewer.py38570644editdlrm
StackViewer.pyc59160644editdlrm
StackViewer.pyo59160644editdlrm
tabbedpages.py181880644editdlrm
tabbedpages.pyc180850644editdlrm
tabbedpages.pyo180850644editdlrm
textView.py32460644editdlrm
textView.pyc39650644editdlrm
textView.pyo39650644editdlrm
TODO.txt84780644editdlrm
ToolTip.py27360644editdlrm
ToolTip.pyc41260644editdlrm
ToolTip.pyo41260644editdlrm
TreeWidget.py152370644editdlrm
TreeWidget.pyc179060644editdlrm
TreeWidget.pyo179060644editdlrm
UndoDelegator.py102770644editdlrm
UndoDelegator.pyc125500644editdlrm
UndoDelegator.pyo125500644editdlrm
WidgetRedirector.py44760644editdlrm
WidgetRedirector.pyc53380644editdlrm
WidgetRedirector.pyo53380644editdlrm
WindowList.py24730644editdlrm
WindowList.pyc36240644editdlrm
WindowList.pyo36240644editdlrm
ZoomHeight.py13070644editdlrm
ZoomHeight.pyc16510644editdlrm
ZoomHeight.pyo16510644editdlrm
__init__.py370644editdlrm
__init__.pyc1250644editdlrm
__init__.pyo1250644editdlrm
Edit: /usr/lib/python2.6/idlelib/ScriptBinding.py (7783B)
"""Extension to execute code outside the Python shell window. This adds the following commands: - Check module does a full syntax check of the current module. It also runs the tabnanny to catch any inconsistent tabs. - Run module executes the module's code in the __main__ namespace. The window must have been saved previously. The module is added to sys.modules, and is also added to the __main__ namespace. XXX GvR Redesign this interface (yet again) as follows: - Present a dialog box for ``Run Module'' - Allow specify command line arguments in the dialog box """ import os import re import string import tabnanny import tokenize import tkMessageBox from idlelib import PyShell from idlelib.configHandler import idleConf IDENTCHARS = string.ascii_letters + string.digits + "_" indent_message = """Error: Inconsistent indentation detected! 1) Your indentation is outright incorrect (easy to fix), OR 2) Your indentation mixes tabs and spaces. To fix case 2, change all tabs to spaces by using Edit->Select All followed \ by Format->Untabify Region and specify the number of columns used by each tab. """ class ScriptBinding: menudefs = [ ('run', [None, ('Check Module', '<>'), ('Run Module', '<>'), ]), ] def __init__(self, editwin): self.editwin = editwin # Provide instance variables referenced by Debugger # XXX This should be done differently self.flist = self.editwin.flist self.root = self.editwin.root def check_module_event(self, event): filename = self.getfilename() if not filename: return 'break' if not self.checksyntax(filename): return 'break' if not self.tabnanny(filename): return 'break' def tabnanny(self, filename): f = open(filename, 'r') try: tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) except tokenize.TokenError, msg: msgtxt, (lineno, start) = msg self.editwin.gotoline(lineno) self.errorbox("Tabnanny Tokenizing Error", "Token Error: %s" % msgtxt) return False except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return False return True def checksyntax(self, filename): self.shell = shell = self.flist.open_shell() saved_stream = shell.get_warning_stream() shell.set_warning_stream(shell.stderr) f = open(filename, 'r') source = f.read() f.close() if '\r' in source: source = re.sub(r"\r\n", "\n", source) source = re.sub(r"\r", "\n", source) if source and source[-1] != '\n': source = source + '\n' text = self.editwin.text text.tag_remove("ERROR", "1.0", "end") try: try: # If successful, return the compiled code return compile(source, filename, "exec") except (SyntaxError, OverflowError), err: try: msg, (errorfilename, lineno, offset, line) = err if not errorfilename: err.args = msg, (filename, lineno, offset, line) err.filename = filename self.colorize_syntax_error(msg, lineno, offset) except: msg = "*** " + str(err) self.errorbox("Syntax error", "There's an error in your program:\n" + msg) return False finally: shell.set_warning_stream(saved_stream) def colorize_syntax_error(self, msg, lineno, offset): text = self.editwin.text pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1) text.tag_add("ERROR", pos) char = text.get(pos) if char and char in IDENTCHARS: text.tag_add("ERROR", pos + " wordstart", pos) if '\n' == text.get(pos): # error at line end text.mark_set("insert", pos) else: text.mark_set("insert", pos + "+1c") text.see(pos) def run_module_event(self, event): """Run the module after setting up the environment. First check the syntax. If OK, make sure the shell is active and then transfer the arguments, set the run environment's working directory to the directory of the module being executed and also add that directory to its sys.path if not already included. """ filename = self.getfilename() if not filename: return 'break' code = self.checksyntax(filename) if not code: return 'break' if not self.tabnanny(filename): return 'break' shell = self.shell interp = shell.interp if PyShell.use_subprocess: shell.restart_shell() dirname = os.path.dirname(filename) # XXX Too often this discards arguments the user just set... interp.runcommand("""if 1: _filename = %r import sys as _sys from os.path import basename as _basename if (not _sys.argv or _basename(_sys.argv[0]) != _basename(_filename)): _sys.argv = [_filename] import os as _os _os.chdir(%r) del _filename, _sys, _basename, _os \n""" % (filename, dirname)) interp.prepend_syspath(filename) # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still # go to __stderr__. With subprocess, they go to the shell. # Need to change streams in PyShell.ModifiedInterpreter. interp.runcode(code) return 'break' def getfilename(self): """Get source filename. If not saved, offer to save (or create) file The debugger requires a source file. Make sure there is one, and that the current version of the source buffer has been saved. If the user declines to save or cancels the Save As dialog, return None. If the user has configured IDLE for Autosave, the file will be silently saved if it already exists and is dirty. """ filename = self.editwin.io.filename if not self.editwin.get_saved(): autosave = idleConf.GetOption('main', 'General', 'autosave', type='bool') if autosave and filename: self.editwin.io.save(None) else: reply = self.ask_save_dialog() self.editwin.text.focus_set() if reply == "ok": self.editwin.io.save(None) filename = self.editwin.io.filename else: filename = None return filename def ask_save_dialog(self): msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?" mb = tkMessageBox.Message(title="Save Before Run or Check", message=msg, icon=tkMessageBox.QUESTION, type=tkMessageBox.OKCANCEL, default=tkMessageBox.OK, master=self.editwin.text) return mb.show() def errorbox(self, title, message): # XXX This should really be a function of EditorWindow... tkMessageBox.showerror(title, message, master=self.editwin.text) self.editwin.text.focus_set()