AlkantarClanX12

Your IP : 18.117.75.218


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/binhex.cpython-310.opt-1.pyc

o

6��f�9�@s
dZddlZddlZddlZddlZddlZddlZejdedd�gd�Z	Gdd�de
�ZdZd	Z
d
ZdZdZGd
d�d�Zdd�ZGdd�d�Zejdd��ZGdd�d�ZGdd�d�ZGdd�d�Zdd�ZGdd�d�ZGdd �d �ZGd!d"�d"�Zd#d$�ZdS)%z�Macintosh binhex compression/decompression.

easy interface:
binhex(inputfilename, outputfilename)
hexbin(inputfilename, outputfilename)
�Nzthe binhex module is deprecated�)�
stacklevel)�binhex�hexbin�Errorc@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�-/opt/alt/python310/lib64/python3.10/binhex.pyr%sr�i��@��c@seZdZdd�ZdS)�FInfocCsd|_d|_d|_dS)Nz????r)�Type�Creator�Flags��selfr
r
r�__init__6s
zFInfo.__init__N)rrr	rr
r
r
rr5srcCs�t�}t�|d��}|�d�}d|vrd|_|�dd�|��}Wd�n1s*wYtj�	|�\}}|�
ddd�}|||dfS)	N�rbirZTEXTr�:�-r)r�io�open�readr�seek�tell�os�path�split�replace)�name�finfo�fp�dataZdsize�dir�filer
r
r�getfileinfo;s

�r(c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�openrsrccG�dS�Nr
�r�argsr
r
rrI�zopenrsrc.__init__cGsdS�N�r
r,r
r
rrLr.z
openrsrc.readcGr*r+r
r,r
r
r�writeOr.zopenrsrc.writecCr*r+r
rr
r
r�closeRr.zopenrsrc.closeN)rrr	rrr1r2r
r
r
rr)Hs
r)ccsD�t���t�ddt�dVWd�dS1swYdS)N�ignore�)�warnings�catch_warnings�filterwarnings�DeprecationWarningr
r
r
r�_ignore_deprecation_warningXs
�
"�r9c@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_Hqxcoderenginez(Write data to the coder in 3-byte chunkscCs ||_d|_d|_td|_dS)Nr0r)�ofpr%�hqxdata�LINELEN�linelen�rr<r
r
rrbsz_Hqxcoderengine.__init__cCs�|j||_t|j�}|dd}|jd|�}|j|d�|_|s$dSt��|jt�|�|_Wd�n1s;wY|�d�dS)N�r)r%�lenr9r=�binascii�b2a_hqx�_flush)rr%ZdatalenZtodor
r
rr1hs
�z_Hqxcoderengine.writecCs�d}|t|j�|jkr-||j}|j�|j||�d�t|_|}|t|j�|jks|j|d�|_|rB|j�|jd�dSdS)Nr�
s:
)rBr=r?r<r1r>)rZforce�firstZlastr
r
rrEts
��z_Hqxcoderengine._flushcCs\|jr t��|jt�|j�|_Wd�n1swY|�d�|j��|`dS)Nr)r%r9r=rCrDrEr<r2rr
r
rr2s�

z_Hqxcoderengine.closeN)rrr	�__doc__rr1rEr2r
r
r
rr;_sr;c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�_Rlecoderenginez4Write data to the RLE-coder in suitably large chunkscC�||_d|_dSr/)r<r%r@r
r
rr��
z_Rlecoderengine.__init__cCsf|j||_t|j�tkrdSt��t�|j�}Wd�n1s#wY|j�|�d|_dSr/)r%rB�REASONABLY_LARGEr9rC�rlecode_hqxr<r1)rr%�rledatar
r
rr1�s�
z_Rlecoderengine.writecCsV|jr"t��t�|j�}Wd�n1swY|j�|�|j��|`dSr+)r%r9rCrNr<r1r2)rrOr
r
rr2�s�
z_Rlecoderengine.closeN)rrr	rHrr1r2r
r
r
rrJ�s
	rJc@�LeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�BinHexc
Cs�|\}}}}d}t|t�r|}t�|d�}d}z*|�d�t|�}	t|	�|_d|_|dur0t	�}||_
||_|�||�t
|_WdS|rK|���)NF�wbTs0(This file must be converted with BinHex 4.0)

:r)�
isinstance�strrrr1r;rJr<�crcr�dlen�rlen�
_writeinfo�_DID_HEADER�stater2)
rZname_finfo_dlen_rlenr<r"r#rVrWZclose_on_errorZofnameZhqxerr
r
rr�s*


zBinHex.__init__cCs�t|�}|dkrtd��t|g�|�d�d}|j|j}}t|t�r)|�d�}t|t�r3|�d�}||}t�	d|j
�}t�	d|j|j�}	||||	}
|�
|
�|��dS)N�?zFilename too longzlatin-1��>hz>ii)rBr�bytes�encoderrrSrT�struct�packrrVrW�_write�	_writecrc)rr"r#�nl�d�tpZcrZd2Zd3Zd4�infor
r
rrX�s




zBinHex._writeinfocCs t�||j�|_|j�|�dSr+)rC�crc_hqxrUr<r1�rr%r
r
rrb�sz
BinHex._writecCs4|jdkrd}nd}|j�t�||j��d|_dS)Nrr]z>H)rUr<r1r`ra)rZfmtr
r
rrc�s


zBinHex._writecrccCs0|jtkr	td��|jt|�|_|�|�dS)NzWriting data at the wrong time)rZrYrrVrBrbrir
r
rr1�s
zBinHex.writecCs,|jdkr
td|jf��|��t|_dS)NrzIncorrect data size, diff=%r)rVrrWrc�	_DID_DATArZrr
r
r�
close_data�s

zBinHex.close_datacCsB|jtkr	|��|jtkrtd��|jt|�|_|�|�dS)Nz'Writing resource data at the wrong time)rZrjrkrrWrBrbrir
r
r�
write_rsrc�s

zBinHex.write_rsrccCs�|jdurdSz2|jtkr|��|jtkrtd��|jdkr'td|jf��|��Wd|_|j}|`|��dSd|_|j}|`|��w)NzClose at the wrong timerz$Incorrect resource-datasize, diff=%r)rZrjrkrrWrcr<r2r@r
r
rr2�s$




�
zBinHex.closeN)rrr	rrXrbrcr1rkrlr2r
r
r
rrQ�s
rQcCs�t|�}t||�}t�|d��}	|�d�}|sn|�|�q|��Wd�n1s-wYt|d�}	|�d�}|s@n|�|�q8|�	�|�	�dS)zEbinhex(infilename, outfilename): create binhex-encoded copy of a filerT��N)
r(rQrrrr1rkr)rlr2)�inp�outr#r<�ifprer
r
rr�s$


�
�


�rc@rI)	�_Hqxdecoderenginez*Read data via the decoder in 4-byte chunkscCrK)Nr)rp�eof�rrpr
r
rrrLz_Hqxdecoderengine.__init__cCs�d}|}|dkrl|jr
|S|ddd}|j�|�}	zt��t�|�\}|_Wd�n1s3wYWntjyCYnw|j�d�}|sPtd	��||}q||}|t|�}|sh|jshtd	��|dks|S)
z&Read at least wtd bytes (or until EOF)r0rrrA�TNrzPremature EOF on binhex file)	rrrprr9rCZa2b_hqxZ
IncompleterrB)rZtotalwtdZdecdata�wtdr%Z
decdatacur�newdatar
r
rrs4
���
�z_Hqxdecoderengine.readcC�|j��dSr+�rpr2rr
r
rr2:�z_Hqxdecoderengine.closeN)rrr	rHrrr2r
r
r
rrqs
!rqc@r:)�_RledecoderenginezRead data via the RLE-codercCs||_d|_d|_d|_dS)Nr0r)rp�
pre_buffer�post_bufferrrrsr
r
rr@s
z_Rledecoderengine.__init__cCsD|t|j�kr|�|t|j��|jd|�}|j|d�|_|Sr+)rBr|�_fill)rru�rvr
r
rrFs
z_Rledecoderengine.readcCs@|j|j�|d�|_|jjr2t��|jt�|j�|_Wd�n1s(wYd|_dSt|j�}|jdd�t	dt	krI|d}n,|jdd�t	krW|d}n|jdd�t	dkrg|d}n|jdd�t	krqn|d	}t��|jt�|jd|��|_Wd�n1s�wY|j|d�|_dS)
Nrtr0���r\rA���r���r)
r{rprrrr9r|rCZ
rledecode_hqxrB�RUNCHAR)rruZmarkr
r
rr}Ms2
��




��z_Rledecoderengine._fillcCrwr+rxrr
r
rr2rryz_Rledecoderengine.closeN)rrr	rHrrr}r2r
r
r
rrz=s%rzc@rP)�HexBincCsht|t�rt�|d�}	|�d�}|std��|dkrq|dkr!nqt|�}t|�|_d|_	|�
�dS)NrTrzNo binhex data foundrF�:r)rSrTrrrrrqrzrprU�_readheader)rrpZchZhqxifpr
r
rrvs

�
zHexBin.__init__cCs |j�|�}t�||j�|_|Sr+)rprrCrhrU)rrBr%r
r
r�_read�szHexBin._readcCsNt�d|j�d��dd@}|jd@|_||jkr"td|j|f��d|_dS)Nr]rri��zCRC error, computed %x, read %x)r`�unpackrprrUr)rZfilecrcr
r
r�	_checkcrc�s
�
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���	r]�rz>l�)r��ordr�r`r�rVrW�FNamerrrrrYrZ)rrBZfname�rest�typeZcreator�flagsr
r
rr��s


zHexBin._readheadercGst|jtkr	td��|r|d}t||j�}n|j}d}t|�|kr2||�|t|��}t|�|ks!|j||_|S)NzRead data at wrong timerr0)rZrYr�minrVrBr�)r�nr~r
r
rr�s
�zHexBin.readcCs6|jtkr	td��|jr|�|j�}|��t|_dS)Nzclose_data at wrong time)rZrYrrVr�r�rj�rZdummyr
r
rrk�s

zHexBin.close_datacGsZ|jtkr	|��|jtkrtd��|r|d}t||j�}n|j}|j||_|�|�S)Nz Read resource data at wrong timer)rZrYrkrjrr�rWr�)rr�r
r
r�	read_rsrc�s


zHexBin.read_rsrccCsR|jdurdSz|jr|�|j�}|��Wd|_|j��dSd|_|j��wr+)rZrWr�r�rpr2r�r
r
rr2�s

�zHexBin.closeN)rrr	rr�r�r�rrkr�r2r
r
r
rr�us

r�cCs�t|�}|j}|s|j}t�|d��}	|�d�}|sn|�|�qWd�n1s,wY|��|�d�}|rYt	|d�}|�|�	|�d�}|sOn|�|�qG|�
�|�
�dS)z6hexbin(infilename, outfilename) - Decode binhexed filerRTrmN)r�rr�rrrr1rkr�r)r2)rnrorpr#r<rer
r
rr�s0

��




�r)rHrC�
contextlibrrr`r5�warnr8�__all__�	ExceptionrrYrjrMr>r�rr(r)�contextmanagerr9r;rJrQrrqrzr�rr
r
r
r�<module>s<�

(^+8h