3 § fþPã@sddlZddlmZddlZddlZddlZddlZddlZddljZ ddl j Z ddl mZddlZddlmZejr~dZ�n yddlZejejdƒWneejfk r²YnXdZejdkrôyejƒd ZejeƒWnek rðYnXnžy2ejej ƒZedk�sedk�rdZejeƒWnje!e"efk �r�y2ejƒd Zedk�s`edk�rddZejeƒWne#efk �rŠYnXYnXej$ƒZeZej%d ej&ƒZ'ej%d ej&ƒZ(d d „Z)Gdd„dƒZ*dd„Z+e,dk�rddl-m.Z.e.dddd�ddl/m0Z0e0e+ƒdS)éN)ÚBOM_UTF8)Ú askstring)ÚidleConfzutf-8ÚÚasciiZwin32éz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)z^[ \t\f]*(?:[#\r\n]|$)c CsÎt|tƒr|jdƒ}n|}d|kr8|jddƒdd…}n$d|krV|jddƒdd…}n|g}x2|D]&}tj|ƒ}|dk rzPtj|ƒsbdSqbWdS|jdƒ}ytj |ƒ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/python36/lib64/python3.6/idlelib/iomenu.pyÚ coding_specGs*      rc@sþeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd Zd d „Z d Z d Z dd„Z d:dd„Z dZejeƒZejZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd Zd Z d>Z!e"j#d.krÔd/nd0Z$d1d2„Z%d?d4d5„Z&d6d7„Z'd8d9„Z(d S)@Ú IOBindingcCsr||_|j|_|jjd|jƒ|_|jjd|jƒ|_|jjd|jƒ|_|jjd|j ƒ|_ d|_ |jjd|j ƒ|_ dS)Nz<>z<>z<>z<>z<>)Ú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__us  zIOBinding.__init__cCsf|jjd|jƒ|jjd|jƒ|jjd|jƒ|jjd|jƒ|jjd|jƒd|_d|_d|_dS)Nz<>z<>z<>z<>z<>) rZunbindr"r$r&r(r+rÚfilename_change_hook)r,rrrÚclose�szIOBinding.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_hookcCsF|rtjj|ƒrd|_||_n$||_d|_|jdƒ|jrB|jƒdS)Nr)ÚosÚpathÚisdirÚfilenameÚdirnamer1r.)r,r9rrrÚ set_filenamežs zIOBinding.set_filenamecCsÎ|jj}|rx|s|jƒ}n|}|rd|jrXt|jddƒ rX|j rX|jƒrX|j||jƒqt|j|ƒn|jrt|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@y|j j j ƒt d d t|j j d �}|�rnt ||ƒ}d|_|d fSttfk �rŽYnXdS)zCreate a Unicode string.Nézutf-8FÚBOMzError loading the filez^The encoding '%s' is not known to this Python installation. The file may not display correctly)ÚtitleÚmessagerGrzSpecify 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 initialvaluerGT)NF)NF)NF)Ú startswithrr ÚUnicodeDecodeErrorr)rrrNrOrrPrÚupdaterÚencoding)r,rYr r[ÚencrrrrrQýsh         zIOBinding._decodecCsp|jƒr dSd|jpd}tjd|tj|jd�}|rPd}|jdƒ|jƒsbd}n|dkr^d}nd}|jjƒ|S)NÚyesz&Do you want to save %s before closing?zthis untitled documentz Save On Close)r^r_ÚdefaultrGr=Úno)r0r9rNZaskyesnocancelZYESrr#rB)r,r_ÚconfirmrErrrrCAs&    zIOBinding.maybesavec CsZ|js|j|ƒn:|j|jƒrL|jdƒy|jjƒWntk rJYnX|jjƒdS)NTr<) r9r%Ú writefiler1rÚstore_file_breaksÚAttributeErrorrrB)r,rDrrrr#Ws    zIOBinding.savec Csf|jƒ}|rN|j|ƒrN|j|ƒ|jdƒy|jjƒWntk rLYnX|jjƒ|j |ƒdS)Nrr<) Ú asksavefilerir;r1rrjrkrrBrW)r,rDr9rrrr%ds     zIOBinding.save_ascCs.|jƒ}|r|j|ƒ|jjƒ|j|ƒdS)Nr<)rlrirrBrW)r,rDr9rrrr'rs    zIOBinding.save_a_copycCs˜|jƒ|jjddƒ}|jdkr.|jd|jƒ}|j|ƒ}y$t|dƒ�}|j|ƒWdQRXdStk r’}zt j dt |ƒ|jd�dSd}~XnXdS) Nz1.0zend-1crÚwbTz I/O Error)rGF) Ú fixlastlinerÚgetrTÚreplaceÚencoder!ÚwriterMrNrOrP)r,r9rr[rXrZrrrrizs     zIOBinding.writefilec#CsÚt|tƒr|S|jdkr&t|jdƒSy |jdƒStk rDYnXyt|ƒ}d}Wn*tk r€}z|}d}WYdd}~Xn X|sŠd}|r¶y |j|ƒStk r´d|}YnXtj dd||j d�t|jdƒS)Nr]zutf-8rzInvalid encoding '%s'z I/O Errorz%s. Saving as UTF-8)rG) r r r)rrqÚ UnicodeErrorrrrNrOr)r,r[rdZfailedrZrrrrq‰s4     zIOBinding.encodecCs&|jjdƒ}|dkr"|jjddƒdS)Nzend-2crzend-1c)rrorI)r,Úcrrrrn°s zIOBinding.fixlastlinecCsftjddtj|jd�}|s(|jjƒdSd}|jƒ}|r>|j}| sL|dkr‚tjdd�\}}|}t j |ƒ|j |ƒs‚t j |ƒdSt j }d}|dkr¬tjd d d ƒ} | d } n|d krÄtjd d dƒ} nd}|�r8| tj|ƒ} t j| dƒ} | jƒjƒ} | j ƒ} | �rd| | } | �rRdt| ƒ| } tjd| |jd�nd|} tjd| |jd�|�rbt j |ƒdS)NZPrintzPrint to Default Printer)r^r_rfrGr<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)rGz-Printing is not enabled for this platform: %s)rNZ askokcancelZOKrrBr0r9ÚtempfileZmkstempr6r/riÚunlinkrrZ GetOptionÚshlexZquoteÚpopenrLÚstripÚreprrOZshowinfo)r,rDrhZ tempfilenameZsavedr9ZtfdÚplatformZ printPlatformZcommandÚpipeÚoutputZstatusr_rrrr*µsX          zIOBinding.print_windowú Python filesú *.py *.pywÚTEXTú Text filesú*.txtú All filesÚ*Údarwinz.pyrcCs<|jdƒ\}}|js(tj|j|jd�|_|jj||d�}|S)Nr!)rGÚ filetypes)Ú initialdirÚ initialfile)ÚdefaultfilenameÚ opendialogÚ tkFileDialogZOpenrr‹Úshow)r,ÚdirÚbaser9rrrr?òs  zIOBinding.askopenfiler!c CsV|jrtjj|jƒS|jr$|jdfSy tjƒ}Wntk rHd}YnX|dfSdS)Nr)r9r6r7rr:ÚgetcwdrM)r,ÚmodeÚpwdrrrrŽús   zIOBinding.defaultfilenamecCs@|jdƒ\}}|js,tj|j|j|jd�|_|jj||d�}|S)Nr#)rGr‹Údefaultextension)rŒr�)rŽÚ savedialogr�ZSaveAsrr‹r—r‘)r,r’r“r9rrrrls zIOBinding.asksavefilecCs|jjr|jj|ƒdS)z-Update recent file list on all editor windowsN)rr>Zupdate_recent_files_list)r,r9rrrrWszIOBinding.updaterecentfileslist)NN©rƒr„r…©r†r‡r…©rˆr‰)r™ršr›)r!))Ú__name__Ú __module__Ú __qualname__r-r/r0r1r3r.r5r9r:r;r!ZeolÚreÚcompilerRr6ÚlineseprTrArQrCr#r%r'rirqrnr*r�r˜r‹Úsysr€r—r?rŽrlrWrrrrrpsD   , $D '2  rc Cs’ddlm}m}||ƒ}|jdƒtt|jƒjdƒdd…ƒ\}}|jd||dfƒGdd „d ƒ}||ƒ}|jƒ|j ƒ||ƒ}t |ƒdS) Nr)ÚToplevelÚTextzTest IOBindingú+rz+%d+%dé¯c@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)z_io_binding..MyEditWincSs`||_d|_|jjd|jƒ|jjd|jƒ|jjd|jƒ|jjd|jƒ|jjd|jƒdS)Nz z z zz )rr>r r!Úprintr#ÚsaveasÚsavecopy)r,rrrrr-sz'_io_binding..MyEditWin.__init__cSsdS)Nrr)r,rrrr0%sz(_io_binding..MyEditWin.get_savedcSsdS)Nr)r,r2rrrr1&sz(_io_binding..MyEditWin.set_savedcSsdS)Nr)r,rrrr3'sz)_io_binding..MyEditWin.reset_undocSs|jjdƒdS)Nz<>)rÚevent_generate)r,rDrrrr!(sz#_io_binding..MyEditWin.opencSs|jjdƒdS)Nz<>)rrª)r,rDrrrr§*sz$_io_binding..MyEditWin.printcSs|jjdƒdS)Nz<>)rrª)r,rDrrrr#,sz#_io_binding..MyEditWin.savecSs|jjdƒdS)Nz<>)rrª)r,rDrrrr¨.sz%_io_binding..MyEditWin.saveascSs|jjdƒdS)Nz<>)rrª)r,rDrrrr©0sz'_io_binding..MyEditWin.savecopyN) rœr�ržr-r0r1r3r!r§r#r¨r©rrrrÚ MyEditWinsr«) Ztkinterr£r¤r^ÚmapÚintZgeometryrZpackrBr) rGr£r¤ÚrootÚxÚyr«rrrrrÚ _io_bindings  r±Ú__main__)rwzidlelib.idle_test.test_iomenur F)Ú verbosityÚexit)Úrun)1rrr6rŸr|r¢rzZtkinter.filedialogZ filedialogr�Ztkinter.messageboxZ messageboxrNZtkinter.simpledialogrZidlelibZidlelib.configrZtestingrcZlocaleÚ setlocaleÚLC_CTYPEÚ ImportErrorÚErrorZ locale_decoder€ZgetdefaultlocaleZlocale_encodingrrÚ nl_langinfoÚCODESETÚ NameErrorrkÚ ValueErrorÚlowerr ÚASCIIrrrrr±rœZunittestrwZidlelib.idle_test.htestrµrrrrÚsj          )($