Viewing File: /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/PyShell.cpython-35.opt-2.pyc



]@s_ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZyddlTWn2ek
reddejejdYnXddljZddlmZmZdd	lmZdd
lmZddl m!Z!ddl"m#Z#dd
l$m%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*dZ+dZ,eja-ddl.Z.dddZ/ddddZ0da1ddZ2e2ddej3ddZ4e4e_3GdddeZ5GdddeZ6Gd d!d!eZ7Gd"d#d#e!Z8Gd$d%d%e'j9Z:Gd&d'd'e
Z;Gd(d)d)e#Z<Gd*d+d+e
j=Z>Gd,d-d-e>Z?Gd.d/d/e>Z@d0d1ZAd2ZBd3d4ZCeDd5krQejEd5ejEd)<eCe2d6dS)7N)InteractiveInterpreter)python_versionsystem)*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **file)EditorWindow
fixwordbreaks)FileList)ColorDelegator)
UndoDelegator)OutputWindow)idleConf)rpc)Debugger)RemoteDebugger)
macosxSupportz	127.0.0.1cCssd}|d||f7}|dkr8tj||}|j}|rX|d|7}|d|j|f7}|S)Nz!
Warning (from warnings module):
z  File "%s", line %s
z    %s
z%s: %s
)	linecachegetlinestrip__name__)messagecategoryfilenamelinenolinesr,/opt/alt/python35/lib64/python3.5/PyShell.pyidle_formatwarning0srcCsd|dkrt}y3|jt||||d||jdWnttfk
r_YnXdS)Nrz>>> )warning_streamwriterAttributeErrorOSError)rrrrrrrrridle_showwarning=s	r$cCsF|r'tdkrBtjatt_ntdk	rBtt_dadS)N)_warnings_showwarningwarningsshowwarningr$)capturerrrcapture_warningsPs		r)TcCsxtj}i}xKt|D]=}|dd|dddkr|j|||<qW|||j|dS)Nrz<>)rcachelistpopupdate)rZorig_checkcacher+savekeyrrrextended_linecache_checkcache_s	$
r1c@seZdZddZd&d'd(d)d*d+gZdddZddZdddZdddZddZ	ddZ
ddZd d!Zd"d#Z
d$d%ZdS),PyShellEditorWindowcGsg|_tj|||jjd|j|jjd|j|jjd|jjt	j
jtj
d|_|jj|dd}|jj||jjr|j|jdS)Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstcSs|j|dS)N)restore_file_breaks)Zold_hookselfrrrfilename_changed_hooks
z;PyShellEditorWindow.__init__.<locals>.filename_changed_hook)breakpointsr__init__textbindset_breakpoint_hereclear_breakpoint_hereflist
open_shellospathjoinrZ
GetUserCfgDirbreakpointPathioZfilename_change_hookZset_filename_change_hookrr3color_breakpoint_text)r4argsr5rrrr7ys		
zPyShellEditorWindow.__init__Cut<<cut>>rmenu_check_cutCopy<<copy>>rmenu_check_copyPaste	<<paste>>rmenu_check_pasteNSet Breakpoint<<set-breakpoint-here>>Clear Breakpoint<<clear-breakpoint-here>>TcCsc|jdkrdS|r:tj}tj|d}nddddi}|jjd|dS)Nbreak
foreground
backgroundBREAK)rBrCurrentThemeGetHighlightr8Z
tag_config)r4ZcolorthemeZcfgrrrrCsz)PyShellEditorWindow.color_breakpoint_textcCs|j}|jj}|jdd|d|dy|jj|Wn"tk
rl|jj|YnXy&|jj	j
j}|j||WnYnXdS)NrVz%d.0r)
r8rBrtag_addr6index
ValueErrorappendr<pyshellinterpdebuggerr:)r4rr8rdebugrrrset_breakpoints	
z"PyShellEditorWindow.set_breakpointcCsU|j}|jj}|s)|jdStt|jd}|j|dS)Ninsert)r8rBrbellintfloatr[rb)r4eventr8rrrrrr:s	
z'PyShellEditorWindow.set_breakpoint_herecCs|j}|jj}|s)|jdStt|jd}y|jj|WnYnX|j	dddy&|j
jjj
}|j||WnYnXdS)NrcrVzinsert linestartzinsert lineend +1char)r8rBrrdrerfr[r6remove
tag_remover<r^r_r`r;)r4rgr8rrrarrrr;s"	
z)PyShellEditorWindow.clear_breakpoint_herec	Cs|jr||j}|jj}|s2|jdSg|_|jddty#|jjj	j
}|j|WnYnXdS)NrVz1.0)r6r8rBrrdriZENDr<r^r_r`clear_file_breaks)r4r8rrarrrrjs		
	z%PyShellEditorWindow.clear_file_breaksc Cs[|j}|jj}y,t|jd}|j}WdQRXWntk
r[g}YnXyt|jdp}x.|D]&}|j|ds{|j|q{W|j	|j}|r|j|dt
|dWdQRXWnotk
rV}zOt|jddsDd|j_
tjdd	d
dt
|d|jWYdd}~XnXdS)
Nrw=
breakpoint_error_displayedFTtitlez
IDLE Errorrz$Unable to update breakpoint list:
%sparent)r6rBropenrA	readlinesr#
startswithr!update_breakpointsstrgetattrrootrotkMessageBox	showerrorr8)r4ZbreaksrfplinesZnew_filererrrrrstore_file_breakss.	


	*
z%PyShellEditorWindow.store_file_breakscCs|jj|jdkr dS|jj}|dkr<dStjj|jrt|jd}|j	}WdQRXx_|D]W}|j
|drt|t|dd}x|D]}|j
|qWqWdS)Nrkrmr)r8r.rBrr>r?isfilerArrrsrtevallenrb)r4rr{r|rZbreakpoint_linenumbersZbreakpoint_linenumberrrrr3s

 
z'PyShellEditorWindow.restore_file_breakscCs4|j}|jd}|j|}||_dS)NrV)r8Z
tag_rangesranges_to_linenumbersr6)r4r8rangesZlinenumber_listrrrrus	z&PyShellEditorWindow.update_breakpointscCsg}xtdt|dD]f}tt||j}tt||dj}x'||kr|j||d7}q^WqW|S)Nrr)rangerrerfstringr])r4rr|r[rendrrrrs
z)PyShellEditorWindow.ranges_to_linenumberscCs|jtj|dS)N)rjr_close)r4rrrr-s
zPyShellEditorWindow._close)rErFrG)rHrIrJ)rKrLrM)NNN)rNrON)rPrQN)r
__module____qualname__r7Zrmenu_specsrCrbr:r;rjr~r3rurrrrrrr2vs"		*r2c@s+eZdZeZdZdddZdS)PyShellFileListNcCsN|jr|jjjn+t||_|jrG|jjsGdS|jS)N)r^topwakeupPyShellbegin)r4rgrrrr=<s		zPyShellFileList.open_shell)rrrr2rr^r=rrrrr3src@s@eZdZddZddZddZddZd	S)
ModifiedColorDelegatorcCstj||jdS)N)rr7LoadTagDefs)r4rrrr7Js
zModifiedColorDelegator.__init__cCs7|jddd|jdddtj|dS)NZTODOz1.0iomarkZSYNC)rirZrrecolorize_main)r4rrrrNsz&ModifiedColorDelegator.recolorize_maincCsutj|tj}|jjdddddidtj|ddtj|ddtj|didS)NstdinrUrSstdoutstderrconsole)rrrrWtagdefsr.rX)r4rYrrrrSs
	z"ModifiedColorDelegator.LoadTagDefscCs+x$|jD]}|j|ddq
WdS)Nrr)rri)r4tagrrrremovecolors]sz#ModifiedColorDelegator.removecolorsN)rrrr7rrrrrrrrGs
rc@s.eZdZdddZdddZdS)ModifiedUndoDelegatorNc
Cs\y-|jj|ddr,|jjdSWntk
rAYnXtj||||dS)N<r)delegatecomparerdTclErrorrrc)r4r[charstagsrrrrces

zModifiedUndoDelegator.insertcCsYy-|jj|ddr,|jjdSWntk
rAYnXtj|||dS)Nrr)rrrdrrdelete)r4Zindex1Zindex2rrrrns

zModifiedUndoDelegator.delete)rrrrcrrrrrrbs	rc@seZdZddZdS)MyRPCClientcCs
tdS)N)EOFError)r4rrr
handle_EOFzszMyRPCClient.handle_EOFN)rrrrrrrrrxsrc@seZdZddZdZdZdZddZddZdd	Z	d
ddd
Z
ddZddZddZ
ddZd
ddZdZddZdZddZddZddZd d!Zd"Zd#d$Zdd%d&Zd'd(Zd)d*Zd+d,Zdd-d.Zd/d0Zd1d2Zd3d4Z d5d6Z!d7d8Z"d9d:Z#d;d<Z$d=d>Z%dS)?ModifiedInterpretercCsf||_tjdj}tj|d|d|_d|_d|_t	|_
|jjj
|_dS)N__main__localsF)	tkconsolesysmodules__dict__rr7save_warnings_filters
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)r4rrrrrr7s					zModifiedInterpreter.__init__NcCs7|jdkr|j|_tj|j|_dS)N)rbuild_subprocess_arglist
subprocessPopen
rpcsubproc)r4rrrspawn_subprocesssz$ModifiedInterpreter.spawn_subprocesscCsddtjD}tjddddddd	}td
krSd|f}n
d|f}tjg|d
|t|jgS)NcSsg|]}d|qS)z-Wr).0rrrr
<listcomp>s	z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>mainGeneralzdelete-exitfuncdefaultFtypeboolzidlelib.PyShellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)z-c)rwarnoptionsr	GetOptionr
executablervr)r4rlZ	del_exitfZcommandrrrrs
z,ModifiedInterpreter.build_subprocess_arglistcCst|jf}xXtdD]<}tj|yt||_PWqtk
rWYqXqW|jdS|jj	j
d|_tdkr|jj	jt
jt
jd|j|jj	jdy|jjWn#t
jk
r|jdSYnX|jjd|j|jjd|jj|jjd|jj|jjd|jj|jjd	|jj|jjd
t|jjd||jdd
|j|jS)Nrr
rrrrr<rr_with_cwdT)HOSTrrtimesleeprrpccltr#display_port_binding_errorlistening_sockgetsocknamer
setsockoptsocket
SOL_SOCKETSO_REUSEADDRr
settimeoutaccepttimeoutdisplay_no_subprocess_errorregisterrrrrr<r
transfer_pathpoll_subprocess)r4addrirrrstart_subprocesss>

	



	
z$ModifiedInterpreter.start_subprocessFrTcCs|jr|jSd|_|j}|rJytj|jWnYnX|jj|j|j}|j}d|_|j	y|jj
Wn#tjk
r|j
dSYnX|jd||j|jjddd|r|nd}t|jt|dd	d
}|jdj|||jjdd|jjdd
|st|j|rtj|j|j|j|jj_d|_|jS)NTFrrzend-1cz	RESTART: ZShellrrmz
{0} {1} {0}restartleft) rrgetdebuggerrZclose_subprocess_debuggercloseterminate_subprocessr	executingrrrrrr
stop_readliner8rrewidthrr!formatmark_setmark_gravity
showpromptZrestart_subprocess_debuggerload_breakpointsrrrr)r4rrrarZ
was_executingrZhalfbarrrrrestart_subprocesssH		

			

	
%

	z&ModifiedInterpreter.restart_subprocesscCs|jjddfidS)NexecZinterrupt_the_server)rZ
remotecall)r4rrrZ__request_interruptsz'ModifiedInterpreter.__request_interruptcCstjd|jjdS)Ntarget)	threadingThread'_ModifiedInterpreter__request_interruptstart)r4rrrinterrupt_subprocesssz(ModifiedInterpreter.interrupt_subprocesscCs|jdk	r%|jjj|jy|jjjWntk
rMYnXy|jjWntk
rsYnX|jd|j_	d|_dS)NF)
_afteridrr8Zafter_cancelrrrr"rr)r4rrrkill_subprocesss


z#ModifiedInterpreter.kill_subprocesscCsXy|jjWntk
r)dSYn+Xy|jjWntk
rSdSYnXdS)N)rkillr#wait)r4rrrrs
	
z(ModifiedInterpreter.terminate_subprocesscCsC|r"dg}|jtjn	tj}|jd|fdS)NrTzRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)extendrr?
runcommand)r4rr?rrrrs		z!ModifiedInterpreter.transfer_pathcCs|j}|dkrdSy|j|jdd}Wn;tttfk
rr|jjr^dSd}|jYnX|rd|jj	d|_|\}}|jj
}|dkr|dk	r>tt|d|nf|dkr|jj
dr>|jn;|dkr>d}t||dtjt||d|y|jjWntk
rcYnX|jjs|jjj|jj|j|_dS)	Nrg?ZOKrZ	EXCEPTIONz<<toggle-jit-stack-viewer>>ERRORz/PyShell.ModifiedInterpreter: Subprocess ERROR:
)rZpollresponse
active_seqrr#KeyboardInterruptrclosingrresetoutputrprintreprgetvarremote_stack_viewerr
__stderr__endexecutingr"r8afterpollintervalrr)r4ZcltresponsehowZwhatrerrmsgrrrr,s@	
	

z#ModifiedInterpreter.poll_subprocesscCs
||_dS)N)r`)r4r`rrrsetdebuggerTszModifiedInterpreter.setdebuggercCs|jS)N)r`)r4rrrrWszModifiedInterpreter.getdebuggercCs|jjjd|jdS)Ni,)rr8rr)r4rrropen_remote_stack_viewerZs
z,ModifiedInterpreter.open_remote_stack_viewercCsddlm}|jjdddi}|dkrK|jjjdS|j|j|}ddlm	}m
}t|jj}tj
}tj|dd}||d	|d
d}	|	jjddd
d||	jd|}
|
jdS)Nr)RemoteObjectBrowserrZstackviewerr<)ScrolledCanvasTreeNodeZnormalrUbgZhighlightthicknessexpandrfillZboth)r<)idlelibrrremotequeuerrxrdZStubObjectTreeItemZidlelib.TreeWidgetrr
ZToplevelrrWrXframepackZcanvasr)r4rZoiditemrr
rrYrUZscZnoderrrrgsz'ModifiedInterpreter.remote_stack_viewerrcCs#|j|}|j||dS)N)stuffsourceexecfile)r4sourcerrrr
execsourcezszModifiedInterpreter.execsourcecCs|dkr1tj|}|j}WdQRXyt||d}WnXttfk
r|jjtdd|jj	t
j|||jjYnX|j
|dS)NrzB*** Error in script or command!
Traceback (most recent call last):r)tokenizerrreadr
OverflowErrorSyntaxErrorrrrrrshowsyntaxerrorrruncode)r4rrr{coderrrrs
	
zModifiedInterpreter.execfilec
Cs|j|}d|_tjdd|_tjdddtztj|||SWd|jdk	r|jtjdd<d|_XdS)Nractionerrorr)	rZmorer&filtersrfilterwarnings
SyntaxWarningr	runsource)r4rrrrrr&s	zModifiedInterpreter.runsourcecCsSd|j}|jd|_|jd}t|dd||ftj|<|S)Nz<pyshell#%d>rrnr)gidsplitrrr+)r4rrr|rrrrs

#zModifiedInterpreter.stuffsourcecCs|jd|fdS)Na(if 1:
            _filename = %r
            import sys as _sys
            from os.path import dirname as _dirname
            _dir = _dirname(_filename)
            if not _dir in _sys.path:
                _sys.path.insert(0, _dir)
            del _filename, _sys, _dirname, _dir
            
)r)r4rrrrprepend_syspathsz#ModifiedInterpreter.prepend_syspathcCs|j}|j}|jdddtj\}}}t|ddpU|pUd}t|ddpmd}t|d	dpd
}	|	d
kr|d7}|dkrd|	d}
nd|d|	df}
|j||
|j|jd
||j	dS)Nrz1.0rmsgrTz<no detail available>rroffsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
rr8rirexc_inforwZcolorize_syntax_errorrr!r)r4rrr8rvaluetbr*rr+posrrrrs"		

z#ModifiedInterpreter.showsyntaxerrorcCsG|jj|jtj||jjdrC|jjdS)Nz<<toggle-jit-stack-viewer>>)rrchecklinecacher
showtracebackropen_stack_viewer)r4rrrr1s



z!ModifiedInterpreter.showtracebackcCsUtj}xEt|jD]1}|dd|dddkr||=qWdS)Nrz<>r*)rr+r,keys)r4cr0rrrr0s	$z"ModifiedInterpreter.checklinecachecCsV|jjr|jdS|jrB|jjdd|fint||jdS)Nrrrr)rrdisplay_executing_dialogrrrr)r4r rrrrs
	zModifiedInterpreter.runcommandcCs|jjr|jj|j|jdk	rQ|jtjdd<d|_|j}zNyw|jj	|r|j
dk	r|j
jdd|fi|_n,|r|j
||jnt||jWntk
r.|jjs'tjddddd|jjrq*|jnYnytrgtdd	|jj|j|jjn;|jjrd
|j_tdd	|jjn
|jYnXWdtsy|jjWntk
rYnXXdS)NrrzExit?zDo you want to exit altogether?ryesrqz IDLE internal error in runcode()rFr)rrr_rr0rr&r#r`beginexecutingrZ
asyncqueuerrunrr
SystemExitrryZaskyesnor8r1use_subprocessrrrcanceledr")r4r r`rrrrsP

		


	


zModifiedInterpreter.runcodecCs|jjj|S)N)rrr!)r4rrrrr!"szModifiedInterpreter.writecCs tjddd|jjdS)NzPort Binding ErroraAIDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server.  This might be because no networking is installed on this computer.  Run IDLE with the -n command line switch to start without a subprocess and refer to Help/IDLE Help 'Running without a subprocess' for further details.rq)ryrzrr8)r4rrrr&sz.ModifiedInterpreter.display_port_binding_errorcCs tjddd|jjdS)NzSubprocess Startup ErrorzIDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.rq)ryrzrr8)r4rrrr1sz/ModifiedInterpreter.display_no_subprocess_errorcCs tjddd|jjdS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rq)ryrzrr8)r4rrrr59sz,ModifiedInterpreter.display_executing_dialog)&rrrr7rrrrrrrrrrrrrrr`r	rr
rr'rrr&rr)rr1r0rrr!rrr5rrrrrsF
+-

&
1rcs/eZdZdedZeZeZdVdWdXdYdZd[gZ	ddl
mZdddZddZ
dZdZdZdZdZdZddZddZdddZddZddd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Z d1Z!d2d3Z"d4d5Z#d6d7Z$d8d9Z%dd:d;Z&d<d=Z'd>d?Z(d@dAZ)dBdCZ*dDdEZ+ddFdGZ,ddHdIZ-ddJdKZ.dLdMZ/dNdOZ0fdPdQZ1fdRdSZ2fdTdUZ3S)\rzPython z Shellr_Fileedit_Editra_Debugoptions_Optionswindows_Windowhelp_Helpr)HistoryNc	Cstr3|j}|dddkr3|jddt||_|dkrwt}t||jt|}t	j
||ddd|_d|_d|_
|j}|jdd|jd	|j|jd
|j|jd|j|jd|j|jd
|j|jd|j|jd|jtrr|jd|j|jd|jtj|_tj|_tj|_ ddl!m"}t#|d|j$|_t%|d|j$|_t%|d|j$|_t%|d|j$|_&ts0|jt_|jt_|jt_yddl'}|j(|_)Wntj*t_YnX|j+|j|_,d|_-dS)NrrshellShe_llTwrapcharz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>z<<toggle-debugger>>z<<toggle-jit-stack-viewer>>z<<view-restart>>z<<restart-shell>>)	IOBindingrrrr2)rGrH).r:
menu_specsrcrr_Tkr	withdrawrr
r7ZusetabsZindentwidthZcontext_use_ps1r8Z	configurer9enter_callbacklinefeed_callbackcancel_callbackeof_callbackr2toggle_debuggertoggle_jit_stack_viewerview_restart_mark
restart_shellrrsave_stdoutrsave_stderrr
save_stdinrrLPseudoInputFileencodingPseudoOutputFilerpydocZ
plainpagerZpagerrrFhistoryr)r4r<msrxr8rLr_rrrr7Ws\		

				zPyShell.__init__cCstjddS)NZ
shell_onlyT)rZ
GetExtensions)r4rrrget_standard_extension_namessz$PyShell.get_standard_extension_namesFcCs
|adS)N)r )r4streamrrrset_warning_streamszPyShell.set_warning_streamcCstS)N)r )r4rrrget_warning_streamszPyShell.get_warning_streamcCs`|jr0tjddd|j|jdS|jj}|rR|jn
|jdS)NzDon't debug nowz*You can only toggle the debugger when idlerqrR)	rryrzr8set_debugger_indicatorr_rclose_debugger
open_debugger)r4rgdbrrrrUs		


zPyShell.toggle_debuggercCs%|jj}|jd|dS)Nz<<toggle-debugger>>)r_rZsetvar)r4rirrrrfszPyShell.set_debugger_indicatorcCsdS)Nr)r4rgrrrrVszPyShell.toggle_jit_stack_viewercCs|jj}|r{|jjd|j|jjrNtj|jj|j|jj	ddt
_|j|j
dS)Nz[DEBUG OFF]
z>>> )r_rr	rrrZclose_remote_debuggerrrr!rps1rrf)r4rirrrrgs

	
zPyShell.close_debuggercCsq|jjr'tj|jj|}ntj|}|jj||jdt_|j	|j
dS)Nz[DEBUG ON]
>>> )r_rrZstart_remote_debuggerrr	rrrjrrf)r4Zdbg_guirrrrhs
	
zPyShell.open_debuggercCs|jd|_dS)Nr)rr)r4rrrr7s
zPyShell.beginexecutingcCs d|_d|_|jdS)Nr)rr;r)r4rrrrs		zPyShell.endexecutingcCsc|jr:tjddddd|j}|dkr:dS|jd|_d|_tj|S)	NzKill?z7Your program is still running!
 Do you want to kill it?rokrqFcancelT)	rryZaskokcancelr8rr;rrr)r4rrrrrs	
		z
PyShell.closecCsy|jtr|jj|jt_|jt_|j	t_
d|_d|_d|j_
d|_tj|dS)N)rgr:r_rrYrrrZrr[rrr<r^r`rr)r4rrrrs

			zPyShell._closecCsdS)NTr)r4rrrrispythonsourceszPyShell.ispythonsourcecCs|jS)N)shell_title)r4rrrshort_titleszPyShell.short_titlez@Type "copyright", "credits" or "license()" for more information.cCs|jjdd|jtrOd}|jj}|sm|jdSndddd}tjt	_|j
d	t	jt	j|j
|f|jj|jd
dl}d|_dS)NrrcrTFz==== No Subprocess ====

z9WARNING: Running IDLE without a Subprocess is deprecated
z;and will be removed in a later version. See Help/IDLE Help
zfor details.

zPython %s on %s
%s
%srT)r8rrr:r_rrrdisplayhookrr!versionplatform	COPYRIGHTZfocus_forcertkinterZ
_default_root)r4Znosubclientrtrrrrs$

	

	z
PyShell.begincCs'|js
dSd|_|jjdS)NT)reading_stop_readline_flagrquit)r4rrrrs		zPyShell.stop_readlinecCs|j}zd|_|jjWd||_X|jrFd|_dS|jjdd}t|dkrsd}|j|jrd|_t	st
|jrd|_d}|S)NrFrTrzend-1crrn)rvrmainlooprwr8getrrr;r:r	endoffile)r4r/rrrrreadline"s(		
		
				zPyShell.readlinecCsdS)NTr)r4rrrisatty9szPyShell.isattyc
Csy |jjdddrdSWnYnX|jp:|jse|j|jjd|jdSd|_d|_	|jr|jj
r|jjr|jjn
|jj
|jr|jjdS)Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rRrr)r8rrrvrr_r!rr{r;rrrrrrx)r4rgrrrrS<s&

		
	
zPyShell.cancel_callbackcCs|jr|jrdS|jjdddoD|jjdddsKdS|jsk|j|jnd|_d|_|jj	dS)Nrz==rczend-1crrrR)
rrvr8rrrr;r{rrx)r4rgrrrrTRs	

		
zPyShell.eof_callbackcCs@|jr/|jjdd|jjdn
|j|dS)NrcrnrR)rvr8rcseenewline_and_indent_event)r4rgrrrrRas
	
zPyShell.linefeed_callbackcCs|jr|jrdSyK|jjdd}|ra|jjdddra|j||dSWnYnX|jjdddr|jjd	d}|r|jjdd|d
r|j|jj|d|d
|dS|jjd	d}|rI|jjdd
|drI|j|jj|d|d
|dS|jjdd}|r|jj|dddr|j|jj|d
d|n|j|jjdd|dS|jjdddr|jjdd|jjdd}|r/|j	r/|jj
dd|jjdddrX|j|dS|jjdd|jr|jjdd|jj
dn
|j||jjd	dd|jj|jr|jjn
|jdS)Nz	sel.firstzsel.lastz<=rrRrcrziomark linestartrrrzinsert lineendz>=rzinsert linestartzend-1czend-1c linestartrn)rrvr8rzrrecallZ
tag_prevrangeZ
tag_nextrangerrrrrcr~rZZupdate_idletasksrrxrunit)r4rgselprevnextindicesrrrrrQjsX"'"'&
	

	
zPyShell.enter_callbackcCstjdd|}tjdd|}|jd}|jjzC|jjddd|jjdd	|jjd
d}|jj	dr|j
||jjd
d}|jjd|djt
|d
krtjd|djd}tjd|jd}x^|d
dD]L}|j|rg||t
|d}|jjdd|jq8WWd|jjd|jjXdS)Nz^\s*\nrTz\n\s*$rnrz1.0rrczend-1czinsert linestart:rrz	^([ \t]*))resubr(r8Zundo_block_startrirrzrstripendswithrrcrrsearchgrouprtr~Zundo_block_stop)r4rrgr|prefixZorig_base_indentZnew_base_indentrrrrrs*

%zPyShell.recallcCs|jjdd}t|}x.|dkrQ||ddkrQ|d}q$W|dkr|||ddkr||d}x.|dkr||ddkr|d}qW|d|}|jj|dS)Nrzend-1crrz 	rn)r8rzrr_r&)r4rrrrrrs# 
#z
PyShell.runitcCss|jjr|jjSytjWn%tjddd|jdSYnXddlm	}||j
|jdS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)rqr)StackBrowser)r_rrrlast_tracebackryrzr8Zidlelib.StackViewerrrxr<)r4rgrrrrr2s
	
	zPyShell.open_stack_viewercCs$|jjd|jjddS)Nrr)r8r~)r4rgrrrrWszPyShell.view_restart_markcCs|jjdddS)NrT)r_r)r4rgrrrrXszPyShell.restart_shellc	Csl|jyttj}Wnd}YnX|jj||jjdd|j|j	j
dS)NrTrczend-1c)rrvrrjrr!r8rset_line_and_columnrBZ
reset_undo)r4rrrrrs

zPyShell.showpromptcCsz|jjdd}|jr.|jj||jjddkrY|jjdd|jjdd|jdS)Nrzend-1czend-2crn)r8rzr`storercrr)r4rrrrrs	zPyShell.resetoutputcCst|trst|rst|dkrsx't|D]\}}|dkr:Pq:Wtd|||ddyB|jjddtj	|||d}|jjddWnYnX|j
rd|_
tst|S)	Nu￿zUCS-2rz%Non-BMP character not supported in Tkrrightrr)
isinstancervrmax	enumerateUnicodeEncodeErrorr8rr
r!r;r:r)r4rrrrKcountrrrr!s"-			z
PyShell.writecsFy |jjdddrdSWntk
r8dSYnXtjS)Nz	sel.firstrrdisabled)r8rrsuperrG)r4)	__class__rrrGs
	zPyShell.rmenu_check_cutcs)|jjdddrdStjS)Nrcrrr)r8rrrM)r4)rrrrMszPyShell.rmenu_check_paste)rr<)r=r>)rar?)r@rA)rBrC)rDrE)4rrrrrnrrrrrNZidlelib.IdleHistoryrFr7rbrvrr;r{rrwrdrerUrfrVrgrhr7rrrrmrorsrrr|r}rSrTrRrQrrr2rWrXrrr!rGrMrr)rrrAsd	:
	?	rc@sOeZdZdddZeddZeddZdd	ZdS)

PseudoFileNcCs||_||_||_dS)N)rGr	_encoding)r4rGrr]rrrr7"s		zPseudoFile.__init__cCs|jS)N)r)r4rrrr]'szPseudoFile.encodingcCsd|jS)Nz<%s>)r)r4rrrname+szPseudoFile.namecCsdS)NTr)r4rrrr}/szPseudoFile.isatty)rrrr7propertyr]rr}rrrrr src@s(eZdZddZddZdS)r^cCsdS)NTr)r4rrrwritable5szPseudoOutputFile.writablecCst|jrtdt|tk	r^t|tsOtdt|jtj|}|jj	||j
S)Nzwrite to closed filezmust be str, not )closedr\rrvr	TypeErrorr__str__rGr!r)r4rrrrr!8s	zPseudoOutputFile.writeN)rrrrr!rrrrr^3sr^c@sUeZdZdddZddZd
ddZdd	d
ZddZdS)r\NcCs#tj||||d|_dS)NrT)rr7_line_buffer)r4rGrr]rrrr7EszPseudoInputFile.__init__cCsdS)NTr)r4rrrreadableIszPseudoInputFile.readablercCs|jrtd|dkr*d}n(t|tsRtdt|j|j}d|_|dkrx|jj	}|sP||7}qsWn\x6t
||kr|jj	}|sP||7}qW||d|_|d|}|S)Nzread from closed filerzmust be int, not rTrr*)rr\rrerrrrrGr|r)r4sizeresultrrrrrLs,				zPseudoInputFile.readcCs|jrtd|dkr*d}n(t|tsRtdt|j|jpg|jj	}|dkrt
|}|jdd|}|dkr|d}||d|_|d|S)Nzread from closed filerzmust be int, not rrnr*)rr\rrerrrrrGr|rfind)r4rrZeolrrrr|cs		
zPseudoInputFile.readlinecCs|jjdS)N)rGr)r4rrrrsszPseudoInputFile.closer*r*)rrrr7rrr|rrrrrr\Cs
r\cCsG|jdkrCx1dD])}|j|dd|j|dqWdS)NZx11TextEntrySpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)rrr)Z_windowingsystemZ
bind_class)rxclsrrr
fix_x11_pastews
ra
USAGE: idle  [-deins] [-t title] [file]*
       idle  [-dns] [-t title] (-c cmd | -r file) [arg]*
       idle  [-dns] [-t title] - [arg]*

  -h         print this help message and exit
  -n         run IDLE without a subprocess (DEPRECATED,
             see Help/IDLE Help for details)

The following options will override the IDLE 'settings' configuration:

  -e         open an edit window
  -i         open a shell window

The following options imply -i and will open a shell:

  -c cmd     run the command in a shell, or
  -r file    run script from file

  -d         enable the debugger
  -s         run $IDLESTARTUP or $PYTHONSTARTUP before anything else
  -t title   set title of shell window

A default edit window will be bypassed when -c, -r, or - are used.

[arg]* are passed to the command (-c) or script (-r) in sys.argv[1:].

Examples:

idle
        Open an edit window or shell depending on IDLE's configuration.

idle foo.py foobar.py
        Edit the files, also open a shell if configured to start with shell.

idle -est "Baz" foo.py
        Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
        window with the title "Baz".

idle -c "import sys; print(sys.argv)" "foo"
        Open a shell window and run the command, passing "-c" in sys.argv[0]
        and "foo" in sys.argv[1].

idle -d -s -r foo.py "Hello World"
        Open a shell window, run a startup script, enable the debugger, and
        run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
        sys.argv[1].

echo "import sys; print(sys.argv)" | idle - "foobar"
        Open a shell window, run the script piped in, passing '' in sys.argv[0]
        and "foobar" in sys.argv[1].
cstddad}d}d}d}d}d}y)tjtjddd\}}WnRtjk
r}z/td|tfdtjtj	dWYdd}~XnXx*|D]"\}	}
|	dkr|
}d}|	d	krd}d}|	d
krd}|	dkr-tj
jttj	|	dkr?d}|	d
krdtddtjda|	dkr|
}tj
j|rntd|tj	d}|	dkrd}d}|	dkr|
t_d}qW|r
|ddkr
tjj}d}x=tttj
D]&}tj
jtj
|tj
|<q W|r}|ddkr}dg|ddt_n|rdg|t_n|r|g|t_n|r3d}g}x'|D]}
|jtj
j|
qWxs|D]:}tj
j|}|tj
krtj
jd|qWn.tj}|tj
kratj
jd|tjddddd}|p|}|p|}tddatjtj
jtj
jt dt!dkrtj
jd}tj"d |nct#d!krit#d"kr$d#nd$fd%d&d3D}d*d&|D}tj$d|t%tt&tt'ta(t)j*tt(t)j+rtj,d+d,tj,d+d-tj,d+d.|r4|p|s4x:|ddD](}
t(j-|
dkr|j.|
qW|s4t(j/|rut(j0}|sPdSt)j+r~t(j1r~|j2j3n	t(j4}|r|j5|rtj6j7d/ptj6j7d0}
|
rtj
j|
r|j8j9|
|s|rH|j8j:d1tjf|r|j8j;|qw|rw|j8j<||j8j9|n/|rwt)j=t}|rw|j8j:d2|xt(j>rtj?qzWtj@tddS)4NTFrzc:deihnr:st:zError: %s
%srrz-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-tr-rTrrzeditor-on-startuprrZ	classNameZIdleZIconsZWindowszidle.icorg!@g333333!@z.pngz.gifcs/g|]%}tjjd|fqS)z	idle_%d%s)r>r?r@)rr)exticondirrrrs	zmain.<locals>.<listcomp> 0cSsg|]}td|qS)r)Z
PhotoImage)riconfilerrrrs	rz<B2>z<B2-Motion>z<<PasteSelection>>ZIDLESTARTUPZ
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
zprint('%s'))rrr)Ar)r:getoptrargvr"r	usage_msgrexitrr!r>r?rrrnrrrrabspathr]dirnamercgetcwdrrrOrxrPr@__file__rZ
wm_iconbitmapZ	TkVersionZwm_iconphotor	rrr<rZsetupAppZisAquaTkZunbind_classrrrhnewr=dictrlowerr^rhenvironrzr_rrrr)ZtkVersionWarningZinversedictryZdestroy)Zenable_shellZenable_editracmdZscriptZstartupZoptsrDr*oarZpathxrdirZ
edit_startrZ	iconfilesZiconsrGZtkversionwarningr)rrrrs
) 
	


	
$



!



	
	
rrF)Frr>Zos.pathrrrrrrrrBrr rrrrrrtImportErrorrrrZtkinter.messageboxZ
messageboxryZidlelib.EditorWindowrr	Zidlelib.FileListr
Zidlelib.ColorDelegatorrZidlelib.UndoDelegatorrZidlelib.OutputWindowr
Zidlelib.configHandlerrrrrrrrrr r&rr$r%r)
checkcacher1r2rrrZ	RPCClientrrr
TextIOBaserr^r\rrrrrrrrr<module>sz
	
	
	4?
Back to Directory File Manager