3 \��@s6ddlZejZGdd�dej�ZGdd�dej�ZdS)�Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) � BaseStreamcCs|jrtd��dS)NzI/O operation on closed file)�closed� ValueError)�self�r�$/usr/lib64/python3.6/_compression.py�_check_not_closed szBaseStream._check_not_closedcCs|j�stjd��dS)NzFile not open for reading)�readable�io�UnsupportedOperation)rrrr�_check_can_readszBaseStream._check_can_readcCs|j�stjd��dS)NzFile not open for writing)�writabler r )rrrr�_check_can_writeszBaseStream._check_can_writecCs(|j�stjd��|j�s$tjd��dS)Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)r r r �seekable)rrrr�_check_can_seeks zBaseStream._check_can_seekN)�__name__� __module__� __qualname__rr rrrrrrr srcsheZdZdd�Zffdd�Z�fdd�Zdd�Zd d �Zdd d �Zdd�Z e j fdd�Z dd�Z �ZS)�DecompressReadercCsdS)NTr)rrrrr $szDecompressReader.readablecKs>||_d|_d|_d|_||_||_|jf|j�|_||_dS)NFr������)�_fp�_eof�_pos�_size�_decomp_factory� _decomp_args� _decompressor�_trailing_error)r�fpZdecomp_factoryZtrailing_errorZ decomp_argsrrr�__init__'szDecompressReader.__init__csd|_t�j�S)N)r�super�close)r)� __class__rrr";szDecompressReader.closecCs |jj�S)N)rr)rrrrr?szDecompressReader.seekablecCsPt|��:}|jd��$}|jt|��}||dt|��<WdQRXWdQRXt|�S)N�B)� memoryview�cast�read�len)r�bZviewZ byte_view�datarrr�readintoBs$zDecompressReader.readintorc Cs�|dkr|j�S| s|jr dSd}x�|jjr�|jjp@|jjt�}|sHP|jf|j �|_y|jj ||�}Wq�|j k r�PYq�Xn4|jj r�|jjt�}|s�t d��nd}|jj ||�}|r&Pq&W|s�d|_|j|_dS|jt|�7_|S)Nr�zACompressed file ended before the end-of-stream marker was reachedT)�readallrr�eofZ unused_datarr'� BUFFER_SIZErrZ decompressrZ needs_input�EOFErrorrrr()r�sizer*Zrawblockrrrr'Hs>      zDecompressReader.readcCs,|jjd�d|_d|_|jf|j�|_dS)NrF)r�seekrrrrr)rrrr�_rewindrs zDecompressReader._rewindcCs�|tjkr nV|tjkr"|j|}n@|tjkrT|jdkrHx|jtj�rFq8W|j|}ntdj |���||jkrv|j �n ||j8}x0|dkr�|jt tj|��}|s�P|t |�8}q�W|jS)NrzInvalid value for whence: {}) r �SEEK_SET�SEEK_CURr�SEEK_ENDrr'�DEFAULT_BUFFER_SIZEr�formatr3�minr()r�offset�whencer*rrrr2xs&          zDecompressReader.seekcCs|jS)N)r)rrrr�tell�szDecompressReader.tellr)r)rrrr r r"rr+r'r3r r4r2r<� __classcell__rr)r#rr!s   *r)r r7r/�BufferedIOBaser� RawIOBaserrrrr�s