a �DOg 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_mode� binary_file�r&�/usr/lib64/python3.9/gzip.pyrs$ rcCs|�t�d|��dS)Nz|jdur||_n|jt|�8_dSt|j�|_d|_dSr/)r4r0r1r2)r5r7r&r&r'r7bs   z_PaddedFile.prependcCsd|_d|_|j�|�Sr9)r4r0r3�seek)r5Zoffr&r&r'r;ksz_PaddedFile.seekcCsdS�NTr&�r5r&r&r'�seekablepsz_PaddedFile.seekableN)r.)r.)�__name__� __module__� __qualname__r8rr7r;r>r&r&r&r'r-Js   r-c@s eZdZdS)rN)r?r@rAr&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�BufferedReaderr0rC�warnings�warn� FutureWarning�WRITE� _init_write�zlib� compressobj�DEFLATED� MAX_WBITS� DEF_MEM_LEVELr� _write_mtime�fileobj�_write_gzip_header) r5rr r!r\�mtimeZorigmode�rawrQr&r&r'r8�sN#       � � zGzipFile.__init__cCsBddl}|�dtd�|jtkr<|jdd�dkr<|jdS|jS)Nrzuse the name attributer������.gz)rQrR�DeprecationWarningr rTrC)r5rQr&r&r'r�s  zGzipFile.filenamecCs |jjjSr9)r0r_� _last_mtimer=r&r&r'r^�szGzipFile.mtimecCs.t|j�}d|dd�dtt|��dS)Nz)�reprr\�hex�id)r5�sr&r&r'�__repr__�s zGzipFile.__repr__cCs.||_t�d�|_d|_g|_d|_d|_dS�Nr.r)rCrV�crc32�crcr:Zwritebuf�bufsize�offset)r5rr&r&r'rU�s  zGzipFile._init_writecCs|j�d�|j�d�zuszGzipFile.seekablecCs�|jtkr�|tjkr2|tjkr*|j|}ntd��||jkrDtd��||j}d}t|d�D]}|� |�q^|� d|d�n |jt kr�|� �|j � ||�S|jS)NzSeek from end not supportedzNegative seek in write modes�ru)r rTr�SEEK_SET�SEEK_CURrprr��rangerrNr�r0r;)r5rp�whence�count�chunk�ir&r&r'r;xs         z GzipFile.seekcCs|��|j�|�Sr9)r�r0�readline)r5r:r&r&r'r��szGzipFile.readline)rd)rd)rd)r?r@rArJr�r8�propertyrr^rkrUr]rrr�r�r�r�rV� Z_SYNC_FLUSHr�r�r�r�r�r>rr�r;r�r&r&r&r'rxs4 � Q      rcsZeZdZ�fdd�Zdd�Zdd�Zdd�Zdd d �Zd d �Zdd�Z �fdd�Z �Z S)rOcs,t�jt|�tjtj d�d|_d|_dS)N)ZwbitsT)�superr8r-rV� decompressobjrY� _new_memberrc)r5�fp�� __class__r&r'r8�s �z_GzipReader.__init__cCst�d�|_d|_dSrl)rVrm�_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)�_fprr1�EOFError)r5r�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.FrqzNot a gzipped file (%r)z|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.)� descriptionz--fast� store_truezcompress faster)�action�helpz--bestzcompress betterz-dz --decompresszact like gunzip instead of gzip�args�*�-r3)�nargs�default�metavarrr)rr r\r`razfilename doesn't end in .gz: r�)rr r\r!r�)�argparser��add_mutually_exclusive_group� add_argument� parse_args�_COMPRESS_LEVEL_TRADEOFF�fastr�Zbestr�r�rr�sys�stdin�buffer�stdout�exitrrIrrr�) r��parser�groupr�r!�argr6�gr�r&r&r'�main/sR � �     �   r��__main__) r(r�r~rrVrIr� _compression�__all__ZFTEXTr�r�r|r�rNrTr�r�r�rr,r-r�r� BaseStreamr�DecompressReaderrOrrr�r?r&r&r&r'�s4 � ,* 0