%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/gzip.cpython-38.pyc

U

naS@sdZddlZddlZddlZddlZddlZddlZddlZddlZdddddgZ	d\Z
ZZZ
Zd	\ZZd
ZdZdZd
edddfddZddZGdddZGdddeZGdddejZGdddejZefddddZddZddZe dkredS)zFunctions 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.NBadGzipFileGzipFileopencompress
decompress))rrr	rbcCsd|kr d|krPtd|fn0|dk	r0td|dk	r@td|dk	rPtd|dd}t|tttjfr|t|||}n,t|d	st|d
rtd|||}nt	dd|krt
||||S|SdS)aOpen a gzip-compressed file in binary or text mode.

    The filename argument can be an actual filename (a str or bytes object), or
    an existing file object to read from or write to.

    The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for
    binary mode, or "rt", "wt", "xt" or "at" for text mode. The default mode is
    "rb", and the default compresslevel is 9.

    For binary mode, this function is equivalent to the GzipFile constructor:
    GzipFile(filename, mode, compresslevel). In this case, the encoding, errors
    and newline arguments must not be provided.

    For text mode, a GzipFile object is created, and wrapped in an
    io.TextIOWrapper instance with the specified encoding, error handling
    behavior, and line ending(s).

    tbzInvalid mode: %rNz0Argument '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_modebinary_filer& /usr/local/lib/python3.8/gzip.pyrs$cCs|td|dS)Nz<L)rstructpack)outputvaluer&r&r'write32uEsr,c@s<eZdZdZdddZddZdddZd	d
ZddZd
S)_PaddedFilezMinimal read-only file object that prepends a string to the contents
    of an actual file. Shouldn't be used outside of gzip.py, as it lacks
    essential functionality.cCs ||_t||_||_d|_dSNr)_bufferlen_lengthfile_read)selffprependr&r&r'__init__Os
z_PaddedFile.__init__cCs~|jdkr|j|S|j||jkrJ|j}|j|7_|j||jS|j}d|_|j|d|j||j|SdSN)r4r3rr2r0)r5sizerr&r&r'rUs
z_PaddedFile.readcCs>|jdkr||_n|jt|8_dSt|j|_d|_dSr/)r4r0r1r2)r5r7r&r&r'r7bs
z_PaddedFile.prependcCsd|_d|_|j|Sr9)r4r0r3seek)r5Zoffr&r&r'r;ksz_PaddedFile.seekcCsdSNTr&r5r&r&r'seekablepsz_PaddedFile.seekableN)r.)r.)	__name__
__module____qualname____doc__r8rr7r;r>r&r&r&r'r-Js

	r-c@seZdZdZdS)rz6Exception raised in some cases for invalid gzip files.N)r?r@rArBr&r&r&r'rtsc@seZdZdZdZddeddfddZeddZeddZ	d	d
Z
ddZd
dZddZ
d,ddZd-ddZddZeddZddZejfddZddZd d!Zd"d#Zd$d%Zd&d'Zejfd(d)Zd.d*d+ZdS)/ra
The GzipFile class simulates most of the methods of a file object with
    the exception of the truncate() method.

    This class only supports opening files in binary mode. If you need to open a
    compressed file in text mode, use the gzip.open() function.

    NcCs4|r"d|ksd|kr"td||r6d|kr6|d7}|dkrTt||pJd}|_|dkr|t|dd}t|ttfsd}n
t	
|}|dkrt|d	d}|d
rt|_
t|}t||_||_nN|drt|_
||t|tjtjtjd|_||_ntd|||_|j
tkr0||dS)
aGConstructor 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, an io.BytesIO 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 include 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', 'wb', 'x', or
        'xb' depending on whether the file will be read or written.  The default
        is the mode of fileobj if discernible; otherwise, the default is 'rb'.
        A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
        'wb', 'a' and 'ab', and 'x' and 'xb'.

        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 last modification time field in the stream when compressing.
        If omitted or None, the current time is used.

        rUzInvalid mode: {!r}rNrnamerr r)waxr)rformatbuiltinsr	myfileobjgetattrrrrrfspath
startswithREADr _GzipReaderrBufferedReaderr0rDWRITE_init_writezlibcompressobjDEFLATED	MAX_WBITS
DEF_MEM_LEVELr_write_mtimefileobj_write_gzip_header)r5rr r!rZmtimerawr&r&r'r8s@#


zGzipFile.__init__cCsBddl}|dtd|jtkr<|jdddkr<|jdS|jS)Nrzuse the name attributer.gz)warningswarnDeprecationWarningr rRrD)r5r`r&r&r'rs

zGzipFile.filenamecCs
|jjjS)z0Last modification time read from stream, or None)r0r]_last_mtimer=r&r&r'r\szGzipFile.mtimecCs.t|j}d|dddtt|dS)Nz<gzip r >)reprrZhexid)r5sr&r&r'__repr__s
zGzipFile.__repr__cCs.||_td|_d|_g|_d|_d|_dSNr.r)rDrTcrc32crcr:Zwritebufbufsizeoffset)r5rr&r&r'rSszGzipFile._init_writecCs|jd|jdz<tj|j}t|ts<|d}|	drR|dd}Wnt
k
rld}YnXd}|rzt}|jt|d|j
}|dkrt}t|jt||tkrd}n|tkrd	}nd
}|j||jd|r|j|d
dS)Nzlatin-1s.gzr^r.r)rZrrpathbasenamerDrrencodeendswithUnicodeEncodeErrorFNAMEchrrYtimer,int_COMPRESS_LEVEL_BEST_COMPRESS_LEVEL_FAST)r5r!Zfnameflagsr\Zxflr&r&r'r[s6



zGzipFile._write_gzip_headercCs||jtkr&ddl}t|jd|jdkr8tdt|t	rLt
|}nt|}|j}|dkr|j
|j||j|7_t||j|_|j|7_|S)Nrz$write() on read-only GzipFile objectz!write() on closed GzipFile object)_check_not_closedr rRerrnoOSErrorEBADFrZrrrr1
memoryviewnbytesrrr:rTrmrnrp)r5datarlengthr&r&r'rs 



zGzipFile.writerdcCs2||jtkr&ddl}t|jd|j|S)Nrz$read() on write-only GzipFile object)rr rOrrrr0rr5r:rr&r&r'rs

z
GzipFile.readcCs@||jtkr&ddl}t|jd|dkr4tj}|j	|S)zdImplements BufferedIOBase.read1()

        Reads up to a buffer's worth of data if size is negative.rNz%read1() on write-only GzipFile object)
rr rOrrrrDEFAULT_BUFFER_SIZEr0read1rr&r&r'r&s
zGzipFile.read1cCs2||jtkr&ddl}t|jd|j|S)Nrz$peek() on write-only GzipFile object)rr rOrrrr0peek)r5nrr&r&r'r3s

z
GzipFile.peekcCs
|jdkSr9rZr=r&r&r'closed:szGzipFile.closedcCs|j}|dkrdSd|_zP|jtkrR||jt||j	t||j
d@n|jtkrf|jW5|j}|rd|_|XdS)N)
rZrKcloser rRrrflushr,rnr:rOr0)r5rZrKr&r&r'r>s

zGzipFile.closecCs4||jtkr0|j|j||jdSr9)rr rRrZrrr)r5Z	zlib_moder&r&r'rQs
zGzipFile.flushcCs
|jS)zInvoke the underlying file object's fileno() method.

        This will raise AttributeError if the underlying file object
        doesn't support fileno().
        )rZfilenor=r&r&r'rXszGzipFile.filenocCs"|jtkrtd|jddS)z[Return the uncompressed stream file position indicator to the
        beginning of the filezCan't rewind in write moderN)r rOrr0r;r=r&r&r'rewind`s
zGzipFile.rewindcCs
|jtkSr9)r rOr=r&r&r'readablegszGzipFile.readablecCs
|jtkSr9)r rRr=r&r&r'writablejszGzipFile.writablecCsdSr<r&r=r&r&r'r>mszGzipFile.seekablecCs|jtkr|tjkr2|tjkr*|j|}ntd||jkrDtd||j}d}t|dD]}|	|q^|	d|dn |jt
kr||j
||S|jS)NzSeek from end not supportedzNegative seek in write modesru)r rRrSEEK_SETSEEK_CURrprrrangerrOrr0r;)r5rpwhencecountchunkir&r&r'r;ps 





z
GzipFile.seekcCs||j|Sr9)rr0readline)r5r:r&r&r'rszGzipFile.readline)rd)rd)rd)r?r@rArBrKrr8propertyrr\rkrSr[rrrrrrrTZ_SYNC_FLUSHrrrrrr>rrr;rr&r&r&r'rxs:

I

 



csZeZdZfddZddZddZddZdd
dZdd
ZddZ	fddZ
ZS)rPcs,tjt|tjtjdd|_d|_dS)N)ZwbitsT)superr8r-rT
decompressobjrW_new_memberrc)r5fp	__class__r&r'r8s
z_GzipReader.__init__cCstd|_d|_dSrl)rTrm_crc_stream_sizer=r&r&r'
_init_readsz_GzipReader._init_readcCsF|j|}t||krB|j|t|}|s8td||7}q|S)zRead exactly *n* bytes from `self._fp`

        This method is required because self._fp may be unbuffered,
        i.e. return short reads.
        ACompressed file ended before the end-of-stream marker was reached)_fprr1EOFError)r5rrrr&r&r'_read_exacts
z_GzipReader._read_exactcCs|jd}|dkrdS|dkr,td|td|d\}}|_|dkrVtd|t@r|td	|d\}|||t@r|jd
}|r|dkrqq|t	@r|jd
}|r|dkrqq|t
@r|ddS)
Nrr.FrqzNot a gzipped file (%r)z<BBIxxr
zUnknown compression methodz<HrruT)rrrr(unpackrrcFEXTRAr|FCOMMENTFHCRC)r5magicmethodflagZ	extra_lenrjr&r&r'_read_gzip_headers0

z_GzipReader._read_gzip_headerrdcCs|dkr|S|sdS|jjr>|d|_|jf|j|_|jrf||s`|j	|_
dSd|_|jt
j}|j||}|jjdkr|j|jjn|jjdkr|j|jj|dkrq|dkrtdq|||j	t|7_	|S)Nrr.TFr)readall
_decompressoreof	_read_eofr_decomp_factory_decomp_argsrr_pos_sizerrrrrunconsumed_tailr7unused_datar_add_read_datar1)r5r:bufZ
uncompressr&r&r'rs:

z_GzipReader.readcCs$t||j|_|jt||_dSr9)rTrmrrr1)r5rr&r&r'rsz_GzipReader._add_read_datacCstd|d\}}||jkr<tdt|t|jfn||jd@krRtdd}|dkrl|jd}qV|r||j	|dS)Nz<IIr
zCRC check failed %s != %srz!Incorrect length of data producedrur)
r(rrrrrhrrrr7)r5rmZisizecr&r&r'rs


z_GzipReader._read_eofcstd|_dSr<)r_rewindrr=rr&r'rs
z_GzipReader._rewind)rd)r?r@rAr8rrrrrrr
__classcell__r&r&rr'rPs!
3rP)r\c	Cs6t}t|d||d}||W5QRX|S)zCompress data in one shot and return the compressed string.
    Optional argument is the compression level, in range of 0-9.
    wb)rZr r!r\)rBytesIOrrgetvalue)rr!r\rr6r&r&r'rsc
Cs0tt|d}|W5QRSQRXdS)zYDecompress a gzip compressed string in one shot.
    Return the decompressed string.
    rN)rrrr)rr6r&r&r'rsc	Csddlm}|dd}|}|jdddd|jd	dd
d|jdddd
d|jdddgdd|}t}|jr|t}n
|jrt	}|j
D]}|jr|dkrtddt
jjd}t
jj}n>|dddkrt
d|t|d}t|ddd}nB|dkr"t
jj}tddt
jj|d}nt|d}t|dd}|d}|sPq^||q<|t
jjk	rt||t
jjk	r|qdS)Nr)ArgumentParserzeA simple command line interface for the gzip module: act like gzip, but do not delete the input file.)descriptionz--fast
store_truezcompress faster)actionhelpz--bestzcompress betterz-dz--decompresszact like gunzip instead of gzipargs*-r3)nargsdefaultmetavarrr)rr rZr^r_zfilename doesn't end in .gz: r)rr rZr!r)argparseradd_mutually_exclusive_groupadd_argument
parse_args_COMPRESS_LEVEL_TRADEOFFfastrZbestrrrrsysstdinbufferstdoutexitrrJrrr)	rparsergrouprr!argr6grr&r&r'main'sR





r__main__)!rBr(rr~rrTrJr_compression__all__ZFTEXTrrr|rrOrRrrrrr,r-rr
BaseStreamrDecompressReaderrPrrrr?r&r&r&r'<module>s: 
,*	0


Zerion Mini Shell 1.0