%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3.8/__pycache__/gzip.cpython-38.pyc

U

k�]e�S�@sdZddlZddlZddlZddlZddlZddlZddlZddlZdddddgZ	d\Z
ZZZ
Zd	\ZZd
ZdZdZd
edddfdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�dej�ZGdd�dej�Zefdd�dd�Zdd�Zdd�Ze dk�re�dS)z�Functions that read and write gzipped files.

The user of the file doesn't have to worry about the compression,
but random access is not allowed.�N�BadGzipFile�GzipFile�open�compress�
decompress)�����)rrr��	�rbcCs�d|kr d|krPtd|f��n0|dk	r0td��|dk	r@td��|dk	rPtd��|�dd�}t|tttjf�r|t|||�}n,t|d	�s�t|d
�r�td|||�}nt	d��d|kr�t
�||||�S|SdS)aOpen a gzip-compressed file in binary or text mode.

    The filename argument can be an actual filename (a str or bytes object), or
    an existing file object to read from or write to.

    The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for
    binary mode, or "rt", "wt", "xt" or "at" for text mode. The default mode is
    "rb", and the default compresslevel is 9.

    For binary mode, this function is equivalent to the GzipFile constructor:
    GzipFile(filename, mode, compresslevel). In this case, the encoding, errors
    and newline arguments must not be provided.

    For text mode, a GzipFile object is created, and wrapped in an
    io.TextIOWrapper instance with the specified encoding, error handling
    behavior, and line ending(s).

    �t�bzInvalid mode: %rNz0Argument '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_modeZbinary_file�r%�/usr/lib/python3.8/gzip.pyrs$cCs|�t�d|��dS)Nz<L)r�structZpack)�output�valuer%r%r&�write32uEsr*c@s<eZdZdZddd�Zdd�Zddd�Zd	d
�Zdd�Zd
S)�_PaddedFilez�Minimal read-only file object that prepends a string to the contents
    of an actual file. Shouldn't be used outside of gzip.py, as it lacks
    essential functionality.�cCs ||_t|�|_||_d|_dS�Nr)�_buffer�len�_length�file�_read)�self�f�prependr%r%r&�__init__Os
z_PaddedFile.__init__cCs~|jdkr|j�|�S|j||jkrJ|j}|j|7_|j||j�S|j}d|_|j|d�|j�||j|�SdS�N)r2r1rr0r.)r3�sizerr%r%r&rUs
�z_PaddedFile.readcCs>|jdkr||_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__�__doc__r6rr5r9r<r%r%r%r&r+Js

	r+c@seZdZdZdS)rz6Exception raised in some cases for invalid gzip files.N)r=r>r?r@r%r%r%r&rtsc@s�eZdZdZdZddeddfdd�Zedd��Zedd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
d,dd�Zd-dd�Zdd�Zedd��Zdd�Zejfdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zejfd(d)�Zd.d*d+�ZdS)/ra
The GzipFile class simulates most of the methods of a file object with
    the exception of the truncate() method.

    This class only supports opening files in binary mode. If you need to open a
    compressed file in text mode, use the gzip.open() function.

    NcCs4|r"d|ksd|kr"td�|���|r6d|kr6|d7}|dkrTt�||pJd�}|_|dkr|t|dd�}t|ttf�s�d}n
t	�
|�}|dkr�t|d	d�}|�d
�r�t|_
t|�}t�|�|_||_nN|�d��rt|_
|�|�t�|tjtjtjd�|_||_ntd�|���||_|j
tk�r0|�|�dS)
aGConstructor for the GzipFile class.

        At least one of fileobj and filename must be given a
        non-trivial value.

        The new class instance is based on fileobj, which can be a regular
        file, an io.BytesIO object, or any other object which simulates a file.
        It defaults to None, in which case filename is opened to provide
        a file object.

        When fileobj is not None, the filename argument is only used to be
        included in the gzip file header, which may include the original
        filename of the uncompressed file.  It defaults to the filename of
        fileobj, if discernible; otherwise, it defaults to the empty string,
        and in this case the original filename is not included in the header.

        The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x', or
        'xb' depending on whether the file will be read or written.  The default
        is the mode of fileobj if discernible; otherwise, the default is 'rb'.
        A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
        'wb', 'a' and 'ab', and 'x' and 'xb'.

        The compresslevel argument is an integer from 0 to 9 controlling the
        level of compression; 1 is fastest and produces the least compression,
        and 9 is slowest and produces the most compression. 0 is no compression
        at all. The default is 9.

        The mtime argument is an optional numeric timestamp to be written
        to the last modification time field in the stream when compressing.
        If omitted or None, the current time is used.

        r�UzInvalid mode: {!r}rNr�namerr �r)�w�a�xr)r�format�builtinsr�	myfileobj�getattrrrrr�fspath�
startswith�READr �_GzipReaderr�BufferedReaderr.rB�WRITE�_init_write�zlibZcompressobjZDEFLATED�	MAX_WBITSZ
DEF_MEM_LEVELr�_write_mtime�fileobj�_write_gzip_header)r3rr r!rU�mtime�rawr%r%r&r6�s@#


�zGzipFile.__init__cCsBddl}|�dtd�|jtkr<|jdd�dkr<|jdS|jS)Nrzuse the name attributer����.gz)�warnings�warn�DeprecationWarningr rPrB)r3r[r%r%r&r�s

zGzipFile.filenamecCs
|jjjS)z0Last modification time read from stream, or None)r.rX�_last_mtimer;r%r%r&rW�szGzipFile.mtimecCs.t|j�}d|dd�dtt|��dS)Nz<gzip r���� �>)�reprrU�hex�id)r3�sr%r%r&�__repr__�s
zGzipFile.__repr__cCs.||_t�d�|_d|_g|_d|_d|_dS�Nr,r)rBrR�crc32�crcr8Zwritebuf�bufsize�offset)r3rr%r%r&rQ�szGzipFile._init_writecCs|j�d�|j�d�z<tj�|j�}t|t�s<|�d�}|�	d�rR|dd�}Wnt
k
rld}YnXd}|rzt}|j�t|��d��|j
}|dkr�t��}t|jt|��|tkr�d}n|tkr�d	}nd
}|j�|�|j�d�|�r|j�|d
�dS)N���zlatin-1s.gzrYr,r�����)rUrr�path�basenamerBrr�encode�endswith�UnicodeEncodeError�FNAME�chrrT�timer*�int�_COMPRESS_LEVEL_BEST�_COMPRESS_LEVEL_FAST)r3r!Zfname�flagsrWZxflr%r%r&rV�s6



zGzipFile._write_gzip_headercCs�|��|jtkr&ddl}t|jd��|jdkr8td��t|t	�rLt
|�}nt|�}|j}|dkr�|j�
|j�|��|j|7_t�||j�|_|j|7_|S)Nrz$write() on read-only GzipFile objectz!write() on closed GzipFile object)�_check_not_closedr rP�errno�OSError�EBADFrUrrrr/�
memoryview�nbytesrrr8rRrhrirk)r3�datarZlengthr%r%r&rs 



zGzipFile.writer_cCs2|��|jtkr&ddl}t|jd��|j�|�S)Nrz$read() on write-only GzipFile object)r~r rMrr�r�r.r�r3r8rr%r%r&rs

z
GzipFile.readcCs@|��|jtkr&ddl}t|jd��|dkr4tj}|j�	|�S)zdImplements BufferedIOBase.read1()

        Reads up to a buffer's worth of data if size is negative.rNz%read1() on write-only GzipFile object)
r~r rMrr�r�r�DEFAULT_BUFFER_SIZEr.�read1r�r%r%r&r�&s
zGzipFile.read1cCs2|��|jtkr&ddl}t|jd��|j�|�S)Nrz$peek() on write-only GzipFile object)r~r rMrr�r�r.�peek)r3�nrr%r%r&r�3s

z
GzipFile.peekcCs
|jdkSr7�rUr;r%r%r&�closed:szGzipFile.closedcCs�|j}|dkrdSd|_zP|jtkrR|�|j���t||j	�t||j
d@�n|jtkrf|j��W5|j}|r�d|_|��XdS)N���)
rUrI�closer rPrr�flushr*rir8rMr.)r3rUrIr%r%r&r�>s

zGzipFile.closecCs4|��|jtkr0|j�|j�|��|j��dSr7)r~r rPrUrrr�)r3Z	zlib_moder%r%r&r�Qs
zGzipFile.flushcCs
|j��S)z�Invoke the underlying file object's fileno() method.

        This will raise AttributeError if the underlying file object
        doesn't support fileno().
        )rU�filenor;r%r%r&r�XszGzipFile.filenocCs"|jtkrtd��|j�d�dS)z[Return the uncompressed stream file position indicator to the
        beginning of the filezCan't rewind in write moderN)r rMr�r.r9r;r%r%r&�rewind`s
zGzipFile.rewindcCs
|jtkSr7)r rMr;r%r%r&�readablegszGzipFile.readablecCs
|jtkSr7)r rPr;r%r%r&�writablejszGzipFile.writablecCsdSr:r%r;r%r%r&r<mszGzipFile.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�rp)r rPr�SEEK_SET�SEEK_CURrkrr��rangerrMr~r.r9)r3rk�whence�count�chunk�ir%r%r&r9ps 





z
GzipFile.seekcCs|��|j�|�Sr7)r~r.�readline)r3r8r%r%r&r��szGzipFile.readline)r_)r_)r_)r=r>r?r@rIr{r6�propertyrrWrfrQrVrrr�r�r�r�rRZZ_SYNC_FLUSHr�r�r�r�r�r<rr�r9r�r%r%r%r&rxs:
�
I

 



csZeZdZ�fdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	�fdd�Z
�ZS)rNcs,t�jt|�tjtjd�d|_d|_dS)N)ZwbitsT)�superr6r+rRZ
decompressobjrS�_new_memberr^)r3�fp��	__class__r%r&r6�s
�z_GzipReader.__init__cCst�d�|_d|_dSrg)rRrh�_crc�_stream_sizer;r%r%r&�
_init_read�sz_GzipReader._init_readcCsF|j�|�}t|�|krB|j�|t|��}|s8td��||7}q|S)z�Read exactly *n* bytes from `self._fp`

        This method is required because self._fp may be unbuffered,
        i.e. return short reads.
        �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�|dkr�q�q�|t	@r�|j�d
�}|r�|dkr�q�q�|t
@r�|�d�dS)
Nrr,FrlzNot a gzipped file (%r)z<BBIxxr
zUnknown compression methodz<HrrpT)r�rrr'�unpackr�r^�FEXTRArw�FCOMMENT�FHCRC)r3�magic�method�flagZ	extra_lenrer%r%r&�_read_gzip_header�s0�

z_GzipReader._read_gzip_headerr_cCs�|dkr|��S|sdS|jjr>|��d|_|jf|j�|_|jrf|��|��s`|j	|_
dSd|_|j�t
j�}|j�||�}|jjdkr�|j�|jj�n|jjdkr�|j�|jj�|dkr�q�|dkrtd��q|�|�|j	t|�7_	|S)Nrr,TFr�)�readallZ
_decompressorZeof�	_read_eofr�Z_decomp_factoryZ_decomp_argsr�r�Z_posZ_sizer�rrr�rZunconsumed_tailr5Zunused_datar��_add_read_datar/)r3r8�bufZ
uncompressr%r%r&r�s:�

z_GzipReader.readcCs$t�||j�|_|jt|�|_dSr7)rRrhr�r�r/)r3r�r%r%r&r��sz_GzipReader._add_read_datacCs�t�d|�d��\}}||jkr<tdt|�t|j�f��n||jd@krRtd��d}|dkrl|j�d�}qV|r||j�	|�dS)Nz<IIr
zCRC check failed %s != %sr�z!Incorrect length of data producedrpr)
r'r�r�r�rrcr�r�rr5)r3rhZisize�cr%r%r&r��s

�
z_GzipReader._read_eofcst���d|_dSr:)r��_rewindr�r;r�r%r&r�s
z_GzipReader._rewind)r_)r=r>r?r6r�r�r�rr�r�r��
__classcell__r%r%r�r&rN�s!
3rN)rWc	Cs6t��}t|d||d��}|�|�W5QRX|��S)z�Compress data in one shot and return the compressed string.
    Optional argument is the compression level, in range of 0-9.
    �wb)rUr r!rW)r�BytesIOrr�getvalue)r�r!rWr�r4r%r%r&rsc
Cs0tt�|�d��}|��W5QR�SQRXdS)zYDecompress a gzip compressed string in one shot.
    Return the decompressed string.
    r�N)rrr�r)r�r4r%r%r&rsc	Cs�ddlm}|dd�}|��}|jdddd�|jd	dd
d�|jdddd
d�|jdddgdd�|��}t}|jr|t}n
|jr�t	}|j
D]�}|jr�|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
jjk	�rt|��|t
jjk	r�|��q�dS)Nr)�ArgumentParserzeA simple command line interface for the gzip module: act like gzip, but do not delete the input file.)Zdescriptionz--fast�
store_truezcompress faster)�action�helpz--bestzcompress betterz-dz--decompresszact like gunzip instead of gzip�args�*�-r1)�nargs�default�metavarrr)rr rUrYrZzfilename doesn't end in .gz: r�)rr rUr!r�)�argparser�Zadd_mutually_exclusive_group�add_argument�
parse_args�_COMPRESS_LEVEL_TRADEOFFZfastr|Zbestr{r�rr�sys�stdin�buffer�stdout�exitrrHrrr�)	r��parser�groupr�r!�argr4�gr�r%r%r&�main'sR�
�



�
r��__main__)!r@r'r�ryrrRrHrZ_compression�__all__ZFTEXTr�r�rwr�rMrPr|r�r{rr*r+r�rZ
BaseStreamrZDecompressReaderrNrrr�r=r%r%r%r&�<module>s: �
,*	0


Zerion Mini Shell 1.0