usr/lib64/python2.7/gzip.pyc000064400000035337147207550620011556 0ustar00 mfc@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 myfileobjthasattrRRtREADtTruet _new_membertextrabuft extrasizet extrastartt min_readsizetWRITEt _init_writetzlibt compressobjtDEFLATEDt MAX_WBITSt DEF_MEM_LEVELtcompresstIOErrortfileobjtoffsettmtimet_write_gzip_header(tselfR RRR,R.((s/usr/lib64/python2.7/gzip.pyt__init__-sH*  "             &      cCsSddl}|jdtd|jtkrL|jddkrL|jdS|jS(Nisuse the name attributeiis.gz(twarningstwarntDeprecationWarningRR#R(R0R2((s/usr/lib64/python2.7/gzip.pyR s  " cCs6t|j}d|dd!dtt|dS(Ns(treprR,thextid(R0ts((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(R0((s/usr/lib64/python2.7/gzip.pyt _check_closeds cCs>||_tjdd@|_d|_g|_d|_dS(NRli(RR%tcrc32tcrctsizetwritebuftbufsize(R0R ((s/usr/lib64/python2.7/gzip.pyR$s    cCs|jjd|jjdtjj|j}|jdrQ|d }nd}|rft}n|jjt||j }|dkrt j }nt |jt ||jjd|jjd|r|jj|dndS( Nsss.gziisst(R,RtostpathtbasenameRtendswithtFNAMEtchrR.RttimeRtlong(R0tfnametflagsR.((s/usr/lib64/python2.7/gzip.pyR/s"    cCs#tjdd@|_d|_dS(NRli(R%R?R@RA(R0((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 methodiRD( R,R R+tordR R.tFEXTRARIRtFCOMMENTtFHCRC(R0tmagictmethodtflagtxlenR:((s/usr/lib64/python2.7/gzip.pyt_read_gzip_headers2             cCs|j|jtkr:ddl}t|jdn|jdkrUtdnt |t rs|j }nt |dkr|j t ||_ tj||jd@|_|jj|jj||jt |7_nt |S(Nis$write() on read-only GzipFile objects!write() on closed GzipFile objectil(R>RR#terrnoR+tEBADFR,RR=t isinstancet memoryviewttobytestlenRAR%R?R@RR*R-(R0tdataRY((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(R>RRRYR+RZR R,RRt_readtmintmax_read_chunktEOFErrorR-R!R(R0RARYtreadsizeR-tchunk((s/usr/lib64/python2.7/gzip.pyR s4        cCs/t||j|_|jt|8_dS(N(R^R R-(R0tbuf((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,RRcRttelltseekRORXR%t decompressobjR(t decompresstFalseR tflusht _read_eoft_add_read_datat unused_dataR^R(R0RAtposRft uncompress((s/usr/lib64/python2.7/gzip.pyR`s0           $ cCs|tj||jd@|_|j|j}|j|||_|jt||_|j|_|jt||_dS(Nl( R%R?R@R-R!RR R^RA(R0R_R-((s/usr/lib64/python2.7/gzip.pyRoHs  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 producedRDi(R,RiR R@R+R8RAR (R0R?tisizetc((s/usr/lib64/python2.7/gzip.pyRnPs cCs |jdkS(N(R,R(R0((s/usr/lib64/python2.7/gzip.pyR<hscCs|jdkrdS|jtkrq|jj|jjt|j|jt|j|j d@d|_n|jt krd|_n|j r|j j d|_ ndS(Nl( R,RRR#RR*RmRR@RARRtclose(R0((s/usr/lib64/python2.7/gzip.pyRuls    cCsI|j|jtkrE|jj|jj||jjndS(N(R>RR#R,RR*Rm(R0t zlib_mode((s/usr/lib64/python2.7/gzip.pyRm{s 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(R0((s/usr/lib64/python2.7/gzip.pyRwscCs_|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,RiRRRR R!R-(R0((s/usr/lib64/python2.7/gzip.pytrewinds    cCs |jtkS(N(RR(R0((s/usr/lib64/python2.7/gzip.pytreadablescCs |jtkS(N(RR#(R0((s/usr/lib64/python2.7/gzip.pytwritablescCstS(N(R(R0((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 modeiRD( R-R=RR#R+txrangeRRRxR (R0R-twhencetcountti((s/usr/lib64/python2.7/gzip.pyRis&    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(R-R!RtfindR tsystmaxintR"R R^tappendRgRatjoin(R0RAR-RRdtbufsRt((s/usr/lib64/python2.7/gzip.pytreadlines4    *  Ni(i(!t__name__t __module__t__doc__RRRbR1tpropertyR R;R>R$R/RORXRR RgR`RoRnR<RuR%t Z_SYNC_FLUSHRmRwRxRyRzR{RiR(((s/usr/lib64/python2.7/gzip.pyR$s8\      !  !  2        c Cstjd}|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( RtargvRtstdintstdoutR7RRRR RRu(targsRktargtftgRe((s/usr/lib64/python2.7/gzip.pyt_tests<        !  t__main__(RRRRKRER%tioRt__all__tFTEXTRSRQRIRRRR#RR RtBufferedIOBaseRRR(((s/usr/lib64/python2.7/gzip.pyts0    $    &