• File: binhex.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/binhex.pyc
  • Date Modified: 10/26/2026 8:10 PM
  • File size: 15.75 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

jc@sdZddlZddlZddlZddlZdddgZdefdYZdZdZ	d	Z
d
ZedZ
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+/opt/alt/python27/lib64/python2.7/binhex.pyRsiiii@i(tFSSpectFInfo(topenrfcCst|j}tjj|\}}t|d}|jdd|j}t|d}|jdd|j}||||fS(Ntrbiis*rb(	RtFSpGetFInfotostpathtsplittopentseekttellR(tnametfinfotdirtfiletfptdlentrlen((s+/opt/alt/python27/lib64/python2.7/binhex.pytgetfileinfo4scGs*|sd}nd|d}t||S(Ns*rbt*i(R(Rtmode((s+/opt/alt/python27/lib64/python2.7/binhex.pytopenrsrc@s	RcBseZdZRS(cCsd|_d|_d|_dS(Ns????i(tTypetCreatortFlags(tself((s+/opt/alt/python27/lib64/python2.7/binhex.pyt__init__Ms		(RRR(((s+/opt/alt/python27/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
RRtreplace(RRRtdatatctdsizeRR((s+/opt/alt/python27/lib64/python2.7/binhex.pyRRs	
+	
RcBs,eZdZdZdZdZRS(cGsdS(N((Rtargs((s+/opt/alt/python27/lib64/python2.7/binhex.pyRdscGsdS(Nt((RR,((s+/opt/alt/python27/lib64/python2.7/binhex.pyR$gscGsdS(N((RR,((s+/opt/alt/python27/lib64/python2.7/binhex.pytwritejscCsdS(N((R((s+/opt/alt/python27/lib64/python2.7/binhex.pyR'ms(RRRR$R.R'(((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRss			cCs~|j||_t|j}|dd}|j| }|j||_|sTdS|jtj||_|jddS(Nii(R)tlenR1tbinasciitb2a_hqxt_flush(RR)tdatalenttodo((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyR7s
	
cCsL|jr(|jtj|j|_n|jd|jj|`dS(Ni(R)R1R5R6R7R0R'(R((s+/opt/alt/python27/lib64/python2.7/binhex.pyR's
	

(RRt__doc__RR.R7R'(((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRs	cCsX|j||_t|jtkr)dStj|j}|jj|d|_dS(NR-(R)R4tREASONABLY_LARGER5trlecode_hqxR0R.(RR)trledata((s+/opt/alt/python27/lib64/python2.7/binhex.pyR.scCsE|jr.tj|j}|jj|n|jj|`dS(N(R)R5R@R0R.R'(RRA((s+/opt/alt/python27/lib64/python2.7/binhex.pyR's
	
(RRR=RR.R'(((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRs
			c	Cst|}|dkr$tdnt||d}|j|j}tjd|j}tjd|j|j	}||||}|j
||jdS(Ni?sFilename too longss>hs>ii(R4RtchrRRtstructtpackRRRt_writet	_writecrc(	RRRtnltdtd2td3td4tinfo((s+/opt/alt/python27/lib64/python2.7/binhex.pyRGs
cCs,tj||j|_|jj|dS(N(R5tcrc_hqxRER0R.(RR)((s+/opt/alt/python27/lib64/python2.7/binhex.pyRPscCsJ|jdkrd}nd}|jjtj||jd|_dS(Nis>hs>H(RER0R.RNRO(Rtfmt((s+/opt/alt/python27/lib64/python2.7/binhex.pyRQs
	cCsB|jtkrtdn|jt||_|j|dS(NsWriting data at the wrong time(RIRHRRR4RP(RR)((s+/opt/alt/python27/lib64/python2.7/binhex.pyR.scCs<|jdkr%td|jfn|jt|_dS(NisIncorrect data size, diff=%r(RRRRQt	_DID_DATARI(R((s+/opt/alt/python27/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+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyR's
		(
RRRRGRPRQR.R[R\R'(((s+/opt/alt/python27/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+/opt/alt/python27/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+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyR$s.		
cCs|jjdS(N(R_R'(R((s+/opt/alt/python27/lib64/python2.7/binhex.pyR'?s(RRR=RR$R'(((s+/opt/alt/python27/lib64/python2.7/binhex.pyR`s		"t_RledecoderenginecBs2eZdZdZdZdZdZRS(sRead data via the RLE-codercCs(||_d|_d|_d|_dS(NR-i(R_t
pre_buffertpost_bufferRa(RR_((s+/opt/alt/python27/lib64/python2.7/binhex.pyREs			cCsS|t|jkr2|j|t|jn|j| }|j||_|S(N(R4Rkt_fill(RRftrv((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRlRs& 	




cCs|jjdS(N(R_R'(R((s+/opt/alt/python27/lib64/python2.7/binhex.pyR'us(RRR=RR$RlR'(((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRys 	cCs.|jj|}tj||j|_|S(N(R_R$R5RXRE(RR4R)((s+/opt/alt/python27/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+/opt/alt/python27/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>hiis>liiii	iii(RwR&RzRNRxRRtFNameRRRRRHRI(RR4tfnametrestRDtcreatortflags((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyR$s
	!cCsP|jtkrtdn|jr9|j|j}n|jt|_dS(Nsclose_data at wrong time(RIRHRRRwRzRZ(RRu((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyt	read_rsrcs

	cCs]|jdkrdSz,|jr4|j|j}n|jWdd|_|jjXdS(N(RIRFRRRzR_R'(RRu((s+/opt/alt/python27/lib64/python2.7/binhex.pyR's		(
RRRRwRzRsR$R[RR'(((s+/opt/alt/python27/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+/opt/alt/python27/lib64/python2.7/binhex.pyRs.	



cCsDtjd}t||dt|d|dtjddS(Nis.hqxs.viahqx(tsystargvRRtexit(R|((s+/opt/alt/python27/lib64/python2.7/binhex.pyt_tests
t__main__((((((((( R=RR
RNR5t__all__t	ExceptionRRHRZR?R2RMRotCarbon.FileRRtMacOSRRRtImportErrorR/R>RBRR`RiRqRRR(((s+/opt/alt/python27/lib64/python2.7/binhex.pyt<module>s>	

	
'S	,6j