usr/lib64/python2.7/gzip.pyo000064400000035604147204437200011562 0ustar00 zfc@sdZddlZddlZddlZddlZddlZddlZddlZddgZddddd f\Z Z Z Z Z ddf\ZZd Zd Zd d dZdejfdYZdZedkrendS(sFunctions 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.iNtGzipFiletopeniiiiicCs|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(Nisuse the name attributeiis.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|jrtdndS(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_closeds cCs>||_tjdd@|_d|_g|_d|_dS(NRli(RR(tcrc32tcrctsizetwritebuftbufsize(R3R ((s/usr/lib64/python2.7/gzip.pyR's    cCs6|jjd|jjdyVtjj|j}t|tsY|jd}n|j dru|d }nWnt k rd}nXd}|rt }n|jjt ||j }|dkrtj}nt|jt||jjd|jjd |r2|jj|d ndS( Nssslatin-1s.gziRisss(R/RtostpathtbasenameRRtstrtencodetendswithtUnicodeEncodeErrortFNAMEtchrR1RttimeRtlong(R3tfnametflagsR1((s/usr/lib64/python2.7/gzip.pyR2s,     cCs#tjdd@|_d|_dS(NRli(R(RBRCRD(R3((s/usr/lib64/python2.7/gzip.pyt _init_readscCs|jjd}|dkr*tdnt|jjd}|dkrZtdnt|jjd}t|j|_|jjd|t@rt|jjd}|dt|jjd}|jj|n|t@r,x6tr(|jjd}| s!|dkrPqqWn|t @rox6trk|jjd}| sd|dkr9Pq9q9Wn|t @r|jjdndS( NissNot a gzipped fileiisUnknown compression methodis( R/R R.tordR R1tFEXTRARNR tFCOMMENTtFHCRC(R3tmagictmethodtflagtxlenR=((s/usr/lib64/python2.7/gzip.pyt_read_gzip_headers2             cCs|j|jtkr:ddl}t|jdn|jdkrUtdnt |t rs|j }nt |dkr|jj |jj||jt |7_tj||jd@|_|jt |7_nt |S(Nis$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.pyRs   icCsu|j|jtkr:ddl}t|jdn|jdkr\|jdkr\dSd}|dkry4x-t r|j |t |j |d}qtWWq.t k r|j}q.Xnly=x6||jkr|j |t |j |d}qWWn,t k r-||jkr.|j}q.nX|j|j}|j|||!}|j||_|j|7_|S(Nis$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|jdkrtdn|jr|jj}|jjdd||jjkrgtdn|jj||j|jtj tj |_ t |_n|jj |}|dkr|j j}|j|j|tdn|j j |}|j||j jdkrh|jjt|j j dd|jt|_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||jd@|_|j|j}|j|||_|jt||_|j|_|jt||_dS(Nl( R(RBRCR0R$R"R#RbRD(R3RcR0((s/usr/lib64/python2.7/gzip.pyRsNs  cCs|jjddt|j}t|j}||jkrhtdt|t|jfn||jd@krtdnd}x"|dkr|jjd}qW|r|jjddndS(NiisCRC check failed %s != %sls!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|jjt||jt||j d@nWd|j }|rd|_ |j nXdS(Nl( R/RRR&RR-RqRRCRDRtclose(R3R/R((s/usr/lib64/python2.7/gzip.pyRyrs     cCsI|j|jtkrE|jj|jj||jjndS(N(RARR&R/RR-Rq(R3t zlib_mode((s/usr/lib64/python2.7/gzip.pyRqs cCs |jjS(sInvoke 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_|jtkrtdn|jjdt|_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.pytrewinds    cCs |jtkS(N(RR(R3((s/usr/lib64/python2.7/gzip.pytreadablescCs |jtkS(N(RR&(R3((s/usr/lib64/python2.7/gzip.pytwritablescCstS(N(R (R3((s/usr/lib64/python2.7/gzip.pytseekablesicCs*|r1|dkr"|j|}q1tdn|jtkr||jkr^tdn||j}x)t|dD]}|jddq|W|j|ddnt|jtkr#||jkr|jn||j}x%t|dD]}|j dqW|j |dn|jS(NisSeek from end not supportedsNegative seek in write modeis( R0R@RR&R.txrangeRRR|R (R3R0twhencetcountti((s/usr/lib64/python2.7/gzip.pyRms&    cCs|dkr|j|j}|jjd|d}|dkru|j||8_|j||7_|j||!Stj}|j}n|}g}x|dkrs|j|}|jd}||ks|dkrt ||kr|d}n|dks|dkr@|j ||d |j ||dPn|j ||t |}t ||d}qW||jkrt ||jdd|_ndj |S(Nis iiRii(R0R$R"tfindR#tsystmaxintR%R RbtappendRkRetjoin(R3RDR0RRhtbufsRx((s/usr/lib64/python2.7/gzip.pytreadlines4    *  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        cCstjd}|o |ddk}|r6|d}n|sHdg}nx]|D]U}|r|dkrtddddd tj}tj}q9|d d krd 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/is.gzsfilename doesn't end in .gz:twbi( RtargvRtstdintstdoutR:RRR R RRy(targsRotargtftgRi((s/usr/lib64/python2.7/gzip.pyt_tests<        !  t__main__(RRRRPRGR(tioRt__all__tFTEXTRXRVRNRWRR&RR RtBufferedIOBaseRRR(((s/usr/lib64/python2.7/gzip.pyts0    $    &