Vc ^csrdZddlZddlZddlZddlZddlZddlZddlZddlZgdZ d\Z Z Z Z Zd\ZZdZdZdZd edddfd Zd ZGd d ZGddeZGddejZdZdZGddejZ ddede fdZ!efdddZ"dZ#dZ$e%dkr e$dSdS)zFunctions 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) BadGzipFileGzipFileopencompress decompress)i)rrrii rbcs"d|vrd|vrtd|n3|td|td|td|dd}t|ttt jfrt|||}nBt|d st|d rtd|||}ntd d|vr+tj |}tj ||||S|S) 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). tbzInvalid mode: Nz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary modereadwritez1filename must be a str or bytes object, or a file) ValueErrorZreplace isinstancestrbytesosZPathLikerZhasattrZ TypeErrorioZ text_encodingZ TextIOWrapper)filenamemode compresslevelZencodingZerrorsZnewlineZgz_modeZ binary_files /usr/lib64/python3.11/gzip.pyrrsE( d{ P $; ;*449:: : ;  QOPP P  OMNN N  PNOO Oll3##G(S%566Mx-@@ 6 " "Mgh&@&@MtWmXFF KLLL d{#H-- XvwGGGcsV|tjd|dS)Nz>$'' ' :  , ::D JJ$ JJ<TZ0 0:DDJ<&9>>$t|"3D"899: :rcs|j||_n|xjt|zc_dSt|j|_d|_dSr )r%r!r"r#)r&r(rrr(z_PaddedFile.prependcsL : "DLL JJ#g,, &JJ F4<((  rcsRd|_d|_|j|Sr+)r%r!r$seek)r&Zoffrrr-z_PaddedFile.seekls$  y~~c"""rcdSNTr& rseekablez_PaddedFile.seekableqtrN)r) __name__ __module__ __qualname____doc__r*rr(r-r3r0rrrrKss   : : :### rrcseZdZdZdS)rz6Exception raised in some cases for invalid gzip files.N)r5r6r7r8r0rrrrus@@@@rrcseZdZdZdZddeddfdZedZedZ dZ dZ dZ d Z dd Zdd Zd ZedZdZejfdZdZdZdZdZdZejfdZddZdS)ra The GzipFile class simulates most of the methods of a file object with the exception of the truncate() method. This class only supports opening files in binary mode. If you need to open a compressed file in text mode, use the gzip.open() function. Ncs|r*d|vsd|vr"td||r d|vr|dz }|tj||pdx}|_|0t |dd}t |ttfsd}ntj |}|}|t |d d}| d r rr*zGzipFile.__init__sF  @SD[ @C4K @188>>?? ?  CtO  CKD  M'/}Xt|t'L'L LGdn  +w33Hhe 55 y**H  27FD11D ??3   @DIg&&C,S11DL DII ___ - - @ & L"1 &&& DI   X & & & ,]-1].2n_-1-?-. 00DM !&D  188>>?? ? 9  3  # #M 2 2 2 2 2 3 3rcsddl}|dtd|jtkr|jdddkr |jdzS|jS)Nrzuse the name attributer.gz)r>r?ZDeprecationWarningrr@r9)r&r>rrrzGzipFile.filenames] .0BAFFF 9  %$)BCC.E"9 %9u$ $yrcs$|jjjS)z0Last modification time read from stream, or None)r!rH _last_mtimer1r2rrGzGzipFile.mtimes|++rcst|j}d|ddzdztt|zdzS)Nz)ZreprrEhexZid)r&srr__repr__zGzipFile.__repr__s?   !AbD'!C'#bhh--7#==rcs~||_tjd|_d|_g|_d|_d|_dSNrr)r9rBcrc32crcr,ZwritebufZbufsizeoffset)r&rrrrAzGzipFile._init_writes8 :c??    rcs\|jd|jd tj|j}t |ts|d}| dr |dd}n#t$rd}YnwxYwd}|rt}|jt|d|j }|tj}t|jt!||t"krd}n|t$krd }nd }|j||jd |r|j|d zdSdS) Nszlatin-1s.gzrJrrsss)rErrZpathZbasenamer9rrZencodeZendswithZUnicodeEncodeErrorFNAMEZchrrDtimerint_COMPRESS_LEVEL_BEST_COMPRESS_LEVEL_FAST)r&rZfnameZflagsrGxfl rrFzGzipFile._write_gzip_headers ;''' 7### G$$TY//EeU++ 0 Y//~~f%% #crc !   EEE   E 3u::,,Y77888!  IKKEs5zz*** 0 0 CC 2 2 CCC 3 7###  0 L  uw / / / / / 0 0sA-B$$ B32B3cs||jtkrddl}t |jd|jtdt|ttfrt|}nt|}|j }|dkrq|j|j||xj|z c_t#j||j|_|xj|z c_|S)Nrz$write() on read-only GzipFile objectz!write() on closed GzipFile object)_check_not_closedrr@errnoOSErrorEBADFrErrrZ bytearrayr"Z memoryviewZnbytesrrr,rBrRrSrT)r&datar_length rrzGzipFile.writes    9  O LLL%+'MNN N < B@AA A dUI. / / !YYFFd##D[F A: " L  t}55d;; < < < II IIz$11DH KK6 !KK rrMc||jtkrddl}t |jd|j|S)Nrz$read() on write-only GzipFile object)r^rr<r_r`rar!rr&r,r_r)rrz GzipFile.read(sV    9  O LLL%+'MNN N|  &&&rcs||jtkrddl}t |jd|dkr t j}|j |S)zdImplements BufferedIOBase.read1() Reads up to a buffer's worth of data if size is negative.rNz%read1() on write-only GzipFile object) r^rr<r_r`rarDEFAULT_BUFFER_SIZEr!read1rfr)rrhzGzipFile.read1/sl    9  P LLL%+'NOO O !8 *)D|!!$'''rcre)Nrz$peek() on write-only GzipFile object)r^rr<r_r`rar!peek)r&nr_r)rriz GzipFile.peek<sV    9  O LLL%+'MNN N|  ###rcs|jduSr+)rEr1r2rclosedzGzipFile.closedCs|t##rcs|j}|dSd|_ |jtkrZ||jt ||jt ||jdzn)|jtkr|j |j }|rd|_ | dSdS#|j }|rd|_ | wwxYw)N) rErr@rrflushrrSr,r<r!closer;)r&rEr;r)rrnzGzipFile.closeGs ,   F  "yE! % dm1133444$(+++$)j"89999d" % ""$$$I "!%!!!!! " "I "!%!!!! "s BC'C6cs||jtkrM|j|j||jdSdSr+)r^rr@rErrrm)r&Z zlib_moderrrmzGzipFile.flushZsm    9  ! L  t}229== > > > L    ! !rcs4|jS)zInvoke the underlying file object's fileno() method. This will raise AttributeError if the underlying file object doesn't support fileno(). )rEfilenor1r2rrozGzipFile.filenoas |""$$$rcsx|jtkrtd|jddS)z[Return the uncompressed stream file position indicator to the beginning of the filezCan't rewind in write moderN)rr<r`r!r-r1r2rrewindzGzipFile.rewindis> 9  8677 7 !rc"|jtkSr+)rr<r1r2rreadablezGzipFile.readablepsyD  rcrqr+)rr@r1r2rwritablezGzipFile.writablessyE!!rcr.r/r0r1r2rr3zGzipFile.seekablevr4rcs|jtkr|tjkr*|tjkr |j|z}nt d||jkrtd||jz }d}t|dzD]}| || d|dzzn?|jtkr/| |j ||S|jS)NzSeek from end not supportedzNegative seek in write modesirV)rr@rSEEK_SETZSEEK_CURrTrr`Zrangerr<r^r!r-)r&rTZwhenceZcountchunkZir]rr-z GzipFile.seekys  9  5$ DR[(D![61FF$%BCCC # =;<<<T[(E E5D=)) " " 5!!!! JJu - . . . . Y$  5  " " $ $ $<$$VV44 4{rcs^||j|Sr+)r^r!readline)r&r,rrrvzGzipFile.readlines*    |$$T***rrM)r5r6r7r8r;rZr*ZpropertyrrGrPrArFrrrhrirkrnrBZ Z_SYNC_FLUSHrmrorprrrsr3rrtr-rvr0rrrrysI $43TO3O3O3O3bX,,X,>>>000@0'''' ( ( ( ($$$$$X$"""&".!!!!%%%!!!"""#%+(++++++rrcs||}t||krN||t|z }|std||z }t||kN|S)z}Read exactly *n* bytes from `fp` This method is required because fp may be unbuffered, i.e. return short reads. ACompressed file ended before the end-of-stream marker was reached)rr"EOFError)fprjrbr rdr _read_exactr{s 771::D d))a- GGAD M " " ?>?? ?   d))a- KrcsB|d}|dkrdS|dkrtd|ztjdt |d\}}}|dkrtd|t zr5tjd t |d\}t |||t zr |d }|r|d krn|tzr |d }|r|d krn|tzrt |d|S) zRead a gzip header from `fp` and progress to the end of the header. Returns last mtime if header was present or None otherwise. rrNrUzNot a gzipped file (%r)z> ! 3 # C!% )    #' %9T%9&)&)'&)&)" )!!!--//!%DJ3#( (-- 677C+66sDAAJ!1S8 A  !3!CDDDD#/36 A  !3!?@@@S  cz C BCCCE# CJ Z))) S__$ rcs|tj||j|_|jt |z|_dSr+)rBrRrrr")r&rbrrrz_GzipReader._add_read_data s3JtTY//  -D 9rcstjdt|jd\}}||jkr4t dt |dt |j||jdzkrt dd}|dkr |jd}|dk |r|j |dSdS) N"1"+=>> V $*\** * 2011 1 c,''*4 5 CABB B##L111~abb!((11#2rcsddlm}|d}|}|ddd|d dd |d d dd |dddgd|}t }|jrt}n|jrt}|j D]}|j r|dkr3tddtjj}tjj}n|dddkrtjd|t%|d}t'j|ddd}nb|dkr4tjj}tddtjj|}n(t'j|d}t%|dzd} |t*j}|sn||8|tjjur||tjjur|dS)Nr)ArgumentParserzeA simple command line interface for the gzip module: act like gzip, but do not delete the input file.)Z descriptionz--fastZ store_truezcompress faster)ZactionZhelpz--bestzcompress betterz-dz --decompresszact like gunzip instead of gzipargsZ*z-r$)ZnargsZdefaultZmetavarr r )rrrErJrKzfilename doesn't end in .gz: Zwb)rrrEr)ZargparserZadd_mutually_exclusive_groupZ add_argumentZ parse_args_COMPRESS_LEVEL_TRADEOFFZfastr[ZbestrZrrrsysZstdinZbufferZstdoutZexitrr:rrrgrrn) rZparserZgrouprrZargr'ZgrurIrmainrks'''''' ^ ,---F  / / 1 1E x ;LMMM x ;LMMM t^L>@@@ cC5&III     D,M y-, -, y ? ,cz 2btSY=MNNNJ%rss8u$FHDSDDEEEdOOM#crc(D11cz ,I$btSZ=N+8:::M#t,,ud++ FF2122E  GGENNN   CJ% %  GGIII CI$ $  GGIII5rZ__main__r+)&r8rrrXrrBr:rZ _compressionZ__all__ZFTEXTrr}rWr~r<r@r[rrZrrrr`rZ BaseStreamrr{rZDecompressReaderr=rYrrrrrr5r0rrrsW%%   G G G(6%ufeX e,@tT++++Z+++ ''''''''TAAAAA'AAAV+V+V+V+V+|&V+V+V+r    """Ja a a a a ,/a a a J(,KKcK05KKKK*"6$2222...` z DFFFFF  r