AlkantarClanX12

Your IP : 3.12.154.133


Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/binhex.cpython-38.pyc

U

i�f�6�@s�dZddlZddlZddlZddlZdddgZGdd�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@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�+/opt/alt/python38/lib64/python3.8/binhex.pyrs�i��@��c@seZdZdd�ZdS)�FInfocCsd|_d|_d|_dS)Nz????r)�Type�Creator�Flags��selfrrr	�__init__0szFInfo.__init__N)rrrrrrrr	r
/sr
c	Cstt�}t�|d��2}|�d�}d|kr,d|_|�dd�|��}W5QRXtj�	|�\}}|�
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�rr*rrr	rFsz
openrsrc.readcGsdSr)rr*rrr	�writeIszopenrsrc.writecCsdSr)rrrrr	�closeLszopenrsrc.closeN)rrrrrr.r/rrrr	r(Bsr(c@s0eZdZdZdd�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�rr1rrr	rRsz_Hqxcoderengine.__init__cCsh|j||_t|j�}|dd}|jd|�}|j|d�|_|sHdS|jt�|�|_|�d�dS)N�r)r$�lenr2�binascii�b2a_hqx�_flush)rr$ZdatalenZtodorrr	r.Xs
z_Hqxcoderengine.writecCsrd}|t|j�|jkrH||j}|j�|j||�d�t|_|}q|j|d�|_|rn|j�|jd�dS)Nr�
s:
)r7r2r4r1r.r3)rZforce�firstZlastrrr	r:cs
z_Hqxcoderengine._flushcCs6|jr|jt�|j�|_|�d�|j��|`dS)Nr
)r$r2r8r9r:r1r/rrrr	r/ns


z_Hqxcoderengine.closeN)rrr�__doc__rr.r:r/rrrr	r0Os
r0c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_Rlecoderenginez4Write data to the RLE-coder in suitably large chunkscCs||_d|_dSr,)r1r$r5rrr	rxsz_Rlecoderengine.__init__cCs@|j||_t|j�tkrdSt�|j�}|j�|�d|_dSr,)r$r7�REASONABLY_LARGEr8�rlecode_hqxr1r.)rr$�rledatarrr	r.|sz_Rlecoderengine.writecCs0|jrt�|j�}|j�|�|j��|`dSr))r$r8r@r1r.r/)rrArrr	r/�s

z_Rlecoderengine.closeN)rrrr=rr.r/rrrr	r>usr>c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�BinHexc
Cs�|\}}}}d}t|t�r.|}t�|d�}d}zR|�d�t|�}	t|	�|_d|_|dkr`t	�}||_
||_|�||�t
|_Wn|r�|���YnXdS)NF�wbTs0(This file must be converted with BinHex 4.0)

:r)�
isinstance�strrrr.r0r>r1�crcr
�dlen�rlen�
_writeinfo�_DID_HEADER�stater/)
rZname_finfo_dlen_rlenr1r!r"rGrHZclose_on_errorZofnameZhqxerrrr	r�s*



zBinHex.__init__cCs�t|�}|dkrtd��t|g�|�d�d}|j|j}}t|t�rR|�d�}t|t�rf|�d�}||}t�	d|j
�}t�	d|j|j�}	||||	}
|�
|
�|��dS)N�?zFilename too longzlatin-1��>hz>ii)r7r�bytes�encoderrrDrE�struct�packrrGrH�_write�	_writecrc)rr!r"�nl�d�tpZcrZd2Zd3Zd4�inforrr	rI�s




zBinHex._writeinfocCs t�||j�|_|j�|�dSr))r8�crc_hqxrFr1r.�rr$rrr	rS�sz
BinHex._writecCs4|jdkrd}nd}|j�t�||j��d|_dS)NrrNz>H)rFr1r.rQrR)rZfmtrrr	rT�s

zBinHex._writecrccCs0|jtkrtd��|jt|�|_|�|�dS)NzWriting data at the wrong time)rKrJrrGr7rSrZrrr	r.�s
zBinHex.writecCs,|jdkrtd|jf��|��t|_dS)NrzIncorrect data size, diff=%r)rGrrHrT�	_DID_DATArKrrrr	�
close_data�s
zBinHex.close_datacCsB|jtkr|��|jtkr$td��|jt|�|_|�|�dS)Nz'Writing resource data at the wrong time)rKr[r\rrHr7rSrZrrr	�
write_rsrc�s

zBinHex.write_rsrccCsx|jdkrdSzJ|jtkr"|��|jtkr4td��|jdkrNtd|jf��|��W5d|_|j}|`|��XdS)NzClose at the wrong timerz$Incorrect resource-datasize, diff=%r)rKr1r/r[r\rrHrTr5rrr	r/�s



zBinHex.closeN)rrrrrIrSrTr.r\r]r/rrrr	rB�s
rBc	Cs�t|�}t||�}t�|d��*}|�d�}|s0q<|�|�q |��W5QRXt|d�}|�d�}|shqt|�|�qX|�	�|�	�dS)zEbinhex(infilename, outfilename): create binhex-encoded copy of a filer��N)
r'rBrrrr.r\r(r]r/)�inp�outr"r1�ifprVrrr	r�s



c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_Hqxdecoderenginez*Read data via the decoder in 4-byte chunkscCs||_d|_dS)Nr)ra�eof�rrarrr	rsz_Hqxdecoderengine.__init__cCs�d}|}|dkr�|jr|S|ddd}|j�|�}zt�|�\}|_Wq�Wntjk
rdYnX|j�d�}|s~td��||}q6||}|t|�}|s|jstd��q|S)z&Read at least wtd bytes (or until EOF)r-rrr6�r
zPremature EOF on binhex file)rcrarr8Za2b_hqxZ
Incompleterr7)rZtotalwtdZdecdata�wtdr$Z
decdatacur�newdatarrr	rs*


z_Hqxdecoderengine.readcCs|j��dSr)�rar/rrrr	r/%sz_Hqxdecoderengine.closeN)rrrr=rrr/rrrr	rb�s rbc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_RledecoderenginezRead data via the RLE-codercCs||_d|_d|_d|_dS)Nr-r)ra�
pre_buffer�post_bufferrcrdrrr	r+sz_Rledecoderengine.__init__cCsD|t|j�kr"|�|t|j��|jd|�}|j|d�|_|Sr))r7rk�_fill)rrf�rvrrr	r1s
z_Rledecoderengine.readcCs�|j|j�|d�|_|jjr>|jt�|j�|_d|_dSt|j�}|jdd�tdtkrl|d}nX|jdd�tkr�|d}n<|jdd�tdkr�|d}n|jdd�tkr�n|d	}|jt�|jd|��|_|j|d�|_dS)
Nrer-���rMr6���r���r
)	rjrarrcrkr8Z
rledecode_hqxr7�RUNCHAR)rrfZmarkrrr	rl8s*
�



�z_Rledecoderengine._fillcCs|j��dSr)rhrrrr	r/[sz_Rledecoderengine.closeN)rrrr=rrrlr/rrrr	ri(s
#ric@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HexBincCsft|t�rt�|d�}|�d�}|s,td��|dkr6q|dkrqBqt|�}t|�|_d|_	|�
�dS)Nrr
zNo binhex data foundr;�:r)rDrErrrrrbrirarF�_readheader)rraZchZhqxifprrr	r_s


zHexBin.__init__cCs |j�|�}t�||j�|_|Sr))rarr8rYrF)rr7r$rrr	�_readuszHexBin._readcCsNt�d|j�d��dd@}|jd@|_||jkrDtd|j|f��d|_dS)NrNrri��zCRC error, computed %x, read %x)rQ�unpackrarrFr)rZfilecrcrrr	�	_checkcrczs
�zHexBin._checkcrccCs�|�d�}|�t|��}|�d�}|��|dd�}|dd�}t�d|dd��d}t�d|dd	��d|_t�d|d	d��d|_||_t�|_||j_	||j_
||j_t|_
dS)
Nr
���	rN�rz>l�)ru�ordrwrQrvrGrH�FNamer
rrrrJrK)rr7Zfname�rest�typeZcreator�flagsrrr	rt�s

zHexBin._readheadercGsj|jtkrtd��|r,|d}t||j�}n|j}d}t|�|krZ||�|t|��}q6|j||_|S)NzRead data at wrong timerr-)rKrJr�minrGr7ru)r�nrmrrr	r�s
zHexBin.readcCs6|jtkrtd��|jr$|�|j�}|��t|_dS)Nzclose_data at wrong time)rKrJrrGrurwr[�rZdummyrrr	r\�s
zHexBin.close_datacGsZ|jtkr|��|jtkr$td��|r>|d}t||j�}n|j}|j||_|�|�S)Nz Read resource data at wrong timer)rKrJr\r[rr�rHru)rr�rrr	�	read_rsrc�s

zHexBin.read_rsrccCsD|jdkrdSz|jr"|�|j�}|��W5d|_|j��XdSr))rKrar/rHr�rwr�rrr	r/�s
zHexBin.closeN)rrrrrurwrtrr\r�r/rrrr	rr^s

rrc	Cs�t|�}|j}|s|j}t�|d��"}|�d�}|s6qB|�|�q&W5QRX|��|�d�}|r�t	|d�}|�|�|�d�}|s�q�|�|�qv|�
�|�
�dS)z6hexbin(infilename, outfilename) - Decode binhexed filerCr^N)rrr
r~rrrr.r\r�r(r/)r_r`rar"r1rVrrr	r�s(




)r=rrrQr8�__all__�	ExceptionrrJr[r?r3rqr
r'r(r0r>rBrrbrirrrrrrr	�<module>s,


&^*6h