%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3.5/idlelib/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3.5/idlelib/__pycache__/IOBinding.cpython-35.pyc



|�gO�@s{ddlZddlmZddlZddlZddlZddlZddlZddljZ	ddl
jZddl
mZddlmZy#ddlZejejd�Wneejfk
r�YnXej�ZdZejdkr1y!ej�dZeje�Wnek
r-YnXn�yAejej�Zedkp[edkrddZeje�Wnuee efk
r�y?ej�dZedkp�edkr�dZeje�Wne!efk
r�YnXYnXej"�ZeZ#ej$d	ej%�Z&ej$d
ej%�Z'dd�Z(Gd
d�d�Z)dd�Z*e+dkrwddl,m-Z-e-e*�dS)�N)�BOM_UTF8)�	askstring)�idleConf��asciiZwin32�z&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)cCst|t�r!|jd�}n|}d|krR|jdd�dd�}n4d|kr}|jdd�dd�}n	|g}xA|D]5}tj|�}|dk	r�Ptj|�s�dSq�WdS|jd�}ytj	|�Wn"t
k
rt
d|��YnX|S)aVReturn the encoding declaration according to PEP 263.

    When checking encoded data, only the first two lines should be passed
    in to avoid a UnicodeDecodeError if the rest of the data is not unicode.
    The first two lines would contain the encoding specification.

    Raise a LookupError if the encoding is declared but unknown.
    z
iso-8859-1�
�N�
rzUnknown encoding: )�
isinstance�bytes�decode�split�	coding_re�match�blank_re�group�codecs�lookup�LookupError)�data�linesZlst�liner�name�r�'/usr/lib/python3.5/idlelib/IOBinding.py�coding_specDs*		

rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdZdd
�Z	dZ
dZdd�Zdddd�Z
dZeje�ZejZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdZdZ d:d;d<gZ!e"j#d.krJd/nd0Z$d1d2�Z%d3d4d5�Z&d6d7�Z'd8d9�Z(dS)=�	IOBindingcCs�||_|j|_|jjd|j�|_|jjd|j�|_|jjd|j�|_|jjd|j	�|_
d|_|jjd|j�|_
dS)Nz<<open-window-from-file>>z<<save-window>>z<<save-window-as-file>>z<<save-copy-of-window-as-file>>z<<print-window>>)�editwin�text�bind�open�_IOBinding__id_open�save�_IOBinding__id_save�save_as�_IOBinding__id_saveas�save_a_copy�_IOBinding__id_savecopy�fileencoding�print_window�_IOBinding__id_print)�selfrrrr�__init__os		zIOBinding.__init__cCs�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�d|_d|_d|_dS)Nz<<open-window-from-file>>z<<save-window>>z<<save-window-as-file>>z<<save-copy-of-window-as-file>>z<<print-window>>)	rZunbindr"r$r&r(r+r�filename_change_hook)r,rrr�close{s		zIOBinding.closecCs
|jj�S)N)r�	get_saved)r,rrrr0�szIOBinding.get_savedcCs|jj|�dS)N)r�	set_saved)r,�flagrrrr1�szIOBinding.set_savedcCs|jj�dS)N)r�
reset_undo)r,rrrr3�szIOBinding.reset_undoNcCs
||_dS)N)r.)r,�hookrrr�set_filename_change_hook�sz"IOBinding.set_filename_change_hookcCsc|r-tjj|�r-d|_||_n2||_d|_|jd�|jr_|j�dS)Nr)�os�path�isdir�filename�dirnamer1r.)r,r9rrr�set_filename�s			
	zIOBinding.set_filenamecCs|jj}|r�|s'|j�}n|}|r�|jr~t|jdd�r~|jr~|j�r~|j||j�q�|j|�n|jr�|jj	�dS|j�r�|j
�}|dkr�|jj	�dS|s�|j�}n|}|r|j|�n
|jj	�dS)NZinterp�break�cancel)r�flist�askopenfile�getattrr9r0r!�loadfiler�	focus_set�	maybesave)r,�eventZeditFiler>r9�replyrrrr!�s6	
	


zIOBinding.openz(\r\n)|\n|\rc	Cs�yLt|d��6}|j�|j�}|jd�|j�}WdQRXWnHtk
r�}z(tjdt|�d|j�dSWYdd}~XnX|j	||�\}}|dkr�tjdd|d|j�dS|j
j|�}|r|jd�|_
|j
jd|�}|jjd	d
�|jd�|jjd	|�|j�|j|�|rx|jd�|jjdd	�|jjd�|j|�dS)
N�rbrz	I/O Error�parentFzDecoding ErrorzFile %s
Failed to Decodez\nz1.0�end�insertT)r!�readline�seek�read�OSError�tkMessageBox�	showerror�strr�_decode�eol_re�searchr�eol_convention�subZdeleter;rIr3r1Zmark_setZyview�updaterecentfileslist)	r,r9�f�	two_linesr�msg�charsZ	convertedZfirsteolrrrrA�s:
	






zIOBinding.loadfilec;Csd}|jt�r^y|dd�jd�}Wntk
rJdSYnXd|_|dfSyt|�}Wnctk
r�}z.tjdddd	|d
|j	�d}WYdd}~Xntk
r�dSYnX|ry&t
||�}||_|dfSWntk
rYnXy&t
|d�}d|_|dfSWntk
rOYnXy&t
|d�}d|_|dfSWntk
r�YnXy]|jj	j�t
dd
dtd
|jj	�}|r�t
||�}d|_|dfSWnttfk
rYnXdS)zCreate a Unicode string.N�zutf-8F�BOM�titlezError loading the file�messagez^The encoding '%s' is not known to this Python installation. The file may not display correctlyrGrzSpecify file encodingzwThe file's encoding is invalid for Python 3.x.
IDLE will convert it to UTF-8.
What is the current encoding of the file?ZinitialvalueT)NF)NF)NF)�
startswithrr
�UnicodeDecodeErrorr)rrrNrOrrPr�updater�locale_encoding)r,rXrrZ�encrrrrrQ�sh
		
	

		
	
	
	zIOBinding._decodec	Cs�|j�rdSd|jpd}tjddd|dtjd|j�}|r{d}|jd�|j�s�d	}n|dkr�d	}nd
}|jj�|S)NZyesz&Do you want to save %s before closing?zthis untitled documentr]z
Save On Closer^�defaultrGr=Zno)r0r9rNZaskyesnocancelZYESrr#rB)r,r^�confirmrErrrrC;s&		
		
zIOBinding.maybesavecCso|js|j|�nE|j|j�r^|jd�y|jj�Wntk
r]YnX|jj�dS)NTr<)	r9r%�	writefiler1r�store_file_breaks�AttributeErrorrrB)r,rDrrrr#Qs	


zIOBinding.savecCs|j�}|ra|j|�ra|j|�|jd�y|jj�Wntk
r`YnX|jj�|j	|�dS)Nrr<)
�asksavefilerfr;r1rrgrhrrBrV)r,rDr9rrrr%^s




zIOBinding.save_ascCs=|j�}|r|j|�|jj�|j|�dS)Nr<)rirfrrBrV)r,rDr9rrrr'ls


zIOBinding.save_a_copycCs�|j�|jjdd�}|jdkrC|jd|j�}|j|�}y.t|d��}|j|�WdQRXdSWnHtk
r�}z(t	j
dt|�d|j�dSWYdd}~XnXdS)	Nz1.0zend-1cr�wbTz	I/O ErrorrGF)�fixlastliner�getrT�replace�encoder!�writerMrNrOrP)r,r9rrZrWrYrrrrfts

zIOBinding.writefilec#Cst|t�r|S|jdkr3t|jd�Sy|jd�SWntk
rXYnXyt|�}d}Wn1tk
r�}z|}d}WYdd}~Xn
X|s�d}|r�y|j|�SWntk
r�d|}YnXtj	dd|d|j
�t|jd�S)Nr\zutf-8rzInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8rG)rrr)rrn�UnicodeErrorrrrNrOr)r,rZrcZfailedrYrrrrn�s4




zIOBinding.encodecCs5|jjd�}|dkr1|jjdd�dS)Nzend-2crzend-1c)rrlrI)r,�crrrrk�szIOBinding.fixlastlinec	Cs�tjdddddtjd|j�}|sA|jj�dSd}|j�}|rb|j}|su|dkr�tjdd	�\}}|}t	j
|�|j|�s�t	j|�dSt	j
}d
}|dkr�tjdd
d�}	|	d}	n*|dkr!tjdd
d�}	nd}|r�|	tj|�}	t	j|	d�}
|
j�j�}|
j
�}|r�d||}|r�dt|	�|}tjd|d|j�n#d|}
tjd|
d|j�|r�t	j|�dS)Nr]ZPrintr^zPrint to Default PrinterrdrGr<�prefixZ	IDLE_tmp_T�posix�mainZGeneralzprint-command-posixz 2>&1�ntzprint-command-winF�rz#Printing failed (exit status 0x%x)
zPrinting command: %s
zPrint statusz-Printing is not enabled for this platform: %s)rNZaskokcancelZOKrrBr0r9�tempfileZmkstempr6r/rf�unlinkrrZ	GetOption�shlexZquote�popenrL�strip�reprrOZshowinfo)r,rDreZtempfilenameZsavedr9Ztfd�platformZ
printPlatformZcommand�pipe�outputZstatusr^rrrr*�sX		
	

		


zIOBinding.print_window�Python files�
*.py *.pyw�TEXT�
Text files�*.txt�	All files�*�darwinz.pyrcCs^|jd�\}}|js?tjd|jd|j�|_|jjd|d|�}|S)Nr!rG�	filetypes�
initialdir�initialfile)�defaultfilename�
opendialog�tkFileDialogZOpenrr��show)r,�dir�baser9rrrr?�s	zIOBinding.askopenfiler!cCsk|jrtjj|j�S|jr2|jdfSytj�}Wntk
r\d}YnX|dfSdS)Nr)r9r6r7rr:�getcwdrM)r,�mode�pwdrrrr��s		

zIOBinding.defaultfilenamecCsg|jd�\}}|jsHtjd|jd|jd|j�|_|jjd|d|�}|S)Nr#rGr��defaultextensionr�r�)r��
savedialogr�ZSaveAsrr�r�r�)r,r�r�r9rrrris				zIOBinding.asksavefilecCs |jjr|jj|�dS)z-Update recent file list on all editor windowsN)rr>Zupdate_recent_files_list)r,r9rrrrV
szIOBinding.updaterecentfileslist)r�r�r�)r�r�r�)r�r�))�__name__�
__module__�__qualname__r-r/r0r1r3r.r5r9r:r;r!Zeol�re�compilerRr6�lineseprTrArQrCr#r%r'rfrnrkr*r�r�r��sysr}r�r?r�rirVrrrrrmsD,	$D
'2	
rcCs�ddlm}m}||�}|jd�ttttjd|j	����\}}}}|j	d||df�Gdd�d�}||�}	|	j
�|	j�||	�}
t|
�dS)	Nr)�Toplevel�TextzTest IOBindingz[x+]z+%d+%d�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z_io_binding.<locals>.MyEditWincSs�||_d|_|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�dS)Nz<Control-o>z<Control-p>z<Control-s>z<Alt-s>z<Control-c>)rr>r r!�printr#�saveas�savecopy)r,rrrrr-s		z'_io_binding.<locals>.MyEditWin.__init__cSsdS)Nrr)r,rrrr0sz(_io_binding.<locals>.MyEditWin.get_savedcSsdS)Nr)r,r2rrrr1 sz(_io_binding.<locals>.MyEditWin.set_savedcSsdS)Nr)r,rrrr3!sz)_io_binding.<locals>.MyEditWin.reset_undocSs|jjd�dS)Nz<<open-window-from-file>>)r�event_generate)r,rDrrrr!"sz#_io_binding.<locals>.MyEditWin.opencSs|jjd�dS)Nz<<print-window>>)rr�)r,rDrrrr�$sz$_io_binding.<locals>.MyEditWin.printcSs|jjd�dS)Nz<<save-window>>)rr�)r,rDrrrr#&sz#_io_binding.<locals>.MyEditWin.savecSs|jjd�dS)Nz<<save-window-as-file>>)rr�)r,rDrrrr�(sz%_io_binding.<locals>.MyEditWin.saveascSs|jjd�dS)Nz<<save-copy-of-window-as-file>>)rr�)r,rDrrrr�*sz'_io_binding.<locals>.MyEditWin.savecopyN)r�r�r�r-r0r1r3r!r�r#r�r�rrrr�	MyEditWinsr�)
Ztkinterr�r�r]�list�map�intr�rZgeometryZpackrBr)rGr�r��root�widthZheight�x�yr�rrrrr�_io_bindings
3

r��__main__)�run).rrr6r�ryr�rwZtkinter.filedialogZ
filedialogr�Ztkinter.messageboxZ
messageboxrNZtkinter.simpledialogrZidlelib.configHandlerrZlocale�	setlocale�LC_CTYPE�ImportError�Error�getfilesystemencodingZfilesystemencodingrbr}Zgetdefaultlocalerr�nl_langinfo�CODESET�	NameErrorrh�
ValueError�lower�encodingr��ASCIIrrrrr�r�Zidlelib.idle_test.htestr�rrrr�<module>s^

)��$

Zerion Mini Shell 1.0