ó zfc@sůdZddlZddlZddlZddlZddlZddlZddlZddgZddddd f\Z Z Z Z Z ddf\ZZd „Zd „Zd d d„Zdejfd„ƒYZd„ZedkrőeƒndS(s‘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.i˙˙˙˙NtGzipFiletopeniiiiicCs|jtjd|ƒƒdS(NsRiitridtwtasMode s not supportedN(treplacetNonet __builtin__Rt myfileobjtgetattrt isinstancet basestringthasattrRtREADtTruet _new_membertextrabuft extrasizet extrastartRt min_readsizetWRITEt _init_writetzlibt compressobjtDEFLATEDt MAX_WBITSt DEF_MEM_LEVELtcompresstIOErrortfileobjtoffsettmtimet_write_gzip_header(tselfR RRR/R1((s/usr/lib64/python2.7/gzip.pyt__init__-sH*  "            &      cCsSddl}|jdtdƒ|jtkrL|jddkrL|jdS|jS(Ni˙˙˙˙suse the name attributeiiý˙˙˙s.gz(twarningstwarntDeprecationWarningRR&R(R3R5((s/usr/lib64/python2.7/gzip.pyR ‰s  " cCs6t|jƒ}d|dd!dtt|ƒƒdS(Ns(treprR/thextid(R3ts((s/usr/lib64/python2.7/gzip.pyt__repr__‘scCs|jrtdƒ‚ndS(sLRaises a ValueError if the underlying file object has been closed. sI/O operation on closed file.N(tclosedt ValueError(R3((s/usr/lib64/python2.7/gzip.pyt _check_closed•s cCs>||_tjdƒd@|_d|_g|_d|_dS(NRl˙˙i(RR(tcrc32tcrctsizetwritebuftbufsize(R3R ((s/usr/lib64/python2.7/gzip.pyR'œs    cCs6|jjdƒ|jjdƒyVtjj|jƒ}t|tƒsY|jdƒ}n|j dƒru|d }nWnt k rd}nXd}|rĽt }n|jjt |ƒƒ|j }|dkrßtjƒ}nt|jt|ƒƒ|jjdƒ|jjd ƒ|r2|jj|d ƒndS( Ns‹sslatin-1s.gziý˙˙˙Riss˙s(R/RtostpathtbasenameRRtstrtencodetendswithtUnicodeEncodeErrortFNAMEtchrR1RttimeRtlong(R3tfnametflagsR1((s/usr/lib64/python2.7/gzip.pyR2Łs,     cCs#tjdƒd@|_d|_dS(NRl˙˙i(R(RBRCRD(R3((s/usr/lib64/python2.7/gzip.pyt _init_read˝scCs|jjdƒ}|dkr*td‚nt|jjdƒƒ}|dkrZtd‚nt|jjdƒƒ}t|jƒ|_|jjdƒ|t@rét|jjdƒƒ}|dt|jjdƒƒ}|jj|ƒn|t@r,x6tr(|jjdƒ}| s!|dkröPqöqöWn|t @rox6trk|jjdƒ}| sd|dkr9Pq9q9Wn|t @rŒ|jjdƒndS( Nis‹sNot a gzipped fileiisUnknown compression methodis( R/R R.tordR R1tFEXTRARNR tFCOMMENTtFHCRC(R3tmagictmethodtflagtxlenR=((s/usr/lib64/python2.7/gzip.pyt_read_gzip_headerÁs2             cCsô|jƒ|jtkr:ddl}t|jdƒ‚n|jdkrUtd‚nt |t ƒrs|j ƒ}nt |ƒdkrę|jj |jj|ƒƒ|jt |ƒ7_tj||jƒd@|_|jt |ƒ7_nt |ƒS(Ni˙˙˙˙s$write() on read-only GzipFile objects!write() on closed GzipFile objectil˙˙(RARR&terrnoR.tEBADFR/RR@Rt memoryviewttobytestlenRR-RDR(RBRCR0(R3tdataR^((s/usr/lib64/python2.7/gzip.pyRâs   i˙˙˙˙cCsu|jƒ|jtkr:ddl}t|jdƒ‚n|jdkr\|jdkr\dSd}|dkrÂy4x-t r |j |ƒt |j |dƒ}qtWWq.t k rž|j}q.Xnly=x6||jkrý|j |ƒt |j |dƒ}qČWWn,t k r-||jkr.|j}q.nX|j|j}|j|||!}|j||_|j|7_|S(Ni˙˙˙˙s$read() on write-only GzipFile objectiRii(RARRR^R.R_R#R/RR t_readtmintmax_read_chunktEOFErrorR0R$R"(R3RDR^treadsizeR0tchunk((s/usr/lib64/python2.7/gzip.pyR ÷s4        cCs/t|ƒ|j|_|jt|ƒ8_dS(N(RbR#R0(R3tbuf((s/usr/lib64/python2.7/gzip.pyt_unreadscCsl|jdkrtd‚n|jr­|jjƒ}|jjddƒ||jjƒkrgtd‚n|jj|ƒ|jƒ|jƒtj tj ƒ|_ t |_n|jj |ƒ}|dkrý|j jƒ}|jƒ|j|ƒtd‚n|j j |ƒ}|j|ƒ|j jdkrh|jjt|j jƒ ddƒ|jƒt|_ndS(Ns Reached EOFiiRii(R/RRgR!ttelltseekRTR]R(t decompressobjR+t decompresstFalseR tflusht _read_eoft_add_read_datat unused_dataRbR (R3RDtposRjt uncompress((s/usr/lib64/python2.7/gzip.pyRds0           $ cCs|tj||jƒd@|_|j|j}|j|||_|jt|ƒ|_|j|_|jt|ƒ|_dS(Nl˙˙( R(RBRCR0R$R"R#RbRD(R3RcR0((s/usr/lib64/python2.7/gzip.pyRsNs  cCsŇ|jjddƒt|jƒ}t|jƒ}||jkrhtdt|ƒt|jƒfƒ‚n||jd@kr‡td‚nd}x"|dkrą|jjdƒ}qW|rÎ|jjddƒndS(Niř˙˙˙isCRC check failed %s != %sl˙˙s!Incorrect length of data producedsi˙˙˙˙(R/RmR RCR.R;RDR (R3RBtisizetc((s/usr/lib64/python2.7/gzip.pyRrVs cCs |jdkS(N(R/R(R3((s/usr/lib64/python2.7/gzip.pyR?nscCsŸ|j}|dkrdSd|_zP|jtkrq|j|jjƒƒt||jƒt||j d@ƒnWd|j }|ršd|_ |j ƒnXdS(Nl˙˙( R/RRR&RR-RqRRCRDRtclose(R3R/R((s/usr/lib64/python2.7/gzip.pyRyrs     cCsI|jƒ|jtkrE|jj|jj|ƒƒ|jjƒndS(N(RARR&R/RR-Rq(R3t zlib_mode((s/usr/lib64/python2.7/gzip.pyRqƒs cCs |jjƒS(sĽInvoke the underlying file object's fileno() method. This will raise AttributeError if the underlying file object doesn't support fileno(). (R/tfileno(R3((s/usr/lib64/python2.7/gzip.pyR{ŠscCs_|jtkrtdƒ‚n|jjdƒt|_d|_d|_d|_ d|_ dS(s[Return the uncompressed stream file position indicator to the beginning of the filesCan't rewind in write modeiRN( RRR.R/RmR R!R"R#R$R0(R3((s/usr/lib64/python2.7/gzip.pytrewind’s    cCs |jtkS(N(RR(R3((s/usr/lib64/python2.7/gzip.pytreadabležscCs |jtkS(N(RR&(R3((s/usr/lib64/python2.7/gzip.pytwritableĄscCstS(N(R (R3((s/usr/lib64/python2.7/gzip.pytseekable¤sicCs*|r1|dkr"|j|}q1tdƒ‚n|jtkrŻ||jkr^tdƒ‚n||j}x)t|dƒD]}|jddƒq|W|j|ddƒnt|jtkr#||jkrÚ|jƒn||j}x%t|dƒD]}|j dƒqřW|j |dƒn|jS(NisSeek from end not supportedsNegative seek in write modeis( R0R@RR&R.txrangeRRR|R (R3R0twhencetcountti((s/usr/lib64/python2.7/gzip.pyRm§s&    cCsŻ|dkrŠ|j|j}|jjd|ƒd}|dkru|j||8_|j||7_|j||!Stj}|j}n|}g}xŰ|dkrs|j|ƒ}|jdƒ}||ksí|dkrút |ƒ|krú|d}n|dks|dkr@|j ||d ƒ|j ||dƒPn|j |ƒ|t |ƒ}t ||dƒ}q™W||jkr˘t ||jddƒ|_ndj |ƒS(Nis ii˙˙˙˙Rii(R0R$R"tfindR#tsystmaxintR%R RbtappendRkRetjoin(R3RDR0RƒRhtbufsRx((s/usr/lib64/python2.7/gzip.pytreadlineżs4    *  Ni(i (!t__name__t __module__t__doc__RRRfR4tpropertyR R>RAR'R2RTR]RR RkRdRsRrR?RyR(t Z_SYNC_FLUSHRqR{R|R}R~RRmRŠ(((s/usr/lib64/python2.7/gzip.pyR$s8[      !  !  2        cCsŹtjd}|o |ddk}|r6|d}n|sHdg}nx]|D]U}|rŢ|dkr‘tddddd tjƒ}tj}q9|d d krśd Gt|ƒGHqOnt|dƒ}tj|d d ƒ}n[|dkrtj}tdddd d tjƒ}n%tj|dƒ}t|d d ƒ}x0trk|j dƒ}|s[Pn|j |ƒq<W|tjk rˆ|j ƒn|tjk rO|j ƒqOqOWdS(Niis-dt-R RRR R/iý˙˙˙s.gzsfilename doesn't end in .gz:twbi( R…targvRtstdintstdoutR:RRR R RRy(targsRotargtftgRi((s/usr/lib64/python2.7/gzip.pyt_testçs<        !  t__main__(RRR…RPRGR(tioRt__all__tFTEXTRXRVRNRWRR&RR RtBufferedIOBaseRR™R‹(((s/usr/lib64/python2.7/gzip.pyts0    $   ˙Ä &