usr/lib64/python2.7/binhex.pyc000064400000036144147204474620012061 0ustar00 zfc@sdZddlZddlZddlZddlZdddgZdefdYZdZdZ d Z d Z e d Z y<dd lmZmZdd lmZdZdZWn@ek rdd%dYZdZdd&dYZnXdd'dYZdd(dYZdd)dYZdZdd*dYZdd+dYZd d,d!YZd"Zd#Zed$krendS(-sMacintosh binhex compression/decompression. easy interface: binhex(inputfilename, outputfilename) hexbin(inputfilename, outputfilename) iNtbinhexthexbintErrorcBseZRS((t__name__t __module__(((s/usr/lib64/python2.7/binhex.pyRsiiii@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 getfileinfo4s  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__Ms  (RRR(((s/usr/lib64/python2.7/binhex.pyRLscCst}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.pyRRs   +   RcBs,eZdZdZdZdZRS(cGsdS(N((Rtargs((s/usr/lib64/python2.7/binhex.pyRdscGsdS(Nt((RR,((s/usr/lib64/python2.7/binhex.pyR$gscGsdS(N((RR,((s/usr/lib64/python2.7/binhex.pytwritejscCsdS(N((R((s/usr/lib64/python2.7/binhex.pyR'ms(RRRR$R.R'(((s/usr/lib64/python2.7/binhex.pyRcs   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.pyRss   cCs~|j||_t|j}|dd}|j| }|j||_|sTdS|jtj||_|jddS(Nii(R)tlenR1tbinasciitb2a_hqxt_flush(RR)tdatalenttodo((s/usr/lib64/python2.7/binhex.pyR.ys 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/ps   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 longss>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.pyRPscCsJ|jdkrd}nd}|jjtj||jd|_dS(Nis>hs>H(RER0R.RNRO(Rtfmt((s/usr/lib64/python2.7/binhex.pyRQs  cCsB|jtkrtdn|jt||_|j|dS(NsWriting data at the wrong time(RIRHRRR4RP(RR)((s/usr/lib64/python2.7/binhex.pyR.s cCs<|jdkr%td|jfn|jt|_dS(NisIncorrect data size, diff=%r(RRRRQt _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(RIRZR[RRR4RP(RR)((s/usr/lib64/python2.7/binhex.pyt write_rsrcs   cCs|jdkrdSzj|jtkr2|jn|jtkrMtdn|jdkrrtd|jfn|jWdd|_|j}|`|jXdS(NsClose at the wrong timeis$Incorrect resource-datasize, diff=%r( RIRFRZR[RRRQR0R'(RR0((s/usr/lib64/python2.7/binhex.pyR's    ( RRRRGRPRQR.R[R\R'(((s/usr/lib64/python2.7/binhex.pyRBs      cCst|}t||}t|d}x*|jd}|sFPn|j|q-W|j|jt|d}x*|jd}|sPn|j|q}W|j|jdS(s@(infilename, outfilename) - Create binhex-encoded copy of a fileRiN( RRBR R$R.R[R'RR\(tinptoutRR0tifpRS((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|}xfytj|\}|_PWntjk rnX|jjd}|stdn||}qOW||}|t|}| r|j rtdqqW|S(s&Read at least wtd bytes (or until EOF)R-iiiiisPremature EOF on binhex file(RaR_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'?s(RRR=RR$R'(((s/usr/lib64/python2.7/binhex.pyR`s  "t_RledecoderenginecBs2eZdZdZdZdZdZRS(sRead data via the RLE-codercCs(||_d|_d|_d|_dS(NR-i(R_t pre_buffert post_bufferRa(RR_((s/usr/lib64/python2.7/binhex.pyREs   cCsS|t|jkr2|j|t|jn|j| }|j||_|S(N(R4Rkt_fill(RRftrv((s/usr/lib64/python2.7/binhex.pyR$Ks  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-isiiiii( RjR_R$RaRkR5t rledecode_hqxR4tRUNCHAR(RRftmark((s/usr/lib64/python2.7/binhex.pyRlRs&        cCs|jjdS(N(R_R'(R((s/usr/lib64/python2.7/binhex.pyR'us(RRR=RR$RlR'(((s/usr/lib64/python2.7/binhex.pyRiBs    #tHexBincBsPeZdZdZdZdZdZdZdZdZ RS(cCst|tdkr't|}nxb|jd}|sKtdn|dkr]q*n|dkrmPn|dkr*|j}q*q*Wt|}t||_d|_|j dS(NR-isNo binhex data founds R"s i( RDR R$RtreadlineR`RiR_REt _readheader(RR_tchtdummythqxifp((s/usr/lib64/python2.7/binhex.pyRys       cCs.|jj|}tj||j|_|S(N(R_R$R5RXRE(RR4R)((s/usr/lib64/python2.7/binhex.pyt_readscCsktjd|jjddd@}|jd@|_||jkr^td|j|fnd|_dS(Ns>hiiisCRC error, computed %x, read %x(RNtunpackR_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(RwR&RzRNRxRRtFNameRRRRRHRI(RR4tfnametrestRDtcreatortflags((s/usr/lib64/python2.7/binhex.pyRss          cGs|jtkrtdn|r@|d}t||j}n |j}d}x3t||kr||j|t|}qRW|j||_|S(NsRead data at wrong timeiR-(RIRHRtminRR4Rw(RtnRm((s/usr/lib64/python2.7/binhex.pyR$s   !cCsP|jtkrtdn|jr9|j|j}n|jt|_dS(Nsclose_data at wrong time(RIRHRRRwRzRZ(RRu((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[RZRRRRw(RR((s/usr/lib64/python2.7/binhex.pyt read_rsrcs    cCs]|jdkrdSz,|jr4|j|j}n|jWdd|_|jjXdS(N(RIRFRRRzR_R'(RRu((s/usr/lib64/python2.7/binhex.pyR's  ( RRRRwRzRsR$R[RR'(((s/usr/lib64/python2.7/binhex.pyRqxs      cCst|}|j}|s'|j}nt|d}x*|jd}|sRPn|j|q9W|j|j|jd}|rt |d}|j|x*|jd}|sPn|j|qW|jn|jdS(s0(infilename, outfilename) - Decode binhexed filetwbiN( RqRR{R R$R.R'R[RR(R]R^R_RR0RS((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 RNR5t__all__t ExceptionRRHRZR?R2RMRot Carbon.FileRRtMacOSRRRt ImportErrorR/R>RBRR`RiRqRRR(((s/usr/lib64/python2.7/binhex.pyts>         'S ,6j