Your IP : 3.144.3.129


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/gzip.pyc

�
�mec@s�dZddlZddlZddlZddlZddlZddlZddlZddgZddddd	f\Z	Z
ZZ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(Ns<L(twritetstructtpack(toutputtvalue((s/usr/lib64/python2.7/gzip.pytwrite32uscCstjd|jd��dS(Ns<Iii(Rtunpacktread(tinput((s/usr/lib64/python2.7/gzip.pytread32strbi	cCst|||�S(s�Shorthand for GzipFile(filename, mode, compresslevel).

    The filename argument is required; mode defaults to 'rb'
    and compresslevel defaults to 9.

    (R(tfilenametmodet
compresslevel((s/usr/lib64/python2.7/gzip.pyRscBseZdZdZd Zdddddd�Zed��Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
d�Zd�Zdd�Zd�Zd�Zed��Zd�Zejd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd
d�Z RS(!s�The GzipFile class simulates most of the methods of a file object with
    the exception of the readinto() and truncate() methods.

    i
ii	c
Cs�|r|jdd�}n|r:d|kr:|d7}n|dkrhtj||pXd�}|_n|dkr�t|d�r�|jdkr�|j}q�d}n|dkr�t|d�r�|j}q�d}n|dd	!d
kr,t|_t	|_
d|_d|_d|_
||_d|_nx|dd	!dksR|dd	!d
kr�t|_|j|�tj|tjtjtjd�|_ntd|d�||_d|_||_|jtkr�|j�ndS(s{Constructor for the GzipFile class.

        At least one of fileobj and filename must be given a
        non-trivial value.

        The new class instance is based on fileobj, which can be a regular
        file, a StringIO object, or any other object which simulates a file.
        It defaults to None, in which case filename is opened to provide
        a file object.

        When fileobj is not None, the filename argument is only used to be
        included in the gzip file header, which may includes the original
        filename of the uncompressed file.  It defaults to the filename of
        fileobj, if discernible; otherwise, it defaults to the empty string,
        and in this case the original filename is not included in the header.

        The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb',
        depending on whether the file will be read or written.  The default
        is the mode of fileobj if discernible; otherwise, the default is 'rb'.
        Be aware that only the 'rb', 'ab', and 'wb' values should be used
        for cross-platform portability.

        The compresslevel argument is an integer from 0 to 9 controlling the
        level of compression; 1 is fastest and produces the least compression,
        and 9 is slowest and produces the most compression. 0 is no compression
        at all. The default is 9.

        The mtime argument is an optional numeric timestamp to be written
        to the stream when compressing.  All gzip compressed streams
        are required to contain a timestamp.  If omitted or None, the
        current time is used.  This module ignores the timestamp when
        decompressing; however, some programs, such as gunzip, make use
        of it.  The format of the timestamp is the same as that of the
        return value of time.time() and of the st_mtime member of the
        object returned by os.stat().

        tUttbRtnames<fdopen>RiitridtwtasMode s not supportedN(treplacetNonet__builtin__Rt	myfileobjthasattrRRtREADtTruet_new_membertextrabuft	extrasizet
extrastarttmin_readsizetWRITEt_init_writetzlibtcompressobjtDEFLATEDt	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(Ni����suse the name attributeii����s.gz(twarningstwarntDeprecationWarningRR#R(R0R2((s/usr/lib64/python2.7/gzip.pyR
�s
"cCs6t|j�}d|dd!dtt|��dS(Ns<gzip ii����t t>(treprR,thextid(R0ts((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(R0((s/usr/lib64/python2.7/gzip.pyt
_check_closed�s	cCs>||_tjd�d@|_d|_g|_d|_dS(NRl��i(RR%tcrc32tcrctsizetwritebuftbufsize(R0R
((s/usr/lib64/python2.7/gzip.pyR$�s
			cCs�|jjd�|jjd�tjj|j�}|jd�rQ|d }nd}|rft}n|jjt|��|j	}|dkr�tj�}nt|jt
|��|jjd�|jjd�|r�|jj|d�ndS(	Ns�ss.gzi����iss�t(R,RtostpathtbasenameRtendswithtFNAMEtchrR.RttimeRtlong(R0tfnametflagsR.((s/usr/lib64/python2.7/gzip.pyR/�s"
		cCs#tjd�d@|_d|_dS(NRl��i(R%R?R@RA(R0((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 methodiRD(R,R	R+tordRR.tFEXTRARIRtFCOMMENTtFHCRC(R0tmagictmethodtflagtxlenR:((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�|j
t|�|_
tj||j�d@|_|jj|jj|��|jt|�7_nt|�S(Ni����s$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.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(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|jdkrtd�n|jr�|jj�}|jjdd�||jj�krgtd�n|jj|�|j�|j�tj	tj
�|_t|_n|jj
|�}|dkr�|jj�}|j�|j|�td�n|jj|�}|j|�|jjdkrh|jjt|jj�dd�|j�t|_ndS(NsReached EOFiiRii(R,RRcRttelltseekRORXR%t
decompressobjR(t
decompresstFalseR	tflusht	_read_eoft_add_read_datatunused_dataR^R(R0RAtposRft
uncompress((s/usr/lib64/python2.7/gzip.pyR`s0	




$
cCs|tj||j�d@|_|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�|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 producedRDi����(R,RiRR@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|jj��t|j|j�t|j|j	d@�d|_n|jt
kr�d|_n|jr�|jj�d|_ndS(Nl��(
R,RRR#RR*RmRR@RARRtclose(R0((s/usr/lib64/python2.7/gzip.pyRuls	
cCsI|j�|jtkrE|jj|jj|��|jj�ndS(N(R>RR#R,RR*Rm(R0t	zlib_mode((s/usr/lib64/python2.7/gzip.pyRm{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(R0((s/usr/lib64/python2.7/gzip.pyRw�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,RiRRRR R!R-(R0((s/usr/lib64/python2.7/gzip.pytrewind�s				cCs
|jtkS(N(RR(R0((s/usr/lib64/python2.7/gzip.pytreadable�scCs
|jtkS(N(RR#(R0((s/usr/lib64/python2.7/gzip.pytwritable�scCstS(N(R(R0((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 modeiRD(
R-R=RR#R+txrangeRRRxR	(R0R-twhencetcountti((s/usr/lib64/python2.7/gzip.pyRi�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(R-R!RtfindR tsystmaxintR"R	R^tappendRgRatjoin(R0RAR-RRdtbufsRt((s/usr/lib64/python2.7/gzip.pytreadline�s4	*

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	Cs�tjd}|o |ddk}|r6|d}n|sHdg}nx]|D]U}|r�|dkr�tddddd	tj�}tj}q9|d
dkr�dGt|�GHqOnt|d�}tj|d
 d
�}n[|dkrtj}tdddd
d	tj�}n%tj|d�}t|dd
�}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�targvRtstdintstdoutR7RRRR	RRu(targsRktargtftgRe((s/usr/lib64/python2.7/gzip.pyt_test�s<


	!	
t__main__(R�RR�RKRER%tioRt__all__tFTEXTRSRQRIRRRR#RRRtBufferedIOBaseRR�R�(((s/usr/lib64/python2.7/gzip.pyt<module>s0$			��	&