Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/__pycache__/iomenu.cpython-37.opt-1.pyc

B

� f�P�@s�ddlZddlmZddlZddlZddlZddlZddlZddlmZ	ddl
mZddl
mZddlZddlmZejr�dZdZn�yddlZe�ejd�Wneejfk
r�YnXejdkr�dZdZn�ye�ej�Zer�e�e�WnXee e!fk
�rDy e�"�d	Ze�r"e�e�Wne#e!fk
�r>YnXYnXe�rZe�$�Zd
ZndZdZe�%dej&�Z'e�%d
ej&�Z(dd�Z)Gdd�d�Z*dd�Z+e,dk�r�ddl-m.Z.e.dddd�ddl/m0Z0e0e+�dS)�N)�BOM_UTF8)�	askstring)�idleConfzutf-8�surrogateescape�Zwin32��strict�asciiz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)cCs�t|t�r|�d�}n|}d|kr8|�dd�dd�}n$d|krV|�dd�dd�}n|g}x2|D]&}t�|�}|dk	rzPt�|�sbdSqbWdS|�d�}yt�	|�Wn t
k
r�t
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�3/opt/alt/python37/lib64/python3.7/idlelib/iomenu.py�coding_specBs*	




rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdZdd
�Z	dZ
dZdd�Zd4dd�Z
dZe�e�ZejZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdZdZ d'Z!e"j#d(kr�d)nd*Z$d+d,�Z%d5d.d/�Z&d0d1�Z'd2d3�Z(dS)6�	IOBindingcCsr||_|j|_|j�d|j�|_|j�d|j�|_|j�d|j�|_|j�d|j	�|_
d|_|j�d|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)�selfr rrr�__init__ps

zIOBinding.__init__cCsf|j�d|j�|j�d|j�|j�d|j�|j�d|j�|j�d|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>>)	r!Zunbindr$r&r(r*r-r �filename_change_hook)r.rrr�close|szIOBinding.closecCs
|j��S)N)r �	get_saved)r.rrrr2�szIOBinding.get_savedcCs|j�|�dS)N)r �	set_saved)r.�flagrrrr3�szIOBinding.set_savedcCs|j��dS)N)r �
reset_undo)r.rrrr5�szIOBinding.reset_undoNcCs
||_dS)N)r0)r.�hookrrr�set_filename_change_hook�sz"IOBinding.set_filename_change_hookcCsF|rtj�|�rd|_||_n$||_d|_|�d�|jrB|��dS)Nr)�os�path�isdir�filename�dirnamer3r0)r.r;rrr�set_filename�s
zIOBinding.set_filenamecCs�|jj}|rt|s|��}n|}|r`|jrTt|jdd�sT|jsT|��rT|�||j�qp|�|�n|jrp|j�	�dS|��r�|�
�}|dkr�|j�	�dS|s�|��}n|}|r�|�|�n
|j�	�dS)N�interp�break�cancel)r �flist�askopenfile�getattrr;r2r#�loadfiler!�	focus_set�	maybesave)r.�eventZeditFilerAr;�replyrrrr#�s6




zIOBinding.openz(\r\n)|\n|\rc	
CsBy<t|d��(}|��|��}|�d�|��}WdQRXWn8tk
rt}ztjdt|�|jd�dSd}~XYnX|�	||�\}}|dkr�tjdd||jd�dS|j
�|�}|r�|�d�|_
|j
�d|�}|j�d	d
�|�d�|j�d	|�|��|�|�|�r|�d�|j�dd	�|j�d�|�|�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�sub�deleter=rLr5r3Zmark_setZyview�updaterecentfileslist)	r.r;�f�	two_linesr�msg�charsZ	convertedZfirsteolrrrrD�s:





zIOBinding.loadfilec
Cs�d}|�t�rHy|dd��d�}Wntk
r8dSXd|_|dfSyt|�}WnNtk
r�}ztjdd||j	d	�d}Wdd}~XYntk
r�dSX|r�yt
||�}||_|dfStk
r�YnXyt
|d
�}d|_|dfStk
�rYnXyt
|d�}d|_|dfStk
�r4YnXy>|jj	��t
ddt|jj	d
�}|�rnt
||�}d|_|dfSttfk
�r�YnXdS)zCreate a Unicode string.N�zutf-8)NF�BOMFzError loading the filez^The encoding '%s' is not known to this Python installation. The file may not display correctly)�title�messagerJr	zSpecify 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initialvaluerJT)�
startswithrr�UnicodeDecodeErrorr+rrrQrRr!rSr �updater�encoding)r.r\rr^�encrrrrrT�sh





zIOBinding._decodecCsp|��rdSd|jpd}tjd|tj|jd�}|rPd}|�d�|��sbd}n|dkr^d}nd}|j��|S)NZyesz&Do you want to save %s before closing?zthis untitled documentz
Save On Close)rarb�defaultrJr@Zno)r2r;rQZaskyesnocancelZYESr!r%rE)r.rb�confirmrHrrrrF<s&


zIOBinding.maybesavecCsZ|js|�|�n:|�|j�rL|�d�y|j��Wntk
rJYnX|j��dS)NTr?)	r;r'�	writefiler3r �store_file_breaks�AttributeErrorr!rE)r.rGrrrr%Rs

zIOBinding.savecCsf|��}|rN|�|�rN|�|�|�d�y|j��Wntk
rLYnX|j��|�	|�dS)Nrr?)
�asksavefilerjr=r3r rkrlr!rErZ)r.rGr;rrrr'_s




zIOBinding.save_ascCs.|��}|r|�|�|j��|�|�dS)Nr?)rmrjr!rErZ)r.rGr;rrrr)ms


zIOBinding.save_a_copyc
Cs�|��}|�|�}y:t|d��&}|�|�|��t�|���WdQRXdStk
r�}zt	j
dt|�|jd�dSd}~XYnXdS)N�wbTz	I/O Error)rJF)
�fixnewlines�encoder#�write�flushr8�fsync�filenorPrQrRrSr!)r.r;r!r^r[r]rrrrjus


zIOBinding.writefilecCsT|j�d�dkr*t|jd�s*|j�dd�|j�dd�}|jdkrP|�d|j�}|S)z/Return text with final 
 if needed and os eols.zend-2cr
r>zend-1cz1.0)r!�get�hasattrr rLrW�replace)r.r!rrrro�s
zIOBinding.fixnewlinesc
Cs�t|t�r|S|jdkr&t|�d�Sy
|�d�Stk
rDYnXyt|�}d}Wn*tk
r�}z|}d}Wdd}~XYn
X|s�d}|r�y
|�|�Stk
r�d|}YnXtj	dd||j
d�t|�d�S)Nr`zutf-8r	zInvalid encoding '%s'z	I/O Errorz%s.
Saving as UTF-8)rJ)r
rr+rrp�UnicodeErrorrrrQrRr!)r.r^rgZfailedr]rrrrp�s4




zIOBinding.encodecCsdtjddtj|jd�}|s(|j��dSd}|��}|r>|j}|rJ|dkr�tjdd�\}}|}t	�
|�|�|�s�t	�|�dSt	j
}d}|dkr�t�d	d
d�}	|	d}	n|d
kr�t�d	d
d�}	nd}|�r6|	t�|�}	t	�|	d�}
|
����}|
�
�}|�rd||}|�rPdt|	�|}tjd||jd�nd|}
tjd|
|jd�|�r`t	�|�dS)NZPrintzPrint to Default Printer)rarbrhrJr?Z	IDLE_tmp_)�prefixT�posix�mainZGeneralzprint-command-posixz 2>&1�ntzprint-command-winF�rz#Printing failed (exit status 0x%x)
zPrinting command: %s
zPrint status)rJz-Printing is not enabled for this platform: %s)rQZaskokcancelZOKr!rEr2r;�tempfileZmkstempr8r1rj�unlinkrrZ	GetOption�shlexZquote�popenrO�strip�reprrRZshowinfo)r.rGriZtempfilenameZsavedr;Ztfd�platformZ
printPlatformZcommand�pipe�outputZstatusrbrrrr,�sX







zIOBinding.print_window))zPython filesz
*.py *.pyw�TEXT)z
Text filesz*.txtr�)z	All files�*�darwinz.pyrcCs<|�d�\}}|js(tj|j|jd�|_|jj||d�}|S)Nr#)rJ�	filetypes)�
initialdir�initialfile)�defaultfilename�
opendialog�tkFileDialogZOpenr!r��show)r.�dir�baser;rrrrB�szIOBinding.askopenfiler#cCsV|jrtj�|j�S|jr$|jdfSyt��}Wntk
rHd}YnX|dfSdS)Nr)r;r8r9rr<�getcwdrP)r.�mode�pwdrrrr��s

zIOBinding.defaultfilenamecCs@|�d�\}}|js,tj|j|j|jd�|_|jj||d�}|S)Nr%)rJr��defaultextension)r�r�)r��
savedialogr�ZSaveAsr!r�r�r�)r.r�r�r;rrrrmszIOBinding.asksavefilecCs|jjr|j�|�dS)z-Update recent file list on all editor windowsN)r rAZupdate_recent_files_list)r.r;rrrrZszIOBinding.updaterecentfileslist)NN)r#))�__name__�
__module__�__qualname__r/r1r2r3r5r0r7r;r<r=r#Zeol�re�compilerUr8�lineseprWrDrTrFr%r'r)rjrorpr,r�r�r��sysr�r�rBr�rmrZrrrrrks@
,
$D

'2

rc	Cs�ddlm}m}||�}|�d�tt|���d�dd��\}}|�d||df�Gdd	�d	�}||�}|��|�	�||�}t
|�dS)
Nr)�Toplevel�TextzTest IOBinding�+rz+%d+%d�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z_io_binding.<locals>.MyEditWincSs`||_d|_|j�d|j�|j�d|j�|j�d|j�|j�d|j�|j�d|j�dS)Nz<Control-o>z<Control-p>z<Control-s>z<Alt-s>z<Control-c>)r!rAr"r#�printr%�saveas�savecopy)r.r!rrrr/sz'_io_binding.<locals>.MyEditWin.__init__cSsdS)Nrr)r.rrrr2$�z(_io_binding.<locals>.MyEditWin.get_savedcSsdS)Nr)r.r4rrrr3%r�z(_io_binding.<locals>.MyEditWin.set_savedcSsdS)Nr)r.rrrr5&r�z)_io_binding.<locals>.MyEditWin.reset_undocSs|j�d�dS)Nz<<open-window-from-file>>)r!�event_generate)r.rGrrrr#'sz#_io_binding.<locals>.MyEditWin.opencSs|j�d�dS)Nz<<print-window>>)r!r�)r.rGrrrr�)sz$_io_binding.<locals>.MyEditWin.printcSs|j�d�dS)Nz<<save-window>>)r!r�)r.rGrrrr%+sz#_io_binding.<locals>.MyEditWin.savecSs|j�d�dS)Nz<<save-window-as-file>>)r!r�)r.rGrrrr�-sz%_io_binding.<locals>.MyEditWin.saveascSs|j�d�dS)Nz<<save-copy-of-window-as-file>>)r!r�)r.rGrrrr�/sz'_io_binding.<locals>.MyEditWin.savecopyN)r�r�r�r/r2r3r5r#r�r%r�r�rrrr�	MyEditWinsr�)Ztkinterr�r�ra�map�intZgeometryrZpackrEr)	rJr�r��root�x�yr�r!r rrr�_io_bindings
 r��__main__)r{zidlelib.idle_test.test_iomenurF)�	verbosity�exit)�run)1rrr8r�r�r�r~Ztkinter.filedialogZ
filedialogr�Ztkinter.messageboxZ
messageboxrQZtkinter.simpledialogrZidlelibZidlelib.configrZtestingrf�errorsZlocale�	setlocale�LC_CTYPE�ImportError�Errorr��nl_langinfo�CODESETZlocale_encodingr�	NameErrorrlrZgetdefaultlocale�
ValueError�lowerr��ASCIIrrrrr�r�Zunittestr{Zidlelib.idle_test.htestr�rrrr�<module>sf
),$


Hacked By AnonymousFox1.0, Coded By AnonymousFox