‰PNG  IHDR @ @ ªiqÞ pHYs   šœ —tEXtComment  Dfc@sdZddlZddlZddlZddlZdddgZdefdYZed\Z Z Z dZ d Z ed Zy<dd lmZmZdd lmZd ZdZWn@ek rdd$dYZdZdd%dYZnXdd&dYZdd'dYZdd(dYZdZdd)dYZdd*dYZdd+d YZd!Zd"Z e!d#kre ndS(,sMacintosh binhex compression/decompression. easy interface: binhex(inputfilename, outputfilename) hexbin(inputfilename, outputfilename) iNtbinhexthexbintErrorcBseZRS((t__name__t __module__(((s/usr/lib64/python2.7/binhex.pyRsiii@i(tFSSpectFInfo(topenrfcCst|j}tjj|\}}t|d}|jdd|j}t|d}|jdd|j}||||fS(Ntrbiis*rb( Rt FSpGetFInfotostpathtsplittopentseekttellR(tnametfinfotdirtfiletfptdlentrlen((s/usr/lib64/python2.7/binhex.pyt getfileinfo3s  cGs*|sd}nd|d}t||S(Ns*rbt*i(R(Rtmode((s/usr/lib64/python2.7/binhex.pytopenrsrc?s RcBseZdZRS(cCsd|_d|_d|_dS(Ns????i(tTypetCreatortFlags(tself((s/usr/lib64/python2.7/binhex.pyt__init__Ls  (RRR(((s/usr/lib64/python2.7/binhex.pyRKscCst}t|}t|jd}xF|D]5}|j r1|dksbt|dkr1Pq1q1Wd|_|jdd|j}|jt j j |\}}|j ddd }|||dfS( Nit itTEXTiit:t-i( RR treadtisspacetordRRRtcloseR R R treplace(RRRtdatatctdsizeRR((s/usr/lib64/python2.7/binhex.pyRQs   +   RcBs,eZdZdZdZdZRS(cGsdS(N((Rtargs((s/usr/lib64/python2.7/binhex.pyRcscGsdS(Nt((RR,((s/usr/lib64/python2.7/binhex.pyR$fscGsdS(N((RR,((s/usr/lib64/python2.7/binhex.pytwriteiscCsdS(N((R((s/usr/lib64/python2.7/binhex.pyR'ls(RRRR$R.R'(((s/usr/lib64/python2.7/binhex.pyRbs   t_HqxcoderenginecBs2eZdZdZdZdZdZRS(s(Write data to the coder in 3-byte chunkscCs,||_d|_d|_td|_dS(NR-i(tofpR)thqxdatatLINELENtlinelen(RR0((s/usr/lib64/python2.7/binhex.pyRrs   cCs~|j||_t|j}|dd}|j| }|j||_|sTdS|jtj||_|jddS(Nii(R)tlenR1tbinasciitb2a_hqxt_flush(RR)tdatalenttodo((s/usr/lib64/python2.7/binhex.pyR.xs cCsd}xZ|t|j|jkrb||j}|jj|j||!dt|_|}q W|j||_|r|jj|jdndS(Nis s: (R4R1R3R0R.R2(Rtforcetfirsttlast((s/usr/lib64/python2.7/binhex.pyR7s   cCsL|jr(|jtj|j|_n|jd|jj|`dS(Ni(R)R1R5R6R7R0R'(R((s/usr/lib64/python2.7/binhex.pyR's    (RRt__doc__RR.R7R'(((s/usr/lib64/python2.7/binhex.pyR/os   t_RlecoderenginecBs)eZdZdZdZdZRS(s4Write data to the RLE-coder in suitably large chunkscCs||_d|_dS(NR-(R0R)(RR0((s/usr/lib64/python2.7/binhex.pyRs cCsX|j||_t|jtkr)dStj|j}|jj|d|_dS(NR-(R)R4tREASONABLY_LARGER5t rlecode_hqxR0R.(RR)trledata((s/usr/lib64/python2.7/binhex.pyR.s cCsE|jr.tj|j}|jj|n|jj|`dS(N(R)R5R@R0R.R'(RRA((s/usr/lib64/python2.7/binhex.pyR's   (RRR=RR.R'(((s/usr/lib64/python2.7/binhex.pyR>s  tBinHexcBsPeZdZdZdZdZdZdZdZdZ RS(c Cs|\}}}}t|tdkrB|}t|d}n|jdt|}t||_d|_|dkrt}n||_ ||_ |j ||t |_ dS(NR-tws0(This file must be converted with BinHex 4.0) :i(ttypeR R.R/R>R0tcrctNoneRRRt _writeinfot _DID_HEADERtstate( Rtname_finfo_dlen_rlenR0RRRRtofnamethqxer((s/usr/lib64/python2.7/binhex.pyRs       c Cst|}|dkr$tdnt||d}|j|j}tjd|j}tjd|j|j }||||}|j ||j dS(Ni?sFilename too longts>hs>ii( R4RtchrRRtstructtpackRRRt_writet _writecrc( RRRtnltdtd2td3td4tinfo((s/usr/lib64/python2.7/binhex.pyRGs    cCs,tj||j|_|jj|dS(N(R5tcrc_hqxRER0R.(RR)((s/usr/lib64/python2.7/binhex.pyRQscCsJ|jdkrd}nd}|jjtj||jd|_dS(Nis>hs>H(RER0R.RORP(Rtfmt((s/usr/lib64/python2.7/binhex.pyRRs  cCsB|jtkrtdn|jt||_|j|dS(NsWriting data at the wrong time(RIRHRRR4RQ(RR)((s/usr/lib64/python2.7/binhex.pyR.s cCs<|jdkr%td|jfn|jt|_dS(NisIncorrect data size, diff=%r(RRRRRt _DID_DATARI(R((s/usr/lib64/python2.7/binhex.pyt close_datas cCs^|jtkr|jn|jtkr7tdn|jt||_|j|dS(Ns'Writing resource data at the wrong time(RIR[R\RRR4RQ(RR)((s/usr/lib64/python2.7/binhex.pyt write_rsrcs   cCs|jtkr|jn|jtkr7tdn|jdkr\td|jfn|j|jjd|_|`dS(NsClose at the wrong timeis$Incorrect resource-datasize, diff=%r( RIR[R\RRRRR0R'RF(R((s/usr/lib64/python2.7/binhex.pyR's     ( RRRRGRQRRR.R\R]R'(((s/usr/lib64/python2.7/binhex.pyRBs      cCst|}t||}t|d}x)|jd}|sFPn|j|q-|j|jt|d}x)|jd}|sPn|j|q||j|jdS(s@(infilename, outfilename) - Create binhex-encoded copy of a fileRiN( RRBR R$R.R\R'RR](tinptoutRR0tifpRT((s/usr/lib64/python2.7/binhex.pyRs$    t_HqxdecoderenginecBs)eZdZdZdZdZRS(s*Read data via the decoder in 4-byte chunkscCs||_d|_dS(Ni(R`teof(RR`((s/usr/lib64/python2.7/binhex.pyRs cCsd}|}x|dkr|jr(|S|ddd}|jj|}xeytj|\}|_PWntjk rnX|jjd}|stdn||}qO||}|t|}| r|j rtdqqW|S(s&Read at least wtd bytes (or until EOF)R-iiiiisPremature EOF on binhex file(RbR`R$R5ta2b_hqxt IncompleteRR4(RttotalwtdtdecdatatwtdR)t decdatacurtnewdata((s/usr/lib64/python2.7/binhex.pyR$s.    cCs|jjdS(N(R`R'(R((s/usr/lib64/python2.7/binhex.pyR'9s(RRR=RR$R'(((s/usr/lib64/python2.7/binhex.pyRas  "t_RledecoderenginecBs2eZdZdZdZdZdZRS(sRead data via the RLE-codercCs(||_d|_d|_d|_dS(NR-i(R`t pre_buffert post_bufferRb(RR`((s/usr/lib64/python2.7/binhex.pyR?s   cCsS|t|jkr2|j|t|jn|j| }|j||_|S(N(R4Rlt_fill(RRgtrv((s/usr/lib64/python2.7/binhex.pyR$Es  cCs$|j|jj|d|_|jjrU|jtj|j|_d|_dSt|j}|jdtdtkr|d}nd|jdtkr|d}nD|jdtdkr|d}n |jdtkrn |d }|jtj|j| |_|j||_dS( NiR-iRMiiiii( RkR`R$RbRlR5t rledecode_hqxR4tRUNCHAR(RRgtmark((s/usr/lib64/python2.7/binhex.pyRmLs&        cCs|jjdS(N(R`R'(R((s/usr/lib64/python2.7/binhex.pyR'os(RRR=RR$RmR'(((s/usr/lib64/python2.7/binhex.pyRj<s    #tHexBincBsPeZdZdZdZdZdZdZdZdZ RS(cCst|tdkr't|}nxa|jd}|sKtdn|dkr]q*n|dkrmPn|dkr*|j}q*q*t|}t||_d|_|j dS(NR-isNo binhex data founds R"s i( RDR R$RtreadlineRaRjR`REt _readheader(RR`tchtdummythqxifp((s/usr/lib64/python2.7/binhex.pyRss       cCs.|jj|}tj||j|_|S(N(R`R$R5RYRE(RR4R)((s/usr/lib64/python2.7/binhex.pyt_readscCsktjd|jjddd@}|jd@|_||jkr^td|j|fnd|_dS(Ns>hiiisCRC error, computed %x, read %x(ROtunpackR`R$RER(Rtfilecrc((s/usr/lib64/python2.7/binhex.pyt _checkcrcs &cCs|jd}|jt|}|jd}|j|dd!}|dd!}tjd|dd!d}tjd |dd !d|_tjd |d d !d|_||_t|_||j_ ||j_ ||j_ t |_ dS(Niiiii s>hi is>liiii i ii(RxR&R{RORyRRtFNameRRRRRHRI(RR4tfnametrestRDtcreatortflags((s/usr/lib64/python2.7/binhex.pyRts          cGs|jtkrtdn|r@|d}t||j}n |j}d}x3t||kr||j|t|}qRW|j||_|S(NsRead data at wrong timeiR-(RIRHRtminRR4Rx(RtnRn((s/usr/lib64/python2.7/binhex.pyR$s   !cCsP|jtkrtdn|jr9|j|j}n|jt|_dS(Nsclose_data at wrong time(RIRHRRRxR{R[(RRv((s/usr/lib64/python2.7/binhex.pyR\s    cGs|jtkr|jn|jtkr7tdn|r\|d}t||j}n |j}|j||_|j|S(Ns Read resource data at wrong timei(RIRHR\R[RRRRx(RR((s/usr/lib64/python2.7/binhex.pyt read_rsrcs    cCsB|jr|j|j}n|jt|_|jjdS(N(RRR{t _DID_RSRCRIR`R'(RRv((s/usr/lib64/python2.7/binhex.pyR's    ( RRRRxR{RtR$R\RR'(((s/usr/lib64/python2.7/binhex.pyRrrs      cCst|}|j}|s'|j}nt|d}x)|jd}|sRPn|j|q9|j|j|jd}|rt |d}|j|x)|jd}|sPn|j|q|jn|jdS(s0(infilename, outfilename) - Decode binhexed filetwbiN( RrRR|R R$R.R'R\RR(R^R_R`RR0RT((s/usr/lib64/python2.7/binhex.pyRs.       cCsDtjd}t||dt|d|dtjddS(Nis.hqxs.viahqx(tsystargvRRtexit(R}((s/usr/lib64/python2.7/binhex.pyt_tests t__main__((((((((("R=RR ROR5t__all__t ExceptionRtrangeRHR[RR?R2RNRpt Carbon.FileRRtMacOSRRRt ImportErrorR/R>RBRRaRjRrRRR(((s/usr/lib64/python2.7/binhex.pyts<         'N ,6f