a DOg U@sddlZddlZddlZddlZddlZddlZddlZddlZgdZd\Z Z Z Z Z d\ZZdZdZdZdedddfd d Zd d ZGd ddZGdddeZGdddejZGdddejZefddddZddZddZedkredS)N) BadGzipFileGzipFileopencompress decompress))rrr rbcCsd|vr d|vrPtd|fn0|dur0td|dur@td|durPtd|dd}t|tttjfr|t|||}n,t|dst|d rtd|||}nt d d|vrt ||||S|SdS) NtbzInvalid mode: %rz0Argument '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) ValueErrorreplace isinstancestrbytesosPathLikerhasattr TypeErrorio TextIOWrapper)filenamemode compresslevelencodingerrorsnewlineZgz_modeZ binary_filer%)/opt/alt/python39/lib64/python3.9/gzip.pyrs$ rcCs|td|dS)Nz|jdur||_n|jt|8_dSt|j|_d|_dSr-)r2r.r/r0)r3r5r%r%r&r5bs   z_PaddedFile.prependcCsd|_d|_|j|Sr7)r2r.r1seek)r3Zoffr%r%r&r9ksz_PaddedFile.seekcCsdSNTr%r3r%r%r&seekablepsz_PaddedFile.seekableN)r,)r,)__name__ __module__ __qualname__r6rr5r9r<r%r%r%r&r+Js   r+c@s eZdZdS)rN)r=r>r?r%r%r%r&rtsrc@seZdZdZddeddfddZeddZeddZdd Z d d Z d d Z ddZ d+ddZ d,ddZddZeddZddZejfddZddZdd Zd!d"Zd#d$Zd%d&Zejfd'd(Zd-d)d*ZdS).rNc CsV|r"d|vsd|vr"td||r6d|vr6|d7}|durTt||pJd}|_|dur|t|dd}t|ttfsd}n t |}|}|durt|dd}| d rt |_ t|}t||_||_nl| d r(|durd dl}|d td t|_ ||t|tjtj tjd |_||_ntd|||_|j tkrR| |dS)NrUzInvalid mode: {!r}rrnamerr r)waxrzGzipFile was opened for writing, but this will change in future Python releases. Specify the mode argument for opening it for writing.r)!rformatbuiltinsr myfileobjgetattrrrrrfspath startswithREADr _GzipReaderrBufferedReaderr.rAwarningswarn FutureWarningWRITE _init_writezlibZ compressobjZDEFLATED MAX_WBITSZ DEF_MEM_LEVELr _write_mtimefileobj_write_gzip_header) r3rr r!rWmtimeZorigmoderawrOr%r%r&r6sN#         zGzipFile.__init__cCsBddl}|dtd|jtkr<|jdddkr<|jdS|jS)Nrzuse the name attributer.gz)rOrPDeprecationWarningr rRrA)r3rOr%r%r&rs  zGzipFile.filenamecCs |jjjSr7)r.rZ _last_mtimer;r%r%r&rYszGzipFile.mtimecCs.t|j}d|dddtt|dS)Nz)reprrWhexid)r3sr%r%r&__repr__s zGzipFile.__repr__cCs.||_td|_d|_g|_d|_d|_dSNr,r)rArTcrc32crcr8Zwritebufbufsizeoffset)r3rr%r%r&rSs  zGzipFile._init_writecCs|jd|jdzr?rHr{r6propertyrrYrfrSrXrrrrrrrTZ Z_SYNC_FLUSHrrrrrr<rrr9rr%r%r%r&rxs4  Q      rcsZeZdZfddZddZddZddZdd d Zd d ZddZ fddZ Z S)rMcs,tjt|tjtj dd|_d|_dS)N)ZwbitsT)superr6r+rTZ decompressobjrU _new_memberr^)r3fp __class__r%r&r6s z_GzipReader.__init__cCstd|_d|_dSrg)rTrh_crc _stream_sizer;r%r%r& _init_reads z_GzipReader._init_readcCsF|j|}t||krB|j|t|}|s8td||7}q |S)NACompressed file ended before the end-of-stream marker was reached)_fprr/EOFError)r3rrrr%r%r& _read_exacts   z_GzipReader._read_exactcCs|jd}|dkrdS|dkr,td|td|d\}}|_|dkrVtd|t@r|td |d\}|||t@r|jd }|r|d krqq|t @r|jd }|r|d krqq|t @r|dd S) Nrr,FrlzNot a gzipped file (%r)zr?r6rrrrrrr __classcell__r%r%rr&rMs ! 3rM)rYcCsJt}t|d||d}||Wdn1s80Y|S)Nwb)rWr r!rY)rBytesIOrrgetvalue)rr!rYrr4r%r%r&rs(rcCs<tt|d}|WdS1s.0YdS)Nr)rrrr)rr4r%r%r&r'src Csddlm}|dd}|}|jdddd|jd dd d|jd d dd d|jdddgdd|}t}|jr|t}n |jrt }|j D]}|j r|dkrt ddt jjd}t jj}n>|dddkrt d|t|d}t|ddd}nB|dkr"t jj}t ddt jj|d}nt|d}t|dd}|d}|sPq^||q<|t jjurt||t jjur|qdS)Nr)ArgumentParserzeA simple command line interface for the gzip module: act like gzip, but do not delete the input file.)Z descriptionz--fast store_truezcompress faster)actionhelpz--bestzcompress betterz-dz --decompresszact like gunzip instead of gzipargs*-r1)nargsdefaultmetavarrr)rr rWr[r\zfilename doesn't end in .gz: r)rr rWr!r)argparserZadd_mutually_exclusive_group add_argument parse_args_COMPRESS_LEVEL_TRADEOFFZfastr|Zbestr{rrrsysstdinbufferstdoutexitrrGrrr) rparsergrouprr!argr4grr%r%r&main/sR          r__main__) r'rryrrTrGrZ _compression__all__ZFTEXTrrrwrrLrRr|rr{rr*r+rrZ BaseStreamrZDecompressReaderrMrrrr=r%r%r%r&s4  ,* 0