3 2anO@sddlZddlZddlZddlZddlZddlZddlZddlZddddgZd\Z Z Z Z Z d\ZZdd dZddZGdddZGdddejZGdddejZdddZddZddZedkredS)NGzipFileopencompress decompressrb cCsd|kr d|krPtd|fn0|dk r0td|dk r@td|dk rPtd|jdd}t|tttjfr|t|||}n,t|dst|d rtd|||}nt d d|krt j ||||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/python36/lib64/python3.6/gzip.pyrs$ cCs|jtjd|dS)Nz|jdkr||_n|jt|8_dSt|j|_d|_dS)Nr)r0r,r-r.)r1r3r#r#r$r3]s   z_PaddedFile.prependcCsd|_d|_|jj|S)N)r0r,r/seek)r1Zoffr#r#r$r6fsz_PaddedFile.seekcCsdS)NTr#)r1r#r#r$seekableksz_PaddedFile.seekableN)r+)r+)__name__ __module__ __qualname__r4rr3r6r7r#r#r#r$r*Es   r*c@seZdZdZd,ddZeddZeddZd d Zd d Z d dZ ddZ d.ddZ d0ddZ ddZeddZddZejfddZddZd d!Zd"d#Zd$d%Zd&d'Zejfd(d)Zd2d*d+ZdS)3rNr cCs2|r"d|ksd|kr"tdj||r6d|kr6|d7}|dkrTtj||pJd}|_|dkr|t|dd}t|ttfsd}n t j |}|dkrt|dd}|j d rt |_ t|}tj||_||_nN|j drt|_ |j|tj|tjtj tjd |_||_ntdj|||_|j tkr.|jdS)Nr UzInvalid mode: {!r}rr namerrrwaxr)r>r?r@)rformatbuiltinsr myfileobjgetattrrrrrfspath startswithREADr _GzipReaderrBufferedReaderr,r<WRITE _init_writezlibZ compressobjZDEFLATED MAX_WBITSZ DEF_MEM_LEVELr _write_mtimefileobj_write_gzip_header)r1rrrrOmtimerawr#r#r$r4{s>#         zGzipFile.__init__cCsBddl}|jdtd|jtkr<|jdddkr<|jdS|jS)Nrzuse the name attributerz.gz)warningswarnDeprecationWarningrrJr<)r1rUr#r#r$rs  zGzipFile.filenamecCs |jjjS)N)r,rR _last_mtime)r1r#r#r$rQszGzipFile.mtimecCs.t|j}d|dddtt|dS)Nz)reprrOhexid)r1sr#r#r$__repr__s zGzipFile.__repr__cCs.||_tjd|_d|_g|_d|_d|_dS)Nr+r)r<rLcrc32crcr5Zwritebufbufsizeoffset)r1rr#r#r$rKs  zGzipFile._init_writec Cs|jjd|jjdytjdd}|o|ddk}|r.|dd}|s8dg}x|D]}|r|dkrltddtjjd}tjj}q|d dd krtd t|q@t|d}t j|ddd }n>|dkrtjj}tdd tjjd}nt j|d}t|d d }x |j d }|sP|j |qW|tjjk r"|j |tjjk r@|j q@WdS)Nrrz-d-rr )rrrOrSz.gzzfilename doesn't end in .gz:rirTrT) sysargvrstdinbufferstdoutprintr\rrBrrr)argsrargr2grr#r#r$_tests<       r__main__)rrrr r )rr)r r NNN)r )r%rrprrLrBrZ _compression__all__ZFTEXTrrrnrrGrJrr)r*Z BaseStreamrZDecompressReaderrHrrrr8r#r#r#r$s*   +)  &