o ?Og1@sBdZddlZddlZejZGdddejZGdddejZdS)z7Internal classes used by the gzip, lzma and bz2 modulesNc@s0eZdZdZddZddZddZdd Zd S) BaseStreamzMode-checking helper functions.cCs|jrtddS)NzI/O operation on closed file)closed ValueErrorselfr3/opt/alt/python310/lib64/python3.10/_compression.py_check_not_closed szBaseStream._check_not_closedcC|s tddS)NzFile not open for reading)readableioUnsupportedOperationrrrr_check_can_read zBaseStream._check_can_readcCr )NzFile not open for writing)writabler r rrrr_check_can_writerzBaseStream._check_can_writecCs(|s td|stddS)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 rrrrrrrr s  rcsreZdZdZddZdddZfddZd d Zd d ZdddZ ddZ ddZ e j fddZddZZS)DecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIcCsdS)NTrrrrrr $szDecompressReader.readablercKsB||_d|_d|_d|_||_||_|jdi|j|_||_dS)NFrr)_fp_eof_pos_size_decomp_factory _decomp_args _decompressor_trailing_error)rfpZdecomp_factoryZtrailing_errorZ decomp_argsrrr__init__'s zDecompressReader.__init__csd|_tSN)r supercloser __class__rrr&;s zDecompressReader.closecCs |jSr$)rrrrrrr?s zDecompressReader.seekablec Cst|9}|d}|t|}||dt|<Wdn1s$wYWdt|SWdt|S1s@wYt|S)NB) memoryviewcastreadlen)rbZviewZ byte_viewdatarrrreadintoBs( zDecompressReader.readintorcCs|dkr|S|r |jrdSd} |jjrA|jjp|jt}|s#n<|jdi|j |_z |j ||}Wn$|j y@Ynw|jj rR|jt}|sQt dnd}|j ||}|r^nq|sjd|_|j|_dS|jt|7_|S)NrTzACompressed file ended before the end-of-stream marker was reachedr)readallrr eofZ unused_datarr, BUFFER_SIZErr decompressr!Z needs_inputEOFErrorrrr-)rsizer/Zrawblockrrrr,HsH   zDecompressReader.readcCs8g}|tj}r|||tj}s d|S)Nr1)r,sysmaxsizeappendjoin)rZchunksr/rrrr2qs   zDecompressReader.readallcCs0|jdd|_d|_|jdi|j|_dS)NrFr)rseekrrrrr rrrr_rewind|s zDecompressReader._rewindcCs|tjkrn/|tjkr|j|}n$|tjkr.|jdkr(|tjr( |tjs!|j|}ntd |||jkr?| n||j8}|dkra|t tj|}|sW |jS|t |8}|dksH|jS)NrzInvalid value for whence: {}) r SEEK_SETSEEK_CURrSEEK_ENDrr,DEFAULT_BUFFER_SIZErformatr=minr-)roffsetwhencer/rrrr<s,           zDecompressReader.seekcCs|jS)z!Return the current file position.)rrrrrtellszDecompressReader.tell)r)r)rrrrr r#r&rr0r,r2r=r r>r<rF __classcell__rrr'rr!s   ) r) rr r8rAr4BufferedIOBaser RawIOBaserrrrrs