grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î ¤ fú^ã@s6dZddlZddlZddlZddlZddlZddlZddlZddddgZddd d d f\Z Z Z Z Z ddf\ZZd d ddddd„Zdd„ZGdd„dƒZGdd„dejƒZd dd„Zdd„Zdd„Zedkr2eƒndS)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é cCs*d|kr1d|kr‚td|fƒ‚q‚nQ|dk rLtdƒ‚n|dk rgtdƒ‚n|dk r‚tdƒ‚n|jddƒ}t|ttfƒr¾t|||ƒ}nBt|d ƒsÜt|d ƒrôtd|||ƒ}n td ƒ‚d|kr"tj ||||ƒ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/python34/lib64/python3.4/gzip.pyrs$       cCs|jtjd|ƒƒdS)Nzéÿÿÿÿ)rSrr'r,ÚreprÚhexÚid)r.rSÚsr!r!r"Ú__repr__æs    zGzipFile.__repr__cCs|jrtdƒ‚ndS)zLRaises a ValueError if the underlying file object has been closed. zI/O operation on closed file.N)Úclosedr)r.r!r!r"Ú _check_closedís zGzipFile._check_closedcCs>||_tjdƒd@|_d|_g|_d|_dS)Nr(lÿÿr)r8rQÚcrc32Úcrcr2ZwritebufÚbufsize)r.rr!r!r"rPôs    zGzipFile._init_writec CsF|jjdƒ|jjdƒy\tjj|jƒ}t|tƒsY|jdƒ}n|j dƒr{|dd …}nWnt k r–d}YnXd}|r¬t }n|jjt |ƒjdƒƒ|j }|dkrïtjƒ}nt|jt|ƒƒ|jjdƒ|jjd ƒ|rB|jj|d ƒndS) Ns‹szlatin-1s.gzrVr(rssÿsrW)rSrÚosÚpathÚbasenamer8rrÚencodeÚendswithÚUnicodeEncodeErrorÚFNAMEÚchrrTÚtimer&Úint)r.ZfnameÚflagsrTr!r!r"rUûs,     zGzipFile._write_gzip_headercCs#tjdƒd@|_d|_dS)Nr(lÿÿr)rQrerfr2)r.r!r!r"Ú _init_readszGzipFile._init_readcCsj|jj|ƒ}xQt|ƒ|kre|jj|t|ƒƒ}|sXtdƒ‚n||7}qW|S)NzACompressed file ended before the end-of-stream marker was reached)rSrr*ÚEOFError)r.ÚnÚdatarr!r!r"Ú _read_exactszGzipFile._read_exactcCs†|jjdƒ}|dkr"dS|dkr=tdƒ‚ntjd|jdƒƒ\}}|_|dkrtdƒ‚n|t@r·tjd |jdƒƒ\}|j|ƒn|t@rôx0|jjd ƒ}| sé|d krÄPqÄqÄWn|t @r1x0|jjd ƒ}| s&|d krPqqWn|t @rK|jdƒn|jj ƒ}|r‚|j j |ƒ}|j |ƒnd S) Nrr(Fs‹zNot a gzipped filez U      %   ,       c CsGtjƒ}td|ddd|ƒ�}|j|ƒWdQX|jƒS)z�Compress data in one shot and return the compressed string. Optional argument is the compression level, in range of 0-9. rSrÚwbrN)rÚBytesIOrrÚgetvalue)rvrrŽr/r!r!r"rls cCs/tdtj|ƒƒ�}|jƒSWdQXdS)zYDecompress a gzip compressed string in one shot. Return the decompressed string. rSN)rrr¤r)rvr/r!r!r"ruscCsÔtjdd…}|o&|ddk}|rB|dd…}n|sTdg}nxy|D]q}|r|dkr£tddddd tjjƒ}tjj}qa|dd…d krÒtd t|ƒƒq[nt|dƒ}t j|dd…d ƒ}na|dkr<tjj}tdddd d tjjƒ}n%t j|dƒ}t|d d ƒ}x*|j dƒ}|s}Pn|j |ƒqdW|tjjk r­|j ƒn|tjjk r[|j ƒq[q[WdS)Nrrz-dú-rrrr rSrVz.gzzfilename doesn't end in .gz:r£irWrW) r�ÚargvrÚstdinÚbufferÚstdoutÚprintr^rrFrrr“)ÚargsrÚargr/Úgr‰r!r!r"Ú_test}s<   !  $ r¯Ú__main__)r=r#r�rprhrQrFrÚ__all__ZFTEXTr|rzrnr{rIrOrr&r'ÚBufferedIOBaserrrr¯r:r!r!r!r"Ús$0   $+ 8ÿñ  &