Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/binhex.cpython-35.pyc



��Yf�6�@s9dZddlZddlZddlZddlZdddgZGdd�de�ZdZdZ	dZ
d	Zd
ZGdd�d�Z
d
d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�ZdS)z�Macintosh binhex compression/decompression.

easy interface:
binhex(inputfilename, outputfilename)
hexbin(inputfilename, outputfilename)
�N�binhex�hexbin�Errorc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�+/opt/alt/python35/lib64/python3.5/binhex.pyrs�i��@s�c@seZdZdd�ZdS)�FInfocCsd|_d|_d|_dS)Nz????r)�Type�Creator�Flags)�selfrrr	�__init__0s		zFInfo.__init__N)rrrrrrrr	r/srcCs�t�}tj|d��G}|jd�}d|krBd|_|jdd�|j�}WdQRXtjj	|�\}}|j
ddd�}|||dfS)	N�rbirZTEXT��:�-r
)r�io�open�readr
�seek�tell�os�path�split�replace)�name�finfo�fp�dataZdsize�dir�filerrr	�getfileinfo5s		r%c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�openrsrccGsdS)Nr)r�argsrrr	rCszopenrsrc.__init__cGsdS)N�r)rr'rrr	rFsz
openrsrc.readcGsdS)Nr)rr'rrr	�writeIszopenrsrc.writecCsdS)Nr)rrrr	�closeLszopenrsrc.closeN)rrrrrr)r*rrrr	r&Bsr&c@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_Hqxcoderenginez(Write data to the coder in 3-byte chunkscCs,||_d|_d|_td|_dS)Nr(r
)�ofpr"�hqxdata�LINELEN�linelen)rr,rrr	rRs			z_Hqxcoderengine.__init__cCs�|j||_t|j�}|dd}|jd|�}|j|d�|_|s`dS|jtj|�|_|jd�dS)N�r)r"�lenr-�binascii�b2a_hqx�_flush)rr"ZdatalenZtodorrr	r)Xsz_Hqxcoderengine.writecCs�d}x]|t|j�|jkre||j}|jj|j||�d�t|_|}q	W|j|d�|_|r�|jj|jd�dS)Nrs
s:
)r1r-r/r,r)r.)rZforce�firstZlastrrr	r4cs
!	
z_Hqxcoderengine._flushcCsI|jr%|jtj|j�|_|jd�|jj�|`dS)Nr
)r"r-r2r3r4r,r*)rrrr	r*ns
	

z_Hqxcoderengine.closeN)rrr�__doc__rr)r4r*rrrr	r+Os
r+c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�_Rlecoderenginez4Write data to the RLE-coder in suitably large chunkscCs||_d|_dS)Nr()r,r")rr,rrr	rxs	z_Rlecoderengine.__init__cCsX|j||_t|j�tkr)dStj|j�}|jj|�d|_dS)Nr()r"r1�REASONABLY_LARGEr2�rlecode_hqxr,r))rr"�rledatarrr	r)|sz_Rlecoderengine.writecCsB|jr+tj|j�}|jj|�|jj�|`dS)N)r"r2r9r,r)r*)rr:rrr	r*�s
	
z_Rlecoderengine.closeN)rrrr6rr)r*rrrr	r7usr7c@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�BinHexc
	Cs�|\}}}}d}t|t�rE|}tj|d�}d}yu|jd�t|�}	t|	�|_d|_|dkr�t	�}||_
||_|j||�t
|_Wn|r�|j��YnXdS)NF�wbTs0(This file must be converted with BinHex 4.0)

:r)�
isinstance�strrrr)r+r7r,�crcr�dlen�rlen�
_writeinfo�_DID_HEADER�stater*)
rZname_finfo_dlen_rlenr,rr r@rAZclose_on_errorZofnameZhqxerrrr	r�s*
				

zBinHex.__init__cCs�t|�}|dkr$td��t|g�|jd�d}|j|j}}t|t�ru|jd�}t|t�r�|jd�}||}tj	d|j
�}tj	d|j|j�}	||||	}
|j
|
�|j�dS)N�?zFilename too longzlatin-1sz>hz>ii)r1r�bytes�encoder
rr=r>�struct�packrr@rA�_write�	_writecrc)rrr �nl�d�tpZcrZd2Zd3Zd4�inforrr	rB�s 

zBinHex._writeinfocCs,tj||j�|_|jj|�dS)N)r2�crc_hqxr?r,r))rr"rrr	rJ�sz
BinHex._writecCsJ|jdkrd}nd}|jjtj||j��d|_dS)Nrz>hz>H)r?r,r)rHrI)rZfmtrrr	rK�s
	zBinHex._writecrccCsB|jtkrtd��|jt|�|_|j|�dS)NzWriting data at the wrong time)rDrCrr@r1rJ)rr"rrr	r)�szBinHex.writecCs<|jdkr%td|jf��|j�t|_dS)NrzIncorrect data size, diff=%r)r@rrArK�	_DID_DATArD)rrrr	�
close_data�s
zBinHex.close_datacCs[|jtkr|j�|jtkr4td��|jt|�|_|j|�dS)Nz'Writing resource data at the wrong time)rDrQrRrrAr1rJ)rr"rrr	�
write_rsrc�s
zBinHex.write_rsrccCs�|jdkrdSzg|jtkr/|j�|jtkrJtd��|jdkrotd|jf��|j�Wdd|_|j}|`|j�XdS)NzClose at the wrong timerz$Incorrect resource-datasize, diff=%r)rDrQrRrrArKr,r*)rr,rrr	r*�s
		zBinHex.closeN)rrrrrBrJrKr)rRrSr*rrrr	r;�s
r;c
Cs�t|�}t||�}tj|d��;}x'|jd�}|sIP|j|�q3W|j�WdQRXt|d�}x'|jd�}|s�P|j|�q}W|j	�|j	�dS)zEbinhex(infilename, outfilename): create binhex-encoded copy of a fileri�N)
r%r;rrrr)rRr&rSr*)�inp�outr r,�ifprMrrr	r�s"
c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�_Hqxdecoderenginez*Read data via the decoder in 4-byte chunkscCs||_d|_dS)Nr)rV�eof)rrVrrr	rs	z_Hqxdecoderengine.__init__cCs�d}|}x�|dkr�|jr(|S|ddd}|jj|�}xgytj|�\}|_PWntjk
r�YnX|jjd�}|s�td��||}qOW||}|t|�}|r|jrtd��qW|S)z&Read at least wtd bytes (or until EOF)r(rrr0�r
zPremature EOF on binhex file)rXrVrr2Za2b_hqxZ
Incompleterr1)rZtotalwtdZdecdata�wtdr"Z
decdatacur�newdatarrr	rs,	
z_Hqxdecoderengine.readcCs|jj�dS)N)rVr*)rrrr	r*%sz_Hqxdecoderengine.closeN)rrrr6rrr*rrrr	rW�s rWc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_RledecoderenginezRead data via the RLE-codercCs(||_d|_d|_d|_dS)Nr(r)rV�
pre_buffer�post_bufferrX)rrVrrr	r+s			z_Rledecoderengine.__init__cCs\|t|j�kr/|j|t|j��|jd|�}|j|d�|_|S)N)r1r^�_fill)rrZ�rvrrr	r1s
z_Rledecoderengine.readcCsH|j|jj|d�|_|jjrU|jtj|j�|_d|_dSt|j�}|jdd�tdtkr�|d}nv|jdd�tkr�|d}nP|jd	d�tdkr�|d}n&|jd
d�tkr�n
|d}|jtj|jd|��|_|j|d�|_dS)NrYr(r0sr
r���������rcrb)	r]rVrrXr^r2Z
rledecode_hqxr1�RUNCHAR)rrZZmarkrrr	r_8s& 	
!



 z_Rledecoderengine._fillcCs|jj�dS)N)rVr*)rrrr	r*[sz_Rledecoderengine.closeN)rrrr6rrr_r*rrrr	r\(s
#r\c@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HexBincCs�t|t�r!tj|d�}xA|jd�}|sEtd��|dkrTq$|dkr$Pq$Wt|�}t|�|_d|_	|j
�dS)Nrr
zNo binhex data founds
�:r)r=r>rrrrrWr\rVr?�_readheader)rrVZchZhqxifprrr	r_s	zHexBin.__init__cCs.|jj|�}tj||j�|_|S)N)rVrr2rPr?)rr1r"rrr	�_readuszHexBin._readcCsktjd|jjd��dd@}|jd@|_||jkr^td|j|f��d|_dS)Nz>hrri��zCRC error, computed %x, read %x)rH�unpackrVrr?r)rZfilecrcrrr	�	_checkcrczs&zHexBin._checkcrccCs	|jd�}|jt|��}|jd�}|j�|dd�}|dd�}tjd|dd��d}tjd	|dd
��d|_tjd	|d
d��d|_||_t�|_||j_	||j_
||j_t|_
dS)Nr
rYr��	z>h�rz>l��rkrlrmrnro)rh�ordrjrHrir@rA�FNamerrr
rrCrD)rr1Zfname�rest�typeZcreator�flagsrrr	rg�s
 ##	zHexBin._readheadercGs�|jtkrtd��|r@|d}t||j�}n	|j}d}x3t|�|kr�||j|t|��}qRW|j||_|S)NzRead data at wrong timerr()rDrCr�minr@r1rh)r�nr`rrr	r�s
	!zHexBin.readcCsM|jtkrtd��|jr6|j|j�}|j�t|_dS)Nzclose_data at wrong time)rDrCrr@rhrjrQ)r�dummyrrr	rR�s	
zHexBin.close_datacGs|jtkr|j�|jtkr4td��|rY|d}t||j�}n	|j}|j||_|j|�S)Nz Read resource data at wrong timer)rDrCrRrQrrurArh)rrvrrr	�	read_rsrc�s

	zHexBin.read_rsrccCsZ|jdkrdSz)|jr1|j|j�}|j�Wdd|_|jj�XdS)N)rDrArxrjrVr*)rrwrrr	r*�s		zHexBin.closeN)rrrrrhrjrgrrRrxr*rrrr	re^s

rec
Cs�t|�}|j}|s$|j}tj|d��1}x'|jd�}|sRP|j|�q<WWdQRX|j�|jd�}|r�t	|d�}|j|�x'|jd�}|s�P|j|�q�W|j
�|j
�dS)z6hexbin(infilename, outfilename) - Decode binhexed filer<i�N)rerrqrrrr)rRrxr&r*)rTrUrVr r,rMrrr	r�s,		


)r6rrrHr2�__all__�	ExceptionrrCrQr8r.rdrr%r&r+r7r;rrWr\rerrrrr	�<module>s,

&^*6h

Hacked By AnonymousFox1.0, Coded By AnonymousFox