,Rc@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Tddl m Z ddl m Z yddlm Z Wnek rdZ nXy#ddlZejejdWneejfk rnXejZdZejd kr]y!ejd ZejeWnek rYnXnyDejejZeekpedkrdZnejeWnveeefk ryBejd ZeekpedkrdZnejeWneefk rnXnXej Zej!d Z"d e fd YZ#dZ$dfdYZ%dZ&e'dkre&ndS(iN(t*(t SimpleDialog(tidleConf(tBOM_UTF8sttasciitwin32is%^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)tEncodingMessagecBs)eZdZdZdZdZRS(s3Inform user that an encoding declaration is needed.c Cst|_t||_}|jd|j|jd|j|jd|j|j d|j d||_ t |dd}|j dtdtt|d d }|jd d ||j dtdtd tt |dd|}|j dtdtt|}|j dtd td |_|_t|ddddd|j}|j dtd tddt|ddd|j} | j dtd tdd|j|dS(NsstWM_DELETE_WINDOWs I/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(tFalset should_edittTopleveltroottbindt return_eventtdo_oktprotocoltwm_delete_windowtwm_titlet wm_iconnamettoptLabeltpacktTOPtWtEntrytinserttXtFrameRtcanceltButtontLEFTtBOTHtdo_editt_set_transient( tselftmastertencRtl1tl2tl3tbuttonstb1tb2((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyt__init__Ns6           cCs|jddS(Ni(tdone(R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRtscCs|jddS(Ni(R8(R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR,ws(t__name__t __module__t__doc__R7RR,(((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRLs & cCs|jddd }x1|D]%}tj|}|dk rPqqWdS|jd}ddl}y|j|Wntk rtd|nX|S(szReturn the encoding declaration according to PEP 263. Raise LookupError if the encoding is declared but unknown. s iiiNsUnknown encoding (tsplitt coding_retmatchtNonetgrouptcodecstlookupt LookupError(tstrtlsttlineR>tnameRA((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyt coding_speczs    t IOBindingcBs"eZdZdZdZdZdZdZdZ dZ dZ dZ dddZ dZejeZejZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZ d d!d"gZ!dZ"ddZ#dZ$dZ%RS(#cCs||_|j|_|jjd|j|_|jjd|j|_|jjd|j|_|jjd|j |_ d|_ |jjd|j |_dS(Ns<>s<>s<>s<>s<>(teditwinR Rtopent_IOBinding__id_opentsavet_IOBinding__id_savetsave_ast_IOBinding__id_saveast save_a_copyt_IOBinding__id_savecopyR?t fileencodingt print_windowt_IOBinding__id_print(R.RJ((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR7s     cCs|jjd|j|jjd|j|jjd|j|jjd|j|jjd|jd|_d|_d|_ dS(Ns<>s<>s<>s<>s<>( R tunbindRLRNRPRRRUR?RJtfilename_change_hook(R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pytcloses  cCs |jjS(N(RJt get_saved(R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRYscCs|jj|dS(N(RJt set_saved(R.tflag((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRZscCs|jjdS(N(RJt reset_undo(R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR\scCs ||_dS(N(RW(R.thook((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pytset_filename_change_hookscCsf|r-tjj|r-d|_||_n5||_d|_|jd|jrb|jndS(Ni(tostpathtisdirR?tfilenametdirnameRZRW(R.Rb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyt set_filenames      cCs%|jj}|r|s'|j}n|}|r|jr~t|jdd r~|j r~|jr~|j||jq|j|n|j r|j j ndS|jr|j }|dkr|j j dSn|s|j}n|}|r|j|n |j j dS(NtinterptbreakR(( RJtflistt askopenfiletgetattrR?RbRYRKtloadfileR t focus_sett maybesave(R.teventteditFileRgRbtreply((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRKs6          s (\r\n)|\n|\rcCsWy(t|d}|j}WdQXWn3tk r]}tjdt|d|jtSX|j|}|j j |}|r|j d|_ t |j tr|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((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRjs,    cCs!|jtrKy|djd}Wntk r:|SXt|_|Snyt|}Wn<tk r}tjdddd|d|j d }nX|ryt ||SWqtk rqXnyt |dSWntk rnXyt |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.RR0RG((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRvs>         c Cs|jrdSd|jpd}tjddd|dtjd|j}|r~d}|jd|jsd }qn|dkrd }nd }|jj|S( Ntyess&Do you want to save %s before closing?sthis untitled documentRs Save On CloseRRR/R(tno( RYRbRttaskyesnocanceltYESR RMR?Rk(R.RtconfirmRo((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRlCs&          cCsq|js|j|nG|j|jr`|jty|jjWq`tk r\q`Xn|jj dS(NRf( RbROt writefileRZRRJtstore_file_breakstAttributeErrorR Rk(R.Rm((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRMYs    cCs|j}|rf|j|rf|j||jdy|jjWqctk r_qcXqfn|jj|j |dS(NiRf( t asksavefileRRdRZRJRRR RkR(R.RmRb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyROfs       cCs@|j}|r"|j|n|jj|j|dS(NRf(RRR RkR(R.RmRb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRQts    cCs|j|j|jjdd}|jdkrO|jd|j}ny-t|d}|j|WdQXtSWn3t k r}t j dt |d|jt SXdS(Ns1.0send-1cs twbs I/O ErrorR/(t fixlastlineR|R tgetRytreplaceRKtwriteRRsRtRuRDR(R.RbRRR((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR|s  c Cst|tjr|Sy|jdSWntk r:nXyt|}d}Wntk rr}|}d}nX|ry|j|SWqtk rd|}qXn|rtj dd|d|j n|j t ks|rt |jdS|j rYy|j|j SWqYtk rUtj dd|j d|j t |jdSXnt jdd d }|dkrt |jdSt}y.|jt}t}|d krt}nWn*tk rt |jd}d}nX|s|St|jj|}|j|jd krd |}|j jdd} | jdrh|j jd|n|j jd||j|j jddS|S(NRsInvalid encoding '%s's I/O Errors%s. Saving as UTF-8R/sutf-8s1Cannot save this as '%s' anymore. Saving as UTF-8tmaint EditorWindowRtlocaleis# -*- coding: %s -*- s1.0s2.0s#!send-1c(Rzttypest StringTypeR|RRHR?RCRtRuR RSRRt GetOptionRRRRRJRtgotnumRRR%( R.RR0tfailedRtconfig_encodingtask_usertdialogtenclinet firstline((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR|sv                    cCs8|jjd}|dkr4|jjddndS(Nsend-2cs send-1c(R RR%(R.tc((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRs c Cstjdddddtjd|j}|sA|jjdSd}|j}|re|j}n| sx|dkrtj dd \}}|}t j ||j |st j |dSnt j}t}|d krtjd d d } | d} n*|dkr'tjd d d} nt}|r| tj|} t j| d} | jj} | j } | rd| | } n| rdt| | } tjd| d|jqn#d|} tjd| d|j|rt j |ndS(NRtPrintRsPrint to Default PrinterRR/Rftprefixt IDLE_tmp_tposixRtGeneralsprint-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(Rtt askokcanceltOKR RkR?RYRbttempfiletmkstempR_RXRtunlinkRGRRRRtpipestquotetpopenRrtstriptreprRutshowinfo(R.RmRt tempfilenametsavedRbttfdtplatformt printPlatformRtpipetoutputtstatusR((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRTsX                s Python filess *.py *.pywtTEXTs Text filess*.txts All filesRcCs|jd\}}|jsBtjd|jd|j|_n|jjd|d|}t|tr~|j t }n|S(NRKR/t filetypest initialdirt initialfile( tdefaultfilenamet opendialogt tkFileDialogtOpenR RtshowRzR{R|tfilesystemencoding(R.tdirtbaseRb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRhs RKcCsm|jrtjj|jS|jr2|jdfSytj}Wntjk r^d}nX|dfSdS(NR(RbR_R`R<Rctgetcwdterror(R.tmodetpwd((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRs    cCs|jd\}}|jsBtjd|jd|j|_n|jjd|d|}t|tr~|j t }n|S(NRMR/RRR( Rt savedialogRtSaveAsR RRRzR{R|R(R.RRRb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR*s cCs|jj|dS(s-Update recent file list on all editor windowsN(RJtupdate_recent_files_list(R.Rb((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR4sN(s Python filess *.py *.pywR(s Text filess*.txtR(s All filesR(&R9R:R7RXRYRZR\R?RWR^RbRcRdRKteoltretcompileRwR_tlinesepRyRjRvRlRMRORQRR|RRTRRRRhRRR(((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRIsB     ,   -     J  2  cCsbt}dddY}t|}|j|j||}t|}|jdS(Nt MyEditWincBsPeZdZdZdZdZdZdZdZdZ RS(cSsn||_d|_|jjd|j|jjd|j|jjd|j|jjd|jdS(Ns s ss(R R?RgRRKRMRORQ(R.R ((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR7;s   cSsdS(Ni((R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRYBscSsdS(N((R.R[((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRZCscSsdS(N((R.((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR\DscSs|jjddS(Ns<>(R tevent_generate(R.Rm((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRKEscSs|jjddS(Ns<>(R R(R.Rm((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRMGscSs|jjddS(Ns<>(R R(R.Rm((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyROIscSs|jjddS(Ns<>(R R(R.Rm((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyRQKs( R9R:R7RYRZR\RKRMRORQ(((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyR:s       ((tTktTextR!RkRItmainloop(RRR RJtio((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pyttest8s      t__main__((R_RRtsysRARRRtRtTkinterRtidlelib.configHandlerRRt ImportErrorRt setlocaletLC_CTYPEtErrortgetfilesystemencodingRRRtgetdefaultlocaleRBRCt nl_langinfotCODESETR?t NameErrorRt ValueErrortlowerRR=RRHRIRR9(((s2/opt/freeware/lib64/python2.7/idlelib/IOBinding.pytsd                  .