U e5dÜã@s:dZddlZejZGdd„dejƒZGdd„dejƒZdS)z7Internal classes used by the gzip, lzma and bz2 moduleséNc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú BaseStreamzMode-checking helper functions.cCs|jrtdƒ‚dS)NzI/O operation on closed file)ÚclosedÚ ValueError©Úself©rú$/usr/lib64/python3.8/_compression.pyÚ_check_not_closed szBaseStream._check_not_closedcCs| ¡st d¡‚dS)NzFile not open for reading)ÚreadableÚioÚUnsupportedOperationrrrrÚ_check_can_readszBaseStream._check_can_readcCs| ¡st d¡‚dS)NzFile not open for writing)Úwritabler r rrrrÚ_check_can_writeszBaseStream._check_can_writecCs(| ¡st d¡‚| ¡s$t d¡‚dS)Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)r r r ÚseekablerrrrÚ_check_can_seeks zBaseStream._check_can_seekN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r r rrrrrrr s rcsjeZdZdZdd„Zddd„Z‡fdd„Zd d „Zd d „Zddd„Z dd„Z e j fdd„Z dd„Z‡ZS)ÚDecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIcCsdS)NTrrrrrr $szDecompressReader.readablercKs>||_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ƒ ¡S©N)rÚsuperÚcloser©Ú __class__rrr$;szDecompressReader.closecCs |j ¡Sr")rrrrrrr?szDecompressReader.seekablec CsPt|ƒ�:}| d¡�$}| t|ƒ¡}||dt|ƒ…<W5QRXW5QRXt|ƒS)NÚB)Ú memoryviewÚcastÚreadÚlen)rÚbZviewZ byte_viewÚdatarrrÚreadintoBs$zDecompressReader.readintorcCsì|dkr| ¡S|r|jrdSd}|jjr„|jjp<|j t¡}|sDqÀ|jf|j Ž|_z|j  ||¡}Wq¸|j k r€YqÀYq¸Xn4|jj r¦|j t¡}|sªt dƒ‚nd}|j  ||¡}|r"qÀq"|sÖd|_|j|_dS|jt|ƒ7_|S)NrózACompressed file ended before the end-of-stream marker was reachedT)ÚreadallrrÚeofZ unused_datarr*Ú BUFFER_SIZErrÚ decompressrZ needs_inputÚEOFErrorrrr+)rÚsizer-Zrawblockrrrr*Hs@  ÿÿ   zDecompressReader.readcCs,|j d¡d|_d|_|jf|jŽ|_dS)NrF)rÚseekrrrrrrrrrÚ_rewindrs zDecompressReader._rewindcCs°|tjkr nR|tjkr"|j|}n<|tjkrP|jdkrD| tj¡rDq6|j|}ntd  |¡ƒ‚||jkrr|  ¡n ||j8}|dkrª| t tj|ƒ¡}|sœqª|t |ƒ8}q||jS)NrzInvalid value for whence: {}) r ÚSEEK_SETÚSEEK_CURrÚSEEK_ENDrr*ÚDEFAULT_BUFFER_SIZErÚformatr7Úminr+)rÚoffsetÚwhencer-rrrr6xs&          zDecompressReader.seekcCs|jS)z!Return the current file position.)rrrrrÚtell–szDecompressReader.tell)r)r)rrrrr r!r$rr.r*r7r r8r6r@Ú __classcell__rrr%rr!s   *r)rr r;r2ÚBufferedIOBaserÚ RawIOBaserrrrrÚs