Fa@sQdZddlZejZGdddejZGdddejZdS)z7Internal classes used by the gzip, lzma and bz2 modulesNc@sFeZdZdZddZddZddZdd Zd S) BaseStreamzMode-checking helper functions.cCs|jrtddS)NzI/O operation on closed file)closed ValueError)selfr"/usr/lib/python3.5/_compression.py_check_not_closed s zBaseStream._check_not_closedcCs|jstjddS)NzFile not open for reading)readableioUnsupportedOperation)rrrr_check_can_reads zBaseStream._check_can_readcCs|jstjddS)NzFile not open for writing)writabler r )rrrr_check_can_writes zBaseStream._check_can_writecCs:|jstjd|js6tjddS)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____doc__rr rrrrrrr s    rcseZdZdZddZfddZfddZdd Zd d Zdd dZ ddZ e j ddZ ddZS)DecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIcCsdS)NTr)rrrrr $szDecompressReader.readablecKsX||_d|_d|_d|_||_||_|j|j|_||_dS)NFr)_fp_eof_pos_size_decomp_factory _decomp_args _decompressor_trailing_error)rfpZdecomp_factoryZtrailing_errorZ decomp_argsrrr__init__'s      zDecompressReader.__init__csd|_tjS)N)rsuperclose)r) __class__rrr#;s zDecompressReader.closecCs |jjS)N)rr)rrrrr?szDecompressReader.seekablecCsdt|K}|jd2}|jt|}||dt|        zDecompressReader.readcCs;|jjdd|_d|_|j|j|_dS)NrF)rseekrrrrr)rrrr_rewindrs  zDecompressReader._rewindcCs|tjkrn{|tjkr1|j|}n\|tjkrx|jdkrhx|jtjrgqRW|j|}ntdj |||jkr|j n ||j8}xB|dkr|jt tj|}|sP|t |8}qW|jS)NrzInvalid value for whence: {}) r SEEK_SETSEEK_CURrSEEK_ENDrr(DEFAULT_BUFFER_SIZErformatr3minr))roffsetwhencer+rrrr2xs&  zDecompressReader.seekcCs|jS)z!Return the current file position.)r)rrrrtellszDecompressReader.tellr)rrrrr r!r#rr,r(r3r r4r2r<rr)r$rr!s    * r)rr r7r/BufferedIOBaser RawIOBaserrrrrs