Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/idlelib/IOBinding.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Tddl
m
Z
ddlmZyddlm
Z
Wnek
r�dZ
nXy#ddlZejejd�Wneejfk
rnXej�ZdZejd	kr]y!ej�d
Zeje�Wnek
rYnXn�yDejej�Zeekp�edkr�dZneje�Wnveeefk
ryBej�d
Zeekp�dkr�Zneje�Wneefk
rnXnXej �Zej!d�Z"de
fd
��YZ#d�Z$dfd��YZ%d�Z&e'dkr�ddl(m)Z)e)e&�ndS(i�N(t*(tSimpleDialog(tidleConf(tBOM_UTF8sttasciitwin32is%^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)tEncodingMessagecBs)eZdZd�Zd�Zd�ZRS(s3Inform user that an encoding declaration is needed.c
Cs�t|_t|�|_}|jd|j�|jd|j�|jd|j�|j	d�|j
d�||_t|dd�}|j
dtdt�t|d	d
�}|jdd|�|j
dtdtd
t�t|dd|�}|j
dtdt�t|�}|j
dtd
t�d|_|_t|ddddd|j�}|j
dtd
tdd�t|ddd|j�}	|	j
dtd
tdd�|j|�dS(Ns<Return>s<Escape>tWM_DELETE_WINDOWsI/O Warningttexts:Non-ASCII found, yet no encoding declared. Add a line liketsidetanchortfonttcourieris# -*- coding: %s -*-tfills`to your file
Choose OK to save this file as %s
Edit your general options to silence this warningtOktdefaulttactivetcommandtexpandisEdit my file(tFalsetshould_edittTopleveltroottbindtreturn_eventtdo_oktprotocoltwm_delete_windowtwm_titletwm_iconnamettoptLabeltpacktTOPtWtEntrytinserttXtFrameRtcanceltButtontLEFTtBOTHtdo_editt_set_transient(
tselftmastertencRtl1tl2tl3tbuttonstb1tb2((s'/sys/lib/python2.7/idlelib/IOBinding.pyt__init__Ns6	

			
cCs|jd�dS(Ni(tdone(R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyRtscCs|jd�dS(Ni(R8(R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyR,ws(t__name__t
__module__t__doc__R7RR,(((s'/sys/lib/python2.7/idlelib/IOBinding.pyRLs	&	cCs�|jdd�d }x1|D]%}tj|�}|dk	rPqqWdS|jd�}ddl}y|j|�Wntk
r�td|�nX|S(szReturn the encoding declaration according to PEP 263.

    Raise LookupError if the encoding is declared but unknown.
    s
iii�NsUnknown encoding (tsplitt	coding_retmatchtNonetgrouptcodecstlookuptLookupError(tstrtlsttlineR>tnameRA((s'/sys/lib/python2.7/idlelib/IOBinding.pytcoding_speczs

t	IOBindingcBs"eZd�Zd�Zd�Zd�Zd�ZdZd�Z	dZ
dZd�Zddd�Z
dZeje�ZejZd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�ZdZdZ d d!d"gZ!d�Z"dd�Z#d�Z$d�Z%RS(#cCs�||_|j|_|jjd|j�|_|jjd|j�|_|jjd|j�|_|jjd|j	�|_
d|_|jjd|j
�|_dS(Ns<<open-window-from-file>>s<<save-window>>s<<save-window-as-file>>s<<save-copy-of-window-as-file>>s<<print-window>>(teditwinR	Rtopent_IOBinding__id_opentsavet_IOBinding__id_savetsave_ast_IOBinding__id_saveastsave_a_copyt_IOBinding__id_savecopyR?tfileencodingtprint_windowt_IOBinding__id_print(R.RJ((s'/sys/lib/python2.7/idlelib/IOBinding.pyR7�s		cCs�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�d|_d|_d|_	dS(Ns<<open-window-from-file>>s<<save-window>>s<<save-window-as-file>>s<<save-copy-of-window-as-file>>s<<print-window>>(
R	tunbindRLRNRPRRRUR?RJtfilename_change_hook(R.((s'/sys/lib/python2.7/idlelib/IOBinding.pytclose�s		cCs
|jj�S(N(RJt	get_saved(R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyRY�scCs|jj|�dS(N(RJt	set_saved(R.tflag((s'/sys/lib/python2.7/idlelib/IOBinding.pyRZ�scCs|jj�dS(N(RJt
reset_undo(R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyR\�scCs
||_dS(N(RW(R.thook((s'/sys/lib/python2.7/idlelib/IOBinding.pytset_filename_change_hook�scCsf|r-tjj|�r-d|_||_n5||_d|_|jd�|jrb|j�ndS(Ni(tostpathtisdirR?tfilenametdirnameRZRW(R.Rb((s'/sys/lib/python2.7/idlelib/IOBinding.pytset_filename�s			
	cCs%|jj}|r�|s'|j�}n|}|r�|jr~t|jdd�r~|jr~|j�r~|j||j�q�|j|�n|j	r�|j	j
�ndS|j�r�j�}|dkr�j	j
�dSn|s�j�}n|}|r|j|�n
|j	j
�dS(NtinterptbreakR((RJtflisttaskopenfiletgetattrR?RbRYRKtloadfileR	t	focus_sett	maybesave(R.teventteditFileRgRbtreply((s'/sys/lib/python2.7/idlelib/IOBinding.pyRK�s6	
	

s(\r\n)|\n|\rcCsWy(t|d��}|j�}WdQXWn3tk
r]}tjdt|�d|j�tSX|j|�}|j	j
|�}|r�|jd�|_t
|jt�r�|jjd�|_n|j	jd|�}n|jjdd�|jd�|jjd|�|j�|j|�|jjd	d�|jjd	�|j|�tS(
Ntrbs	I/O ErrorR/iRs\ns1.0tendR%(RKtreadtIOErrorttkMessageBoxt	showerrorRDR	Rtdecodeteol_retsearchR@teol_conventiont
isinstancetunicodetencodetsubtdeleteRdR?R%R\tmark_settyviewtupdaterecentfileslisttTrue(R.Rbtftcharstmsgtfirsteol((s'/sys/lib/python2.7/idlelib/IOBinding.pyRj�s,



cCs!|jt�rKy|djd�}Wntk
r:|SXt|_|Snyt|�}Wn<tk
r�}tjdddd|d|j	�d	}nX|r�yt||�SWq�tk
r�q�Xnyt|d�SWntk
r�nXyt|t�}t|_Wntk
rnX|S(
sMCreate a Unicode string

        If that fails, let Tcl try its best
        isutf-8ttitlesError loading the filetmessages^The encoding '%s' is not known to this Python installation. The file may not display correctlyR/RN(
t
startswithRRvtUnicodeErrorRSRHRCRtRuR	R?R{tencoding(R.R�R0RG((s'/sys/lib/python2.7/idlelib/IOBinding.pyRvs>
		





c	Cs�|j�rdSd|jpd}tjddd|dtjd|j�}|r~d}|jd�|j�s�d	}q�n|dkr�d	}nd
}|jj�|S(Ntyess&Do you want to save %s before closing?sthis untitled documentR�s
Save On CloseR�RR/R(tno(	RYRbRttaskyesnocanceltYESR	RMR?Rk(R.R�tconfirmRo((s'/sys/lib/python2.7/idlelib/IOBinding.pyRlCs&		
	
cCsq|js|j|�nG|j|j�r`|jt�y|jj�Wq`tk
r\q`Xn|jj	�dS(NRf(
RbROt	writefileRZR�RJtstore_file_breakstAttributeErrorR	Rk(R.Rm((s'/sys/lib/python2.7/idlelib/IOBinding.pyRMYs	


cCs�|j�}|rf|j|�rf|j|�|jd�y|jj�Wqctk
r_qcXqfn|jj�|j	|�dS(NiRf(
tasksavefileR�RdRZRJR�R�R	RkR�(R.RmRb((s'/sys/lib/python2.7/idlelib/IOBinding.pyROfs





cCs@|j�}|r"|j|�n|jj�|j|�dS(NRf(R�R�R	RkR�(R.RmRb((s'/sys/lib/python2.7/idlelib/IOBinding.pyRQts

cCs�|j�|j|jjdd��}|jdkrO|jd|j�}ny-t|d��}|j|�WdQXtSWn3t	k
r�}t
jdt|�d|j�t
SXdS(Ns1.0send-1cs
twbs	I/O ErrorR/(tfixlastlineR|R	tgetRytreplaceRKtwriteR�RsRtRuRDR(R.RbR�R�R�((s'/sys/lib/python2.7/idlelib/IOBinding.pyR�|s

c
Cs�t|tj�r|Sy|jd�SWntk
r:nXyt|�}d}Wntk
rr}|}d}nX|r�y|j|�SWq�tk
r�d|}q�Xn|r�tj	dd|d|j
�n|jtks�r�|jd�S|jrYy|j|j�SWqYtk
rUtj	dd|jd|j
�t|jd�SXnt
jdd	d
�}|dkr�t|jd�St}y.|jt�}t}|dkr�t}nWn*tk
r�t|jd�}d}nX|s�St|jj|�}|j�|jdkr�d
|}|j
jdd�}	|	jd�rh|j
jd|�n|j
jd|�|j|j
jdd��S|S(NRsInvalid encoding '%s's	I/O Errors%s. Saving as UTF-8R/sutf-8s1Cannot save this as '%s' anymore. Saving as UTF-8tmaintEditorWindowR�tlocaleis# -*- coding: %s -*-
s1.0s2.0s#!send-1c(Rzttypest
StringTypeR|R�RHR?RCRtRuR	RSRRt	GetOptionR�R�RRRJRtgotnumR�R�R%(
R.R�R0tfailedR�tconfig_encodingtask_usertdialogtenclinet	firstline((s'/sys/lib/python2.7/idlelib/IOBinding.pyR|�sv





	


	




cCs8|jjd�}|dkr4|jjdd�ndS(Nsend-2cs
send-1c(R	R�R%(R.tc((s'/sys/lib/python2.7/idlelib/IOBinding.pyR��sc	Cstjdddddtjd|j�}|sA|jj�dSd}|j�}|re|j}n|sx|dkr�tj	dd	�\}}|}t
j|�|j|�s�t
j
|�dSnt
j}t}|d
krtjddd
�}	|	d}	n*|dkr'tjddd�}	nt}|r�|	tj|�}	t
j|	d�}
|
j�j�}|
j�}|r�d||}n|r�t|	�|}tjd|d|j�q�#d|}
tjd|
d|j�|r�j
|�ndS(NR�tPrintR�sPrint to Default PrinterRR/Rftprefixt	IDLE_tmp_tposixR�tGeneralsprint-command-posixs 2>&1tntsprint-command-wintrs#Printing failed (exit status 0x%x)
sPrinting command: %s
sPrint statuss-Printing is not enabled for this platform: %s(RttaskokcanceltOKR	RkR?RYRbttempfiletmkstempR_RXR�tunlinkRGR�RR�RtpipestquotetpopenRrtstriptreprRutshowinfo(R.RmR�ttempfilenametsavedRbttfdtplatformt
printPlatformRtpipetoutputtstatusR�((s'/sys/lib/python2.7/idlelib/IOBinding.pyRT�sX		


		

sPython filess
*.py *.pywtTEXTs
Text filess*.txts	All filesRcCs�|jd�\}}|jsBtjd|jd|j�|_n|jjd|d|�}t|t�r~|j	t
�}n|S(NRKR/t	filetypest
initialdirtinitialfile(tdefaultfilenamet
opendialogttkFileDialogtOpenR	R�tshowRzR{R|tfilesystemencoding(R.tdirtbaseRb((s'/sys/lib/python2.7/idlelib/IOBinding.pyRhs	RKcCsm|jrtjj|j�S|jr2|jdfSytj�}Wntjk
r^d}nX|dfSdS(NR(RbR_R`R<Rctgetcwdterror(R.tmodetpwd((s'/sys/lib/python2.7/idlelib/IOBinding.pyR�s		

cCs�|jd�\}}|jsBtjd|jd|j�|_n|jjd|d|�}t|t�r~|j	t
�}n|S(NRMR/R�R�R�(R�t
savedialogR�tSaveAsR	R�R�RzR{R|R�(R.R�R�Rb((s'/sys/lib/python2.7/idlelib/IOBinding.pyR�*s	cCs|jj|�dS(s-Update recent file list on all editor windowsN(RJtupdate_recent_files_list(R.Rb((s'/sys/lib/python2.7/idlelib/IOBinding.pyR�4sN(sPython filess
*.py *.pywR�(s
Text filess*.txtR�(s	All filesR(&R9R:R7RXRYRZR\R?RWR^RbRcRdRKteoltretcompileRwR_tlinesepRyRjRvRlRMRORQR�R|R�RTR�R�R�RhR�R�R�(((s'/sys/lib/python2.7/idlelib/IOBinding.pyRI�sB							,			-		
				J		2		
	
c
Cs�t�}|jd�ttttjd|j����\}}}}|jd||df�ddd��Y}t|�}|j	�|j
�||�}t|�}	dS(NsTest IOBindings[x+]s+%d+%di�t	MyEditWincBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cSsB||_d|_|jjd|j�|jjd|j�dS(Ns<Control-o>s<Control-s>(R	R?RgRRKRM(R.R	((s'/sys/lib/python2.7/idlelib/IOBinding.pyR7>s		cSsdS(Ni((R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyRYCscSsdS(N((R.R[((s'/sys/lib/python2.7/idlelib/IOBinding.pyRZDscSsdS(N((R.((s'/sys/lib/python2.7/idlelib/IOBinding.pyR\EscSs|jjd�dS(Ns<<open-window-from-file>>(R	tevent_generate(R.Rm((s'/sys/lib/python2.7/idlelib/IOBinding.pyRKFscSs|jjd�dS(Ns<<save-window>>(R	R�(R.Rm((s'/sys/lib/python2.7/idlelib/IOBinding.pyRMHs(R9R:R7RYRZR\RKRM(((s'/sys/lib/python2.7/idlelib/IOBinding.pyR�=s					((tTkR�tlisttmaptintR�R<tgeometrytTextR!RkRI(
tparentRtwidththeighttxtyR�R	RJtio((s'/sys/lib/python2.7/idlelib/IOBinding.pyt_io_binding8s	
3

t__main__(trun(*R_R�R�tsysRAR�R�RtR�tTkinterRtidlelib.configHandlerRRtImportErrorR�t	setlocaletLC_CTYPEtErrortgetfilesystemencodingR�R�R�tgetdefaultlocaleRBRCtnl_langinfotCODESETR?t	NameErrorR�t
ValueErrortlowerR�R=RRHRIR�R9tidlelib.idle_test.htestR�(((s'/sys/lib/python2.7/idlelib/IOBinding.pyt<module>sf



		.	�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.