a XC?h U�@s�ddlZddlZddlZddlZddlZddlZddlZddlZgd�Zd\Z Z Z Z Z d\ZZdZdZdZdedddfd d �Zd d �ZGd d�d�ZGdd�de�ZGdd�dej�ZGdd�dej�Zefdd�dd�Zdd�Zdd�Zedkr�e�dS)�N)� BadGzipFile�GzipFile�open�compress� decompress)�����)rrr�� �rbcCs�d|vr d|vrPtd|f��n0|dur0td��|dur@td��|durPtd��|�dd�}t|tttjf�r|t|||�}n,t|d�s�t|d �r�td|||�}nt d ��d|vr�t � ||||�S|SdS) N�t�bzInvalid mode: %rz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary mode��read�writez1filename must be a str or bytes object, or a file) � ValueError�replace� isinstance�str�bytes�os�PathLiker�hasattr� TypeError�io� TextIOWrapper)�filename�mode� compresslevel�encoding�errors�newlineZgz_modeZ binary_file�r%�)/opt/alt/python39/lib64/python3.9/gzip.pyrs$ rcCs|�t�d|��dS)Nz|jdur||_n|jt|�8_dSt|j�|_d|_dSr-)r2r.r/r0)r3r5r%r%r&r5bs   z_PaddedFile.prependcCsd|_d|_|j�|�Sr7)r2r.r1�seek)r3Zoffr%r%r&r9ksz_PaddedFile.seekcCsdS�NTr%�r3r%r%r&�seekablepsz_PaddedFile.seekableN)r,)r,)�__name__� __module__� __qualname__r6rr5r9r<r%r%r%r&r+Js   r+c@s eZdZdS)rN)r=r>r?r%r%r%r&rtsrc@s�eZdZdZddeddfdd�Zedd��Zedd��Zdd �Z d d �Z d d �Z dd�Z d+dd�Z d,dd�Zdd�Zedd��Zdd�Zejfdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejfd'd(�Zd-d)d*�ZdS).rNc CsV|r"d|vsd|vr"td�|���|r6d|vr6|d7}|durTt�||pJd�}|_|dur|t|dd�}t|ttf�s�d}n t � |�}|}|dur�t|dd�}|� d �r�t |_ t|�}t�|�|_||_nl|� d ��r(|dur�d dl}|�d td �t|_ |�|�t�|tjtj tjd �|_||_ntd�|���||_|j tk�rR|� |�dS)Nr�UzInvalid mode: {!r}rr�namerr �r)�w�a�xrz�GzipFile was opened for writing, but this will change in future Python releases. Specify the mode argument for opening it for writing.r)!r�format�builtinsr� myfileobj�getattrrrrr�fspath� startswith�READr � _GzipReaderr�BufferedReaderr.rA�warnings�warn� FutureWarning�WRITE� _init_write�zlibZ compressobjZDEFLATED� MAX_WBITSZ DEF_MEM_LEVELr� _write_mtime�fileobj�_write_gzip_header) r3rr r!rW�mtimeZorigmode�rawrOr%r%r&r6�sN#       � � zGzipFile.__init__cCsBddl}|�dtd�|jtkr<|jdd�dkr<|jdS|jS)Nrzuse the name attributer������.gz)rOrP�DeprecationWarningr rRrA)r3rOr%r%r&r�s  zGzipFile.filenamecCs |jjjSr7)r.rZ� _last_mtimer;r%r%r&rY�szGzipFile.mtimecCs.t|j�}d|dd�dtt|��dS)Nz)�reprrW�hex�id)r3�sr%r%r&�__repr__�s zGzipFile.__repr__cCs.||_t�d�|_d|_g|_d|_d|_dS�Nr,r)rArT�crc32�crcr8Zwritebuf�bufsize�offset)r3rr%r%r&rS�s  zGzipFile._init_writecCs|j�d�|j�d�zr?rHr{r6�propertyrrYrfrSrXrrr�r�r�r�rTZ Z_SYNC_FLUSHr�r�r�r�r�r<rr�r9r�r%r%r%r&rxs4 � Q      rcsZeZdZ�fdd�Zdd�Zdd�Zdd�Zdd d �Zd d �Zdd�Z �fdd�Z �Z S)rMcs,t�jt|�tjtj d�d|_d|_dS)N)ZwbitsT)�superr6r+rTZ decompressobjrU� _new_memberr^)r3�fp�� __class__r%r&r6�s �z_GzipReader.__init__cCst�d�|_d|_dSrg)rTrh�_crc� _stream_sizer;r%r%r&� _init_read�s z_GzipReader._init_readcCsF|j�|�}t|�|krB|j�|t|��}|s8td��||7}q |S)N�ACompressed file ended before the end-of-stream marker was reached)�_fprr/�EOFError)r3r�r�rr%r%r&� _read_exact�s   z_GzipReader._read_exactcCs�|j�d�}|dkrdS|dkr,td|��t�d|�d��\}}|_|dkrVtd��|t@r|t�d |�d��\}|�|�|t@r�|j�d �}|r�|d kr�q�q�|t @r�|j�d �}|r�|d kr�q�q�|t @r�|�d�d S) Nrr,FrlzNot a gzipped file (%r)zr?r6r�r�r�rr�r�r�� __classcell__r%r%r�r&rM�s ! 3rM)rYcCsJt��}t|d||d��}|�|�Wd�n1s80Y|��S)N�wb)rWr r!rY)r�BytesIOrr�getvalue)r�r!rYr�r4r%r%r&rs(rcCs<tt�|�d��}|��Wd�S1s.0YdS)Nr�)rrr�r)r�r4r%r%r&r'src Cs�ddlm}|dd�}|��}|jdddd�|jd dd d�|jd d dd d�|jdddgdd�|��}t}|jr|t}n |jr�t }|j D]�}|j r�|dkr�t ddt jjd�}t jj}n>|dd�dkr�t �d|���t|d�}t�|dd�d�}nB|dk�r"t jj}t ddt jj|d�}nt�|d�}t|dd�}|�d�}|�sP�q^|�|��q<|t jju�rt|��|t jjur�|��q�dS)Nr)�ArgumentParserzeA simple command line interface for the gzip module: act like gzip, but do not delete the input file.)Z descriptionz--fast� store_truezcompress faster)�action�helpz--bestzcompress betterz-dz --decompresszact like gunzip instead of gzip�args�*�-r1)�nargs�default�metavarrr)rr rWr[r\zfilename doesn't end in .gz: r�)rr rWr!r�)�argparser�Zadd_mutually_exclusive_group� add_argument� parse_args�_COMPRESS_LEVEL_TRADEOFFZfastr|Zbestr{r�rr�sys�stdin�buffer�stdout�exitrrGrrr�) r��parser�groupr�r!�argr4�gr�r%r%r&�main/sR � �     �   r��__main__) r'r�ryrrTrGrZ _compression�__all__ZFTEXTr�r�rwr�rLrRr|r�r{rr*r+r�rZ BaseStreamrZDecompressReaderrMrrr�r=r%r%r%r&�s4 � ,* 0