add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
3

�
�^�6c@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�/usr/lib64/python3.6/binhex.pyr��i�i@s�c@seZdZdd�ZdS)�FInfocCsd|_d|_d|_dS)Nz????r)�Type�Creator�Flags��selfrrr�__init__0szFInfo.__init__N)rrrrrrrrr/r	rcCstt�}tj|d��2}|jd�}d|kr,d|_|jdd�|j�}WdQRXtjj	|�\}}|j
ddd�}|||dfS)	N�rbirZTEXT�z:z-r
)r�io�open�readrZseekZtell�osZpathZsplitZreplace)�name�finfoZfp�dataZdsizeZdirZfilerrr�getfileinfo5s
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�openrsrccG�dS�Nr�rZargsrrrrC�zopenrsrc.__init__cGsdS�N�rrrrrrFr z
openrsrc.readcGrrrrrrr�writeIr zopenrsrc.writecCrrrrrrr�closeLr zopenrsrc.closeN)rrrrrr#r$rrrrrBsrc@�0eZdZdZdd�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'rrrrR�z_Hqxcoderengine.__init__cCsh|j||_t|j�}|dd}|jd|�}|j|d�|_|sHdS|jtj|�|_|jd�dS)N�r)r�lenr(�binascii�b2a_hqx�_flush)rrZdatalenZtodorrrr#Xs
z_Hqxcoderengine.writecCsvd}xF|t|j�|jkrJ||j}|jj|j||�d�t|_|}qW|j|d�|_|rr|jj|jd�dS)Nrs
s:
)r.r(r*r'r#r))rZforceZfirstZlastrrrr1cs
z_Hqxcoderengine._flushcCs6|jr|jtj|j�|_|jd�|jj�|`dS)Nr
)rr(r/r0r1r'r$rrrrr$ns


z_Hqxcoderengine.closeN)rrr�__doc__rr#r1r$rrrrr&Os
r&c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�_Rlecoderenginez4Write data to the RLE-coder in suitably large chunkscC�||_d|_dSr!)r'rr+rrrrx�z_Rlecoderengine.__init__cCs@|j||_t|j�tkrdStj|j�}|jj|�d|_dSr!)rr.�REASONABLY_LARGEr/�rlecode_hqxr'r#)rr�rledatarrrr#|sz_Rlecoderengine.writecCs0|jrtj|j�}|jj|�|jj�|`dSr)rr/r8r'r#r$)rr9rrrr$�s

z_Rlecoderengine.closeN)rrrr2rr#r$rrrrr4usr4c@�LeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�BinHexc
	Cs�|\}}}}d}t|t�r.|}tj|d�}d}yR|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&r4r'�crcr�dlen�rlen�
_writeinfo�_DID_HEADER�stater$)
rZname_finfo_dlen_rlenr'rrr@rAZclose_on_errorZofnameZhqxerrrrr�s*



zBinHex.__init__cCs�t|�}|dkrtd��t|g�|jd�d}|j|j}}t|t�rR|jd�}t|t�rf|jd�}||}tj	d|j
�}tj	d|j|j�}	||||	}
|j
|
�|j�dS)Ni?zFilename too longzlatin-1��>hz>ii)r.rZbytesZencoderr
r=r>�struct�packrr@rA�_write�	_writecrc)rrrZnl�dZtpZcrZd2Zd3Zd4ZinforrrrB�s




zBinHex._writeinfocCs tj||j�|_|jj|�dSr)r/�crc_hqxr?r'r#�rrrrrrI�sz
BinHex._writecCs4|jdkrd}nd}|jjtj||j��d|_dS)NrrFz>H)r?r'r#rGrH)rZfmtrrrrJ�s

zBinHex._writecrccCs0|jtkrtd��|jt|�|_|j|�dS)NzWriting data at the wrong time)rDrCrr@r.rIrMrrrr#�s
zBinHex.writecCs,|jdkrtd|jf��|j�t|_dS)NrzIncorrect data size, diff=%r)r@rrArJ�	_DID_DATArDrrrr�
close_data�s
zBinHex.close_datacCsB|jtkr|j�|jtkr$td��|jt|�|_|j|�dS)Nz'Writing resource data at the wrong time)rDrNrOrrAr.rIrMrrr�
write_rsrc�s

zBinHex.write_rsrccCsx|jdkrdSzJ|jtkr"|j�|jtkr4td��|jdkrNtd|jf��|j�Wdd|_|j}|`|j�XdS)NzClose at the wrong timerz$Incorrect resource-datasize, diff=%r)rDrNrOrrArJr'r$r+rrrr$�s



zBinHex.closeN)rrrrrBrIrJr#rOrPr$rrrrr;�s
r;c
Cs�t|�}t||�}tj|d��.}x|jd�}|s2P|j|�q"W|j�WdQRXt|d�}x|jd�}|snP|j|�q^W|j	�|j	�dS)zEbinhex(infilename, outfilename): create binhex-encoded copy of a filer��N)
rr;rrrr#rOrrPr$)�inp�outrr'�ifprKrrrr�s"



c@r3)	�_Hqxdecoderenginez*Read data via the decoder in 4-byte chunkscCr5)Nr)rT�eof�rrTrrrrr6z_Hqxdecoderengine.__init__cCs�d}|}x�|dkr�|jr|S|ddd}|jj|�}xRytj|�\}|_PWntjk
rfYnX|jjd�}|s�td��||}q:W||}|t|�}|r
|jr
td��q
W|S)z&Read at least wtd bytes (or until EOF)r"rrr-�r
zPremature EOF on binhex file)rVrTrr/Za2b_hqxZ
Incompleterr.)rZtotalwtdZdecdata�wtdrZ
decdatacurZnewdatarrrrs,
z_Hqxdecoderengine.readcC�|jj�dSr�rTr$rrrrr$%r z_Hqxdecoderengine.closeN)rrrr2rrr$rrrrrU�s rUc@r%)�_RledecoderenginezRead data via the RLE-codercCs||_d|_d|_d|_dS)Nr"r)rT�
pre_buffer�post_bufferrVrWrrrr+r,z_Rledecoderengine.__init__cCsD|t|j�kr"|j|t|j��|jd|�}|j|d�|_|Sr)r.r^�_fill)rrY�rvrrrr1s
z_Rledecoderengine.readcCs�|j|jj|d�|_|jjr>|jtj|j�|_d|_dSt|j�}|jdd�tdtkrl|d}nX|jdd�tkr�|d}n<|jd	d�tdkr�|d}n|jd
d�tkr�n|d}|jtj|jd|��|_|j|d�|_dS)NrXr"r-rEr
ri��������������rbra)	r]rTrrVr^r/Z
rledecode_hqxr.�RUNCHAR)rrYZmarkrrrr_8s&



z_Rledecoderengine._fillcCrZrr[rrrrr$[r z_Rledecoderengine.closeN)rrrr2rrr_r$rrrrr\(s
#r\c@r:)�HexBincCsjt|t�rtj|d�}x.|jd�}|s.td��|dkr8q|dkrPqWt|�}t|�|_d|_	|j
�dS)Nrr
zNo binhex data founds
s:r)r=r>rrrrrUr\rTr?�_readheader)rrTZchZhqxifprrrr_s


zHexBin.__init__cCs |jj|�}tj||j�|_|Sr)rTrr/rLr?)rr.rrrr�_readuszHexBin._readcCsNtjd|jjd��dd@}|jd@|_||jkrDtd|j|f��d|_dS)NrFrri��zCRC error, computed %x, read %x)rG�unpackrTrr?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
rXr��	rF�rz>l��rirjrkrlrm)rfZordrhrGrgr@rA�FNamerr
rrrCrD)rr.ZfnameZrestZtypeZcreatorZflagsrrrre�s

zHexBin._readheadercGsn|jtkrtd��|r,|d}t||j�}n|j}d}x&t|�|kr\||j|t|��}q8W|j||_|S)NzRead data at wrong timerr")rDrCr�minr@r.rf)r�nr`rrrr�s
zHexBin.readcCs6|jtkrtd��|jr$|j|j�}|j�t|_dS)Nzclose_data at wrong time)rDrCrr@rfrhrN�rZdummyrrrrO�s
zHexBin.close_datacGsZ|jtkr|j�|jtkr$td��|r>|d}t||j�}n|j}|j||_|j|�S)Nz Read resource data at wrong timer)rDrCrOrNrrorArf)rrprrr�	read_rsrc�s

zHexBin.read_rsrccCsD|jdkrdSz|jr"|j|j�}|j�Wdd|_|jj�XdSr)rDrArrrhrTr$rqrrrr$�s
zHexBin.closeN)rrrrrfrhrerrOrrr$rrrrrd^s

rdc
Cs�t|�}|j}|s|j}tj|d��&}x|jd�}|s8P|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<rQN)rdrrnrrrr#rOrrrr$)rRrSrTrr'rKrrrr�s,




)r2rrrGr/Z__all__Z	ExceptionrrCrNr7r)rcrrrr&r4r;rrUr\rdrrrrrZ<module>s,


&^*6h