ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/binhex.cpython-39.pyc

a

���e�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/python39/lib64/python3.9/binhex.pyr%sr�i��@��c@seZdZdd�ZdS)�FInfocCsd|_d|_d|_dS)Nz????r)�Type�Creator�Flags��selfr
r
r�__init__6szFInfo.__init__N)rrr	rr
r
r
rr5srcCs�t�}t�|d��<}|�d�}d|vr,d|_|�dd�|��}Wd�n1sT0Ytj�	|�\}}|�
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)
�openrsrccGsdS�Nr
�r�argsr
r
rrIszopenrsrc.__init__cGsdS�N�r
r+r
r
rrLsz
openrsrc.readcGsdSr*r
r+r
r
r�writeOszopenrsrc.writecCsdSr*r
rr
r
r�closeRszopenrsrc.closeN)rrr	rrr/r0r
r
r
rr)Hsr)ccs@t���$t�ddt�dVWd�n1s20YdS)N�ignore�)�warnings�catch_warnings�filterwarnings�DeprecationWarningr
r
r
r�_ignore_deprecation_warningXs
r7c@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�rr9r
r
rrbsz_Hqxcoderengine.__init__cCs�|j||_t|j�}|dd}|jd|�}|j|d�|_|sHdSt��"|jt�|�|_Wd�n1sv0Y|�d�dS)N�r)r%�lenr7r:�binascii�b2a_hqx�_flush)rr%ZdatalenZtodor
r
rr/hs
0z_Hqxcoderengine.writecCsrd}|t|j�|jkrH||j}|j�|j||�d�t|_|}q|j|d�|_|rn|j�|jd�dS)Nr�
s:
)r?r:r<r9r/r;)rZforce�firstZlastr
r
rrBts
z_Hqxcoderengine._flushcCs\|jr@t��$|jt�|j�|_Wd�n1s60Y|�d�|j��|`dS)Nr)r%r7r:r@rArBr9r0rr
r
rr0s2

z_Hqxcoderengine.closeN)rrr	�__doc__rr/rBr0r
r
r
rr8_s
r8c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_Rlecoderenginez4Write data to the RLE-coder in suitably large chunkscCs||_d|_dSr-)r9r%r=r
r
rr�sz_Rlecoderengine.__init__cCsf|j||_t|j�tkrdSt��t�|j�}Wd�n1sF0Y|j�|�d|_dSr-)r%r?�REASONABLY_LARGEr7r@�rlecode_hqxr9r/)rr%�rledatar
r
rr/�s*z_Rlecoderengine.writecCsV|jrDt��t�|j�}Wd�n1s.0Y|j�|�|j��|`dSr*)r%r7r@rHr9r/r0)rrIr
r
rr0�s*
z_Rlecoderengine.closeN)rrr	rErr/r0r
r
r
rrF�s	rFc@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|_|dur`t	�}||_
||_|�||�t
|_Wn|r�|���Yn0dS)NF�wbTs0(This file must be converted with BinHex 4.0)

:r)�
isinstance�strrrr/r8rFr9�crcr�dlen�rlen�
_writeinfo�_DID_HEADER�stater0)
rZname_finfo_dlen_rlenr9r"r#rOrPZclose_on_errorZofnameZhqxerr
r
rr�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)r?r�bytes�encoderrrLrM�struct�packrrOrP�_write�	_writecrc)rr"r#�nl�d�tpZcrZd2Zd3Zd4�infor
r
rrQ�s




zBinHex._writeinfocCs t�||j�|_|j�|�dSr*)r@�crc_hqxrNr9r/�rr%r
r
rr[�sz
BinHex._writecCs4|jdkrd}nd}|j�t�||j��d|_dS)NrrVz>H)rNr9r/rYrZ)rZfmtr
r
rr\�s

zBinHex._writecrccCs0|jtkrtd��|jt|�|_|�|�dS)NzWriting data at the wrong time)rSrRrrOr?r[rbr
r
rr/�s
zBinHex.writecCs,|jdkrtd|jf��|��t|_dS)NrzIncorrect data size, diff=%r)rOrrPr\�	_DID_DATArSrr
r
r�
close_data�s
zBinHex.close_datacCsB|jtkr|��|jtkr$td��|jt|�|_|�|�dS)Nz'Writing resource data at the wrong time)rSrcrdrrPr?r[rbr
r
r�
write_rsrc�s

zBinHex.write_rsrccCs�|jdurdSzb|jtkr"|��|jtkr4td��|jdkrNtd|jf��|��Wd|_|j}|`|��nd|_|j}|`|��0dS)NzClose at the wrong timerz$Incorrect resource-datasize, diff=%r)rSrcrdrrPr\r9r0r=r
r
rr0�s$





�zBinHex.closeN)rrr	rrQr[r\r/rdrer0r
r
r
rrJ�s
rJcCs�t|�}t||�}t�|d��4}|�d�}|s0q<|�|�q |��Wd�n1sX0Yt|d�}|�d�}|s|q�|�|�ql|�	�|�	�dS)zEbinhex(infilename, outfilename): create binhex-encoded copy of a filer��N)
r(rJrrrr/rdr)rer0)�inp�outr#r9�ifpr^r
r
rr�s

&

rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_Hqxdecoderenginez*Read data via the decoder in 4-byte chunkscCs||_d|_dS)Nr)ri�eof�rrir
r
rrsz_Hqxdecoderengine.__init__cCs�d}|}|dkr�|jr|S|ddd}|j�|�}z>t�� t�|�\}|_Wd�n1sd0YWq�Wntjy�Yn0|j�d�}|s�td��||}q6||}|t|�}|s|jstd��q|S)	z&Read at least wtd bytes (or until EOF)r.rrr>�NrzPremature EOF on binhex file)	rkrirr7r@Za2b_hqxZ
Incompleterr?)rZtotalwtdZdecdata�wtdr%Z
decdatacur�newdatar
r
rrs*
.


z_Hqxdecoderengine.readcCs|j��dSr*�rir0rr
r
rr0:sz_Hqxdecoderengine.closeN)rrr	rErrr0r
r
r
rrjs!rjc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_RledecoderenginezRead data via the RLE-codercCs||_d|_d|_d|_dS)Nr.r)ri�
pre_buffer�post_bufferrkrlr
r
rr@sz_Rledecoderengine.__init__cCsD|t|j�kr"|�|t|j��|jd|�}|j|d�|_|Sr*)r?rs�_fill)rrn�rvr
r
rrFs
z_Rledecoderengine.readcCsB|j|j�|d�|_|jjrdt��$|jt�|j�|_Wd�n1sP0Yd|_dSt|j�}|jdd�t	dt	kr�|d}nX|jdd�t	kr�|d}n<|jdd�t	dkr�|d}n|jdd�t	kr�n|d	}t��,|jt�|jd|��|_Wd�n1�s$0Y|j|d�|_dS)
Nrmr.���rUr>���r���r)
rrrirrkr7rsr@Z
rledecode_hqxr?�RUNCHAR)rrnZmarkr
r
rrtMs.
�$



�&z_Rledecoderengine._fillcCs|j��dSr*rprr
r
rr0rsz_Rledecoderengine.closeN)rrr	rErrrtr0r
r
r
rrq=s
%rqc@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 foundrC�:r)rLrMrrrrrjrqrirN�_readheader)rriZchZhqxifpr
r
rrvs


zHexBin.__init__cCs |j�|�}t�||j�|_|Sr*)rirr@rarN)rr?r%r
r
r�_read�szHexBin._readcCsNt�d|j�d��dd@}|jd@|_||jkrDtd|j|f��d|_dS)NrVrri��zCRC error, computed %x, read %x)rY�unpackrirrNr)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���	rV�rz>l�)r}�ordrrYr~rOrP�FNamerrrrrRrS)rr?Zfname�rest�typeZcreator�flagsr
r
rr|�s

zHexBin._readheadercGsj|jtkrtd��|r,|d}t||j�}n|j}d}t|�|krZ||�|t|��}q6|j||_|S)NzRead data at wrong timerr.)rSrRr�minrOr?r})r�nrur
r
rr�s
zHexBin.readcCs6|jtkrtd��|jr$|�|j�}|��t|_dS)Nzclose_data at wrong time)rSrRrrOr}rrc�rZdummyr
r
rrd�s
zHexBin.close_datacGsZ|jtkr|��|jtkr$td��|r>|d}t||j�}n|j}|j||_|�|�S)Nz Read resource data at wrong timer)rSrRrdrcrr�rPr})rr�r
r
r�	read_rsrc�s

zHexBin.read_rsrccCsT|jdurdSz.|jr"|�|j�}|��Wd|_|j��nd|_|j��0dSr*)rSrPr�rrir0r�r
r
rr0�s

�zHexBin.closeN)rrr	rr}rr|rrdr�r0r
r
r
rrzus

rzcCs�t|�}|j}|s|j}t�|d��,}|�d�}|s6qB|�|�q&Wd�n1sV0Y|��|�d�}|r�t	|d�}|�|�|�d�}|s�q�|�|�q�|�
�|�
�dS)z6hexbin(infilename, outfilename) - Decode binhexed filerKrfN)rzrr�rrrr/rdr�r)r0)rgrhrir#r9r^r
r
rr�s$
*



r)rEr@�
contextlibrrrYr3�warnr6�__all__�	ExceptionrrRrcrGr;ryrr(r)�contextmanagerr7r8rFrJrrjrqrzrr
r
r
r�<module>s:�

(^+8h

Zerion Mini Shell 1.0