grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 þ“qc$Oã@sXdZddlZddlZddlZddlZddlZddlZddlZddlZddddgZ ddd d d f\Z Z Z Z Zddf\ZZd d ddddd„Zdd„ZGdd„dƒZGdd„dejƒZGdd„dejƒZd dd„Zdd„Zdd„ZedkrTeƒ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ÚGzipFileÚopenÚcompressÚ decompresséééééÚrbé cCsd|kr.d|krvtd|fƒ‚nH|dk rFtdƒ‚|dk r^tdƒ‚|dk rvtdƒ‚|jddƒ}t|ttfƒr²t|||ƒ}nBt|d ƒsÐt|d ƒrètd|||ƒ}n td ƒ‚d|krtj ||||ƒ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ÚbytesrÚhasattrÚ TypeErrorÚioÚ TextIOWrapper)ÚfilenameÚmodeÚ compresslevelÚencodingÚerrorsÚnewlineZgz_modeZ binary_file©r!ú)/opt/alt/python35/lib64/python3.5/gzip.pyrs$          cCs|jtjd|ƒƒdS)Nz)rÚformatÚbuiltinsrÚ myfileobjÚgetattrrrrÚ startswithÚREADrÚ _GzipReaderrÚBufferedReaderr)r:ÚWRITEÚ _init_writeÚzlibZ compressobjZDEFLATEDÚ MAX_WBITSZ DEF_MEM_LEVELrÚ _write_mtimeÚfileobjÚ_write_gzip_header)r.rrrrLÚmtimeÚrawr!r!r"r1{s<#             zGzipFile.__init__cCsYddl}|jdtdƒ|jtkrR|jdd…dkrR|jdS|jS)Nrzuse the name attributeréz.gzéýÿÿÿ)ÚwarningsÚwarnÚDeprecationWarningrrGr:)r.rRr!r!r"rÂs  ( zGzipFile.filenamecCs |jjjS)z0Last modification time read from stream, or None)r)rOÚ _last_mtime)r.r!r!r"rNÊszGzipFile.mtimecCs9t|jƒ}d|dd…dtt|ƒƒdS)Nzéÿÿÿÿ)ÚreprrLÚhexÚid)r.Úsr!r!r"Ú__repr__ÏszGzipFile.__repr__cCsC||_tjdƒ|_d|_g|_d|_d|_dS)Nr(r)r:rIÚcrc32Úcrcr2ZwritebufÚbufsizeÚoffset)r.rr!r!r"rHÓs     zGzipFile._init_writec Cs7|jjdƒ|jjdƒyVtjj|jƒ}t|tƒsV|jdƒ}|j dƒru|dd …}Wnt k r�d}YnXd}|r£t }|jjt |ƒjdƒƒ|j }|dkrãtjƒ}t|jt|ƒƒ|jjdƒ|jjd ƒ|r3|jj|d ƒdS) Ns‹szlatin-1s.gzrPr(rssÿsrQ)rLrÚosÚpathÚbasenamer:rrÚencodeÚendswithÚUnicodeEncodeErrorÚFNAMEÚchrrKÚtimer&Úint)r.ZfnameÚflagsrNr!r!r"rMÛs,     zGzipFile._write_gzip_headercCsç|jƒ|jtkr7ddl}t|jdƒ‚|jdkrRtdƒ‚t|t ƒrpt |ƒ}nt |ƒ}|j }|dkrã|jj |jj|ƒƒ|j|7_tj||jƒ|_|j|7_|S)Nrz$write() on read-only GzipFile objectz!write() on closed GzipFile object)Ú_check_not_closedrrGÚerrnoÚOSErrorÚEBADFrLrrrr*Ú memoryviewÚnbytesrrr2rIr^r_ra)r.ÚdatarnZlengthr!r!r"rõs       zGzipFile.writercCsG|jƒ|jtkr7ddl}t|jdƒ‚|jj|ƒS)Nrz$read() on write-only GzipFile object)rmrrDrnrorpr)r)r.r2rnr!r!r"r s   z GzipFile.readcCs\|jƒ|jtkr7ddl}t|jdƒ‚|dkrLtj}|jj |ƒS)zdImplements BufferedIOBase.read1() Reads up to a buffer's worth of data is size is negative.rNz%read1() on write-only GzipFile object) rmrrDrnrorprÚDEFAULT_BUFFER_SIZEr)Úread1)r.r2rnr!r!r"rus    zGzipFile.read1cCsG|jƒ|jtkr7ddl}t|jdƒ‚|jj|ƒS)Nrz$peek() on write-only GzipFile object)rmrrDrnrorpr)Úpeek)r.Únrnr!r!r"rv!s   z GzipFile.peekcCs |jdkS)N)rL)r.r!r!r"Úclosed(szGzipFile.closedc Cs¸|j}|dkrdSd|_zl|jtkrq|j|jjƒƒt||jƒt||jd@ƒn|jt kr�|j j ƒWd|j }|r³d|_ |j ƒXdS)Nlÿÿ) rLrrGrrÚflushr&r_r2rDr)ÚcloserA)r.rLrAr!r!r"rz,s     zGzipFile.closecCsF|jƒ|jtkrB|jj|jj|ƒƒ|jjƒdS)N)rmrrGrLrrry)r.Z zlib_moder!r!r"ry?s zGzipFile.flushcCs |jjƒS)z¥Invoke the underlying file object's fileno() method. This will raise AttributeError if the underlying file object doesn't support fileno(). )rLÚfileno)r.r!r!r"r{FszGzipFile.filenocCs/|jtkrtdƒ‚|jjdƒdS)z[Return the uncompressed stream file position indicator to the beginning of the filezCan't rewind in write moderN)rrDror)r3)r.r!r!r"ÚrewindNs zGzipFile.rewindcCs |jtkS)N)rrD)r.r!r!r"ÚreadableUszGzipFile.readablecCs |jtkS)N)rrG)r.r!r!r"ÚwritableXszGzipFile.writablecCsdS)NTr!)r.r!r!r"r4[szGzipFile.seekablecCsò|jtkr¿|tjkrI|tjkr=|j|}n tdƒ‚||jkrdtdƒ‚||j}tdƒ}x%t |dƒD]}|j |ƒqŽW|j t|dƒƒn,|jt krë|j ƒ|j j||ƒS|jS)NzSeek from end not supportedzNegative seek in write modei)rrGrÚSEEK_SETÚSEEK_CURrarrorÚrangerrDrmr)r3)r.raÚwhenceÚcountÚchunkÚir!r!r"r3^s      z GzipFile.seekcCs|jƒ|jj|ƒS)N)rmr)Úreadline)r.r2r!r!r"r†rs zGzipFile.readlinerXrXrX)r5r6r7r8rAr1ÚpropertyrrNr]rHrMrrrurvrxrzrIZ Z_SYNC_FLUSHryr{r|r}r~r4rrr3r†r!r!r!r"rns. F           cseZdZ‡fdd†Zdd„Zdd„Zdd„Zdd d „Zd d „Zdd„Z ‡fdd†Z ‡S)rEcs<tƒjt|ƒtjdtj ƒd|_d|_dS)NZwbitsT)Úsuperr1r'rIZ decompressobjrJÚ _new_memberrU)r.Úfp)Ú __class__r!r"r1xs  z_GzipReader.__init__cCstjdƒ|_d|_dS)Nr(r)rIr^Ú_crcÚ _stream_size)r.r!r!r"Ú _init_readsz_GzipReader._init_readcCsg|jj|ƒ}xNt|ƒ|krb|jj|t|ƒƒ}|sUtdƒ‚||7}qW|S)z•Read exactly *n* bytes from `self._fp` This method is required because self._fp may be unbuffered, i.e. return short reads. zACompressed file ended before the end-of-stream marker was reached)Ú_fprr*ÚEOFError)r.rwrsrr!r!r"Ú _read_exactƒs z_GzipReader._read_exactcCs;|jjdƒ}|dkr"dS|dkr>td|ƒ‚tjd|jdƒƒ\}}|_|dkr}tdƒ‚|t@r²tjd |jdƒƒ\}|j|ƒ|t@réx*|jjd ƒ}| sä|d kr¿Pq¿W|t @r x*|jjd ƒ}| s|d kröPqöW|t @r7|jdƒd S) Nrr(Fs‹zNot a gzipped file (%r)zs(0    $+ )ÿ �  &