Hacked By AnonymousFox

Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/zipfile.cpython-38.pyc

U

i�f�Y�@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZzddlZejZWnek
r�dZejZYnXzddlZWnek
r�dZYnXzddlZWnek
r�dZYnXddddddd	d
ddd
ddg
ZGdd�de�ZGdd�de�ZeZZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(e�)e'�Z*dZ+dZ,dZ-dZ.d Z/d!Z0d"Z1d#Z2dZ3d$Z4d%Z5d&Z6e�)e5�Z7dZ8dZ9dZ:dZ;d Z<d!Z=d"Z>d#Z?dZ@d$ZAd'ZBd(ZCdZDd)ZEdZFd*ZGd+ZHd,ZId-ZJd.ZKd/ZLe�)eK�ZMdZNdZOdZPdZQd ZRd!ZSd"ZTd#ZUdZVd$ZWd'ZXd(ZYd0ZZd1Z[e�)eZ�Z\d2Z]d3Z^e�)e]�Z_dZ`dZadZbdZcd Zdd!Zed"Zfd#ZgdZhd$Zid4Zje�kd5�Zld6d7�Zmd8d9�Znd:d
�Zod;d<�Zpd=d>�ZqGd?d�der�Zsdatd@dA�ZudBdC�ZvGdDdE�dE�ZwGdFdG�dG�ZxdHdIdJdJdJdJdKdLdMdNdKdOdPdQdRdSdTdU�ZydVdW�ZzdtdXdY�Z{dZd[�Z|Gd\d]�d]�Z}Gd^d_�d_�Z~Gd`da�daej�Z�Gdbdc�dcej�Z�Gddd�d�Z�Gded
�d
e��Z�dfdg�Z�dhdi�Z�e�j�Z�djdk�Z�Gdldm�dme��Z�Gdndo�doe��Z�Gdpd�d�Z�dudqdr�Z�e�dsk�r
e��dS)vzP
Read and write ZIP files.

XXX references to utf-8 need further investigation.
�N�
BadZipFile�
BadZipfile�error�
ZIP_STORED�ZIP_DEFLATED�	ZIP_BZIP2�ZIP_LZMA�
is_zipfile�ZipInfo�ZipFile�	PyZipFile�LargeZipFile�Pathc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�,/opt/alt/python38/lib64/python3.8/zipfile.pyr+sc@seZdZdZdS)r
zu
    Raised when writing a zipfile, the zipfile requires ZIP64 extensions
    and those extensions are disabled.
    N)rrr�__doc__rrrrr
/si���������-�.�?s<4s4H2LHsPK��������	z<4s4B4HL2L5H2LsPK�
��
����z<4s2B4HL2L2HsPKz<4sLQLsPKz
<4sQ2H2L4QsPKiPK�<HHc
Cs�tj}d}g}d}}|dt|�krz||||d��\}}|d|}	||krt||krl|�|||��|	}d}|	}q|s�|Sd�|�S)NFrr T�)�_EXTRA_FIELD_STRUCT�unpack�len�append�join)
�extraZxidsr/Zmodified�buffer�start�iZxidZxlen�jrrr�_strip_extra�s r8cCs,zt|�rWdSWntk
r&YnXdS)NTF)�_EndRecData�OSError��fprrr�_check_zipfile�s
r=c	CsVd}z8t|d�rt|d�}nt|d��}t|�}W5QRXWntk
rPYnX|S)z�Quickly see if a file is a ZIP file by checking the magic number.

    The filename argument may be a file or file-like object too.
    F�readr;�rb)�hasattrr=�openr:)�filename�resultr<rrrr	�s
c
Csz|�|td�Wntk
r,|YSX|�t�}t|�tkrH|St�t|�\}}}}|tkrh|S|dksx|dkr�t	d��|�|tt
d�|�t
�}t|�t
kr�|St�t|�\
}}}	}
}}}
}}}|tkr�|S||t
<||t<||t<|
|t<||t<||t<||t<|S)zM
    Read the ZIP64 end-of-archive records and use that to update endrec
    rrrz3zipfiles that span multiple disks are not supported)�seek�sizeEndCentDir64Locatorr:r>r0�structr/�structEndArchive64Locator�stringEndArchive64Locatorr�sizeEndCentDir64�structEndArchive64�stringEndArchive64�_ECD_SIGNATURE�_ECD_DISK_NUMBER�_ECD_DISK_START�_ECD_ENTRIES_THIS_DISK�_ECD_ENTRIES_TOTAL�	_ECD_SIZE�_ECD_OFFSET)�fpin�offset�endrec�dataZsigZdisknoZreloffZdisksZsz�create_versionZread_versionZdisk_numZdisk_dirZdircountZ	dircount2ZdirsizeZ	diroffsetrrr�
_EndRecData64�s@



�rXc	Csh|�dd�|��}z|�td�Wntk
r<YdSX|��}t|�tkr�|dd�tkr�|dd�dkr�t�t	|�}t
|�}|�d�|�|t�t|t|�St
|dtd�}|�|d�|��}|�t�}|dk�rd|||t�}t|�tk�rdSt
t�t	|��}|t}||t|t|�}|�|�|�||�t|||||�SdS)	z�Return data from the "End of Central Directory" record, or None.

    The data is a list of the nine items in the ZIP "End of central dir"
    record followed by a tenth item, the file seek offset of this record.rrNr ���sr-i)rD�tell�sizeEndCentDirr:r>r0�stringEndArchiverFr/�structEndArchive�listr1rX�max�rfind�_ECD_COMMENT_SIZE)	rSZfilesizerVrUZmaxCommentStartr5ZrecDataZcommentSize�commentrrrr9sD��



�r9c@s\eZdZdZdZddd�Zdd�Zdd
d�Zdd
�Zdd�Z	e
ddd�dd��Zdd�Zd	S)r
z>Class with attributes describing each file in the ZIP archive.)�
orig_filenamerB�	date_time�
compress_type�_compresslevelrbr3�
create_systemrW�extract_version�reserved�	flag_bits�volume�
internal_attr�
external_attr�
header_offset�CRC�
compress_size�	file_size�	_raw_time�_end_offset�NoName��rrrrrcCs�||_|�td��}|dkr(|d|�}tjdkrJtj|krJ|�tjd�}||_||_|ddkrjtd��t	|_
d|_d|_d|_
tjdkr�d|_nd|_t|_t|_d|_d|_d|_d|_d|_d|_dS)Nr�/rvz+ZIP does not support timestamps before 1980r-Zwin32r)rc�find�chr�os�sep�replacerBrd�
ValueErrorrrerfrbr3�sys�platformrg�DEFAULT_VERSIONrWrhrirjrkrlrmrs)�selfrBrdZ	null_byterrr�__init__Ys2
zZipInfo.__init__cCs�d|jj|jfg}|jtkr8|�dt�|j|j��|jd?}|jd@}|rd|�dt	�
|��|rv|�d|�|��}|r�|jr�|�d|j�|r�|j
r�|jtks�|j|j
kr�|�d|j
�|�d	�d
�|�S)Nz<%s filename=%r� compress_type=%sr)rz filemode=%rz external_attr=%#xz
 file_size=%rz compress_size=%r�>�)�	__class__rrBrerr1�compressor_names�getrm�stat�filemode�is_dirrqrpr2)r�rC�hi�lo�isdirrrr�__repr__�s0
��



�
�
zZipInfo.__repr__NcCs||j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}|jd
@rfd}}}n|j}|j}|j}|j}d}	|dkr�|tkp�|tk}|r�d}
|t�|
dt�	|
�d	||�}|tks�|tkr�|s�t
d
��d}d}t}	|jt
k�rtt|	�}	n|jtk�rtt|	�}	t|	|j�|_t|	|j�|_|��\}}t�tt|j|j||j|||||t|�t|��
}
|
||S)z-Return the per-file header as a bytes object.rrvr$rr!rrr&r rNz<HHQQz'Filesize would require ZIP64 extensions���)rdrjrorprqr3�ZIP64_LIMITrF�pack�calcsizer
�
ZIP64_VERSIONrerr_�
BZIP2_VERSIONr�LZMA_VERSIONrhrW�_encodeFilenameFlags�structFileHeader�stringFileHeaderrir0)r��zip64�dt�dosdate�dostimerorprqr3�min_version�fmtrBrj�headerrrr�
FileHeader�s^$$
�
�zZipInfo.FileHeadercCsDz|j�d�|jfWStk
r>|j�d�|jdBfYSXdS)N�ascii�utf-8�)rB�encoderj�UnicodeEncodeError�r�rrrr��szZipInfo._encodeFilenameFlagscCs�|j}tj}t|�dk�r�|d|dd��\}}|dt|�krPtd||f��|dk�rp|dkrv|d|dd��}nV|dkr�|d	|dd
��}n:|dkr�|d|dd
��}n|dkr�d}ntd||f��d}|jdk�rt|�|kr�td��|||_|d7}|jdk�r6t|�|k�r$td��|||_|d7}|jdk�rpt|�|k�rXtd��|j}|||_|d7}||dd�}qdS)Nr r,z"Corrupt extra field %04x (size=%d)r�z<QQQ�r)z<QQrrz<Qrrr)l����r�z/Corrupt zip64 extra field. File size not found.r�z3Corrupt zip64 extra field. Compress size not found.z3Corrupt zip64 extra field. Header offset not found.)r3rFr/r0rrqrprn)r�r3r/�tpZlnZcounts�idx�oldrrr�_decodeExtra�sP
�
�
�
zZipInfo._decodeExtraT��strict_timestampsc	Cst|tj�rt�|�}t�|�}t�|j�}t�|j	�}|dd�}|sZ|ddkrZd}n|sn|ddkrnd}|dkrz|}tj
�tj
�|�d�}|dtj
tjfkr�|dd�}q�|r�|d	7}|||�}|jd
@d>|_|r�d|_|jdO_n|j|_|S)a_Construct an appropriate ZipInfo for a file on the filesystem.

        filename should be the path to a file or directory on the filesystem.

        arcname is the name which it will have within the archive (by default,
        this will be the same as filename, but without a drive letter and with
        leading path separators removed).
        rr"rvru�;)r�r���;r�Nrrwrr))�
isinstancerz�PathLike�fspathr��S_ISDIR�st_mode�time�	localtime�st_mtime�path�normpath�
splitdriver{�altseprmrq�st_size)	�clsrB�arcnamer��str��mtimerd�zinforrr�	from_files0



zZipInfo.from_filecCs|jddkS)z2Return True if this archive member is a directory.���rw�rBr�rrrr�'szZipInfo.is_dir)rtru)N)N)
rrrr�	__slots__r�r�r�r�r��classmethodr�r�rrrrr
>s
,
.2%cCs0td�D]"}|d@r"|d?dA}q|dL}q|S)Nrrl q[)�range)�crcr7rrr�_gen_crc1s

r�csld�d�d�tdkr&ttttd���at��fdd������fdd��|D]}�|�qL��fd	d
�}|S)NixV4i�gE#i�xV4�cs|d?�||Ad@AS)z(Compute the CRC32 primitive on one byte.r�r)Zchr�)�crctablerr�crc32Ksz_ZipDecrypter.<locals>.crc32cs<�|�����d@d@��ddd@���d?���dS)Nr�r�i�rr�r)�c)r��key0�key1�key2rr�update_keysOs
z"_ZipDecrypter.<locals>.update_keyscsNt�}|j}|D]4}�dB}|||dAd?d@N}�|�||�qt|�S)zDecrypt a bytes object.rrrr�)�	bytearrayr1�bytes)rVrCr1r��k)r�r�rr�	decrypterYs
z _ZipDecrypter.<locals>.decrypter)�	_crctabler^�mapr�r�)�pwd�pr�r)r�r�r�r�r�r�r�
_ZipDecrypterAs
r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�LZMACompressorcCs
d|_dS�N)�_compr�rrrr�iszLZMACompressor.__init__cCsFt�dtji�}tjtjt�tj|�gd�|_t�dddt	|��|S)N�id��filtersz<BBHr$r )
�lzmaZ_encode_filter_properties�FILTER_LZMA1r��
FORMAT_RAW�_decode_filter_propertiesr�rFr�r0)r�Zpropsrrr�_initls
�
zLZMACompressor._initcCs*|jdkr|��|j�|�S|j�|�Sr�)r�r��compress)r�rVrrrr�ss
zLZMACompressor.compresscCs&|jdkr|��|j��S|j��Sr�)r�r��flushr�rrrr�xs
zLZMACompressor.flushN)rrrr�r�r�r�rrrrr�gsr�c@seZdZdd�Zdd�ZdS)�LZMADecompressorcCsd|_d|_d|_dS)Nr-F)�_decomp�_unconsumed�eofr�rrrr��szLZMADecompressor.__init__c	Cs�|jdkr�|j|7_t|j�dkr*dSt�d|jdd��\}t|j�d|krXdStjtjt�tj	|jdd|��gd�|_|jd|d�}|`|j�
|�}|jj|_|S)Nr r-z<Hrr�)r�r�r0rFr/r�r�r�r�r��
decompressr�)r�rVZpsizerCrrrr��s"
��

zLZMADecompressor.decompressN)rrrr�r�rrrrr�~sr�ZstoreZshrink�reduceZimplode�tokenizeZdeflateZ	deflate64Zbzip2r�ZterseZlz77ZwavpackZppmd)rrrrr r!r"r#rr$r%rrr+��a�bcCsX|tkr
nJ|tkr tsTtd��n4|tkr6tsTtd��n|tkrLtsTtd��ntd��dS)Nz.Compression requires the (missing) zlib modulez-Compression requires the (missing) bz2 modulez.Compression requires the (missing) lzma modulez(That compression method is not supported)	rr�zlib�RuntimeErrorr�bz2rr��NotImplementedError)�compressionrrr�_check_compression�s$���r�cCsj|tkr2|dk	r t�|tjd�St�tjtjd�S|tkrT|dk	rLt�|�St��S|tkrbt	�SdSdS)N��)
rr�ZcompressobjZDEFLATEDZZ_DEFAULT_COMPRESSIONrr�Z
BZ2Compressorrr�)re�
compresslevelrrr�_get_compressor�s
r�cCsvt|�|tkrdS|tkr&t�d�S|tkr6t��S|tkrDt	�St
�|�}|rdtd||f��ntd|f��dS)Nr�zcompression type %d (%s)zcompression type %d)
r�rrr�Z
decompressobjrr�ZBZ2Decompressorrr�r�r�r�)reZdescrrrr�_get_decompressor�s

rc@s0eZdZdd�Zddd�Zd
dd�Zd	d
�ZdS)�_SharedFilecCs2||_||_||_||_||_|j|_|j|_dSr�)�_file�_pos�_close�_lock�_writing�seekablerZ)r��file�pos�close�lockZwritingrrrr��sz_SharedFile.__init__rc
CsN|j�>|��rtd��|j�||�|j��|_|jW5QR�SQRXdS)Nz}Can't reposition in the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rrr}rrDrZr)r�rT�whencerrrrD�sz_SharedFile.seekr�c
CsX|j�H|��rtd��|j�|j�|j�|�}|j��|_|W5QR�SQRXdS)N�yCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rrr}rrDrr>rZ�r��nrVrrrr>�sz_SharedFile.readcCs$|jdk	r |j}d|_|�|�dSr�)rr)r��fileobjrrrr
s
z_SharedFile.closeN)r)r�)rrrr�rDr>r
rrrrr�s	


rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�	_TellablecCs||_d|_dS�Nr)r<rT�r�r<rrrr�
sz_Tellable.__init__cCs|j�|�}|j|7_|Sr�)r<�writerT)r�rVrrrrrsz_Tellable.writecCs|jSr�)rTr�rrrrZsz_Tellable.tellcCs|j��dSr�)r<r�r�rrrr�sz_Tellable.flushcCs|j��dSr�)r<r
r�rrrr
sz_Tellable.closeN)rrrr�rrZr�r
rrrrr	s
rcs�eZdZdZdZdZdZd(dd�Zd	d
�Zdd�Z	d)dd�Z
d*dd�Zdd�Zd+dd�Z
dd�Zdd�Zdd�Zdd�Z�fdd �Zd!d"�Zd,d$d%�Zd&d'�Z�ZS)-�
ZipExtFilezZFile-like object for reading an archive member.
       Is returned by ZipFile.open().
    i@iiNFcCs(||_||_||_|j|_|j|_|j|_t	|j�|_
d|_d|_d|_
d|_||_|j|_t|d�rz|j|_td�|_nd|_d|_z4|��r�|��|_|j|_|j|_|j|_d|_Wntk
r�YnXd|_|�r$|j d@r�|j!d?d@}n|jd?d@}|�"�}||k�r$t#d	|j$��dS)
NFr-rroTrr�r�zBad password for file %r)%�_fileobj�_pwd�_close_fileobjre�_compress_typerp�_compress_leftrq�_leftr�
_decompressor�_eof�_readbuffer�_offset�newlines�moderB�namer@ro�
_expected_crcr��_running_crc�	_seekablerrZ�_orig_compress_start�_orig_compress_size�_orig_file_size�_orig_start_crc�AttributeError�
_decrypterrjrr�_init_decrypterr�rc)r�rr!�zipinfor�Z
close_fileobjZ
check_byte�hrrrr�+sF




zZipExtFile.__init__cCs4t|j�|_|j�d�}|jd8_|�|�dS)Nrr&)r�rr+rr>r)r�r�rrrr,^szZipExtFile._init_decryptercCsvd|jj|jjfg}|jsX|�d|j|jf�|jtkrb|�dt	�
|j|j��n
|�d�|�d�d�|�S)N�<%s.%sz name=%r mode=%rr��	 [closed]r�r�)r�rr�closedr1r"r!rrr�r�r2�r�rCrrrr�is�
��

zZipExtFile.__repr__r�cCsL|dkr>|j�d|j�d}|dkr>|j|j|�}||_|Stj�||�S)zrRead and return a line from the stream.

        If limit is specified, at most limit bytes will be read.
        r�
r)rrxr�io�BufferedIOBase�readline)r��limitr6�linerrrr6wszZipExtFile.readlinercCsr|t|j�|jkr\|�|�}t|�|jkrJ||j|jd�|_d|_n|jt|�8_|j|j|jd�S)z6Returns buffered bytes without advancing the position.Nri)r0rrr>)r�r�chunkrrr�peek�s
zZipExtFile.peekcCsdS�NTrr�rrr�readable�szZipExtFile.readablecCs|dks|dkrH|j|jd�}d|_d|_|jsD||�|j�7}q,|S||j}|t|j�krz|j|j|�}||_|S|t|j�}|j|jd�}d|_d|_|dkr�|js�|�|�}|t|�kr�||_||_||d|�7}q�||7}|t|�8}q�|S)z�Read and return up to n bytes.
        If the argument is omitted, None, or negative, data is read and returned until EOF is reached.
        Nrr-�rrr�_read1�MAX_Nr0)r�r�buf�endrVrrrr>�s4

zZipExtFile.readcCs@|jdkrdSt||j�|_|jr<|j|jkr<td|j��dS)NzBad CRC-32 for file %r)r#r�r$rrr")r��newdatarrr�_update_crc�s

zZipExtFile._update_crccCs|dks|dkrR|j|jd�}d|_d|_|jsN|�|j�}|r,||7}qNq,|S||j}|t|j�kr�|j|j|�}||_|S|t|j�}|j|jd�}d|_d|_|dk�r|j�s|�|�}|t|�kr�||_||_||d|�7}�q|r�||7}�qq�|S)z7Read up to n bytes with at most one read() system call.Nrr-r=)r�rr@rVrArrr�read1�s>


zZipExtFile.read1cCs"|js|dkrdS|jtkrH|jj}|t|�krR||�|t|��7}n
|�|�}|jtkrj|jdk|_nx|jtkr�t	||j
�}|j�||�}|jjp�|jdko�|jj|_|jr�||j�
�7}n |j�|�}|jjp�|jdk|_|d|j�}|jt|�8_|jdk�rd|_|�|�|S)Nrr-T)rrrrZunconsumed_tailr0�_read2rrr_�
MIN_READ_SIZEr�r�r�rrCrrrrr>�s4




�
zZipExtFile._read1cCsd|jdkrdSt||j�}t||j�}|j�|�}|jt|�8_|sLt�|jdk	r`|�|�}|S)Nrr-)	rr_rF�minrr>r0�EOFErrorr+rrrrrEs


zZipExtFile._read2cs&z|jr|j��W5t���XdSr�)�superr
rrr��r�rrr
szZipExtFile.closecCs|jSr�)r%r�rrrr"szZipExtFile.seekablercCs>|jst�d��|��}|dkr&|}n.|dkr8||}n|dkrL|j|}ntd��||jkrd|j}|dkrpd}||}||j}|dkr�|t|j�kr�||_d}nf|dk�r
|j	�
|j�|j|_
|j|_|j|_d|_d|_t|j�|_d|_|}|jdk	�r
|��|dk�r6t|j|�}|�|�||8}�q
|��S)N�!underlying stream is not seekablerrrzCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r-F)r%r4�UnsupportedOperationrZr(r}rr0rrrDr&r)r$r'rrrrrrr+r,rG�
MAX_SEEK_READr>)r�rTrZcurr_posZnew_posZread_offsetZbuff_offsetZread_lenrrrrD%sH






zZipExtFile.seekcCs0|jst�d��|j|jt|j�|j}|S)NrK)r%r4rLr(rr0rr)r�ZfileposrrrrZUs
zZipExtFile.tell)NF)r�)r)r�)r)rrrrr?rFrMr�r,r�r6r:r<r>rCrDr>rEr
rrDrZ�
__classcell__rrrJrrs*�
3



!
%$
0rcs@eZdZdd�Zedd��Zdd�Zdd�Z�fd	d
�Z�Z	S)�
_ZipWriteFilecCs8||_||_||_t|j|j�|_d|_d|_d|_	dSr)
�_zinfo�_zip64�_zipfiler�rerf�_compressor�
_file_size�_compress_size�_crc)r��zfr�r�rrrr�]s�z_ZipWriteFile.__init__cCs|jjSr�)rRr<r�rrrrgsz_ZipWriteFile._fileobjcCsdSr;rr�rrr�writableksz_ZipWriteFile.writablecCsf|jrtd��t|�}|j|7_t||j�|_|jrV|j�|�}|jt|�7_|j	�
|�|S)NzI/O operation on closed file.)r1r}r0rTr�rVrSr�rUrr)r�rV�nbytesrrrrnsz_ZipWriteFile.writec	sb|jr
dS�zFt���|jrR|j��}|jt|�7_|j	�
|�|j|j_n
|j
|j_|j|j_|j
|j_|jjd@r�|jr�dnd}|j	�
t�|t|jj|jj|jj��|j	��|j_nn|js�|j
tkr�td��|jtkr�td��|j	��|j_|j	�|jj�|j	�
|j�|j��|j	�|jj�|jj�|j�|j|jj|jj <W5d|j_XdS)NFrz<LLQQz<LLLLz+File size unexpectedly exceeded ZIP64 limitz1Compressed size unexpectedly exceeded ZIP64 limit)!r1rRrrIr
rSr�rUr0rrrPrprTrVrorqrjrQrFr��
_DD_SIGNATURErZ�	start_dirr�r�rDrnr��filelistr1�
NameToInforB)r�r@r�rJrrr
zsF




�
�
�z_ZipWriteFile.close)
rrrr��propertyrrXrr
rNrrrJrrO\s

rOc@s$eZdZdZdZdZdeddfdd�dd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
d=dd�Zdd�Zdd�Zdd�Zedd��Zejdd��Zd>dd �Zd?d!d"�d#d$�Zd@d%d&�ZdAd'd(�ZdBd)d*�Zed+d,��Zd-d.�Zd/d0�ZdCd1d2�ZdDd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"d;d<�Z#dS)Erai Class with methods to open, read, write, close, list zip files.

    z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True,
                compresslevel=None)

    file: Either the path to the file, or a file-like object.
          If it is a path, the file will be opened and closed by ZipFile.
    mode: The mode can be either read 'r', write 'w', exclusive create 'x',
          or append 'a'.
    compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),
                 ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma).
    allowZip64: if True ZipFile will create files with ZIP64 extensions when
                needed, otherwise it will raise an exception when this would
                be necessary.
    compresslevel: None (default for the given compression type) or an integer
                   specifying the level to pass to the compressor.
                   When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
                   When using ZIP_DEFLATED integers 0 through 9 are accepted.
                   When using ZIP_BZIP2 integers 1 through 9 are accepted.

    N�rTr�c
	CsP|dkrtd��t|�||_d|_d|_i|_g|_||_||_||_	d|_
d|_||_t
|tj�rpt�|�}t
|t�r�d|_||_ddd	d
dddd
�}||}zt�||�|_Wq�tk
r�||kr�||}Yq��Yq�Xq�q�nd|_||_t|dd�|_d|_t��|_d|_d|_�z|dk�r4|��n�|dk�r�d|_z|j� �|_!Wn2t"tfk
�r�t#|j�|_d|_!d|_Yn6Xz|j�$|j!�Wn t"tfk
�r�d|_YnXnf|dk�rz|��|j�$|j!�Wn6t%k
�r|j�$dd�d|_|j� �|_!YnXntd��Wn$|j}	d|_|�&|	��YnXdS)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
        or append 'a'.)r_�w�x�az+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNr-r?�w+b�x+b�r+b�wbZxb)r_r`rarbrercrdrr"Tr_)r`rarbrz"Mode must be 'r', 'w', 'x', or 'a')'r}r��_allowZip64�
_didModify�debugr]r\r�r�r!r��_comment�_strict_timestampsr�rzr�r��str�_filePassedrBr4rAr<r:�getattr�_fileRefCnt�	threading�RLockrr%r�_RealGetContentsrZr[r*rrDr�_fpclose)
r�rr!r��
allowZip64r�r�ZmodeDictr�r<rrrr��s�

�





zZipFile.__init__cCs|Sr�rr�rrr�	__enter__szZipFile.__enter__cCs|��dSr��r
)r��type�value�	tracebackrrr�__exit__!szZipFile.__exit__cCs�d|jj|jjfg}|jdk	rd|jr8|�d|j�n|jdk	rR|�d|j�|�d|j�n
|�d�|�d�d�|�S)Nr/z file=%rz filename=%rz mode=%rr0r�r�)	r�rrr<rmr1rBr!r2r2rrrr�$s�



zZipFile.__repr__cCs�|j}zt|�}Wntk
r.td��YnX|s<td��|jdkrNt|�|t}|t}|t|_	|t
||}|ttkr�|t
t8}|jdkr�||}td|||�|||_|�|jd�|�|�}t�|�}d}||k�r�|�t�}	t|	�tk�r
td��t�t|	�}	|	ttk�r,td��|jdk�r@t|	�|�|	t�}
|	d}|d	@�rl|
�d
�}
n
|
�d�}
t|
�}|�|	t�|_|�|	t �|_!|	t"|_#|	dd�\|_$|_%|_&|_'|_(|_)}
}|_*|_+|_,|j&t-k�r�t.d
|j&d��|	dd�\|_/|_0|_1|
|_2|d?d|d?d@|d@|
d?|
d?d@|
d@df|_3|�4�|j#||_#|j5�6|�||j7|j8<|t|	t|	t|	t }|jdkr�td|�q�|j}t9|j5dd�dd�D]}||_:|j#}�q�dS)z/Read in the table of contents for the ZIP file.zFile is not a zip filerrzgiven, inferred, offsetrzTruncated central directoryz&Bad magic number for central directoryr!r�r��cp437rzzip file version %.1fr%r(r+r$rvr�r&r�totalcSs|jSr�)rn)r�rrr�<lambda>�r-z*ZipFile._RealGetContents.<locals>.<lambda>T)�key�reverseN);r<r9r:rri�printrQrR�_ECD_COMMENTrj�
_ECD_LOCATIONrLrKrIrEr[rDr>r4�BytesIO�sizeCentralDirr0rFr/�structCentralDir�
_CD_SIGNATURE�stringCentralDir�_CD_FILENAME_LENGTH�decoder
�_CD_EXTRA_FIELD_LENGTHr3�_CD_COMMENT_LENGTHrb�_CD_LOCAL_HEADER_OFFSETrnrWrgrhrirjrerorprq�MAX_EXTRACT_VERSIONr�rkrlrmrrrdr�r\r1r]rB�sortedrs)r�r<rUZsize_cdZ	offset_cd�concatZinferredrVr|�centdirrB�flagsra�t�dZ
end_offsetr�rrrrr2s�











��

���
�
zZipFile._RealGetContentscCsdd�|jD�S)z+Return a list of file names in the archive.cSsg|]
}|j�qSrr�)�.0rVrrr�
<listcomp>�sz$ZipFile.namelist.<locals>.<listcomp>�r\r�rrr�namelist�szZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the
        archive.r�r�rrr�infolist�szZipFile.infolistcCsLtdd|d�|jD]0}d|jdd�}td|j||jf|d�qdS)z+Print a table of contents for the zip file.z%-46s %19s %12s)z	File NamezModified    ZSize�rz%d-%02d-%02d %02d:%02d:%02dNr"z
%-46s %s %12d)r�r\rdrBrq)r�rr��daterrr�printdir�s�
�zZipFile.printdirc
Cs^d}|jD]N}z*|�|jd��}|�|�r,q W5QRXWq
tk
rV|jYSXq
dS)z%Read all the files and check the CRC.ir_N)r\rArBr>r)r�Z
chunk_sizer��frrr�testzip�s

zZipFile.testzipcCs$|j�|�}|dkr td|��|S)z,Return the instance of ZipInfo given 'name'.Nz(There is no item named %r in the archive)r]r��KeyError)r�r"�inforrr�getinfo�s�zZipFile.getinfocCs6|r t|t�s tdt|�j��|r,||_nd|_dS)z)Set default password for encrypted files.�pwd: expected bytes, got %sN)r�r��	TypeErrorrwrr�)r�r�rrr�setpassword�s
zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)rjr�rrrrb�szZipFile.commentcCs^t|t�stdt|�j��t|�tkrNddl}|jdtdd�|dt�}||_	d|_
dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr��
stacklevelT)r�r�r�rwrr0�ZIP_MAX_COMMENT�warnings�warnrjrh)r�rbr�rrrrb�s
��c
Cs.|�|d|��}|��W5QR�SQRXdS)zReturn file bytes for name.r_N�rAr>)r�r"r�r<rrrr>�szZipFile.readF��force_zip64csJ|dkrtd��|r0t|t�s0tdt|�j��|rD|dkrDtd���jsRtd��t|t�rb|}n,|dkr�t|�}�j|_	�j
|_n
��|�}|dkr��j
||d�S�jr�td���jd	7_t�j|j�j�j�fd
d��}�zL|�t�}t|�tk�rtd��t�t|�}|ttk�r&td
��|�|t�}|t�rL|�|t�|jd@�r`t d��|jd@�rtt d��|t!d@�r�|�"d�}	n
|�"d�}	|	|j#k�r�td|j#|f��|j$dk	�r�|�%�|j&|j$k�r�td|j#�d���|jd	@}
|
�r|�s�j'}|�st(d|��nd}t)||||d�WS|�*��YnXdS)auReturn file-like object for 'name'.

        name is a string for the file name within the ZIP file, or a ZipInfo
        object.

        mode should be 'r' to read a file already in the ZIP file, or 'w' to
        write to a file newly added to the archive.

        pwd is the password to decrypt files (only used for reading).

        When writing, if the file size is not known in advance but may exceed
        2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large
        files.  If the size is known in advance, it is best to pass a ZipInfo
        instance for name, with zinfo.file_size set.
        >r_r`zopen() requires mode "r" or "w"r�r`z'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedr�r
rcs�jSr�)rrr�rrr}�r-zZipFile.open.<locals>.<lambda>zTruncated file headerz Bad magic number for file header� z$compressed patched data (flag bit 5)�@zstrong encryption (flag bit 6)r�r�r{z/File name in directory %r and header %r differ.NzOverlapped entries: z (possible zip bomb)z6File %r is encrypted, password required for extractionT)+r}r�r�r�rwrr<r
r�rer�rfr��_open_to_writerrorrnrsrr>�sizeFileHeaderr0rrFr/r��
_FH_SIGNATUREr��_FH_FILENAME_LENGTH�_FH_EXTRA_FIELD_LENGTHrjr��_FH_GENERAL_PURPOSE_FLAG_BITSr�rcrsrZrpr�r�rr
)r�r"r!r�r�r�Zzef_fileZfheader�fnameZ	fname_strZis_encryptedrr�rrA�s��




�


���
�zZipFile.opencCs�|r|jstd��|jr td��t|d�s0d|_d|_d|_d|_|jt	krZ|jdO_|j
sn|jdO_|jszd|_|jo�|p�|jdtk}|j
r�|j
�|j�|j
��|_|�|�d	|_|j
�|�|��d	|_t|||�S)
NzHforce_zip64 is True, but allowZip64 was False when opening the ZIP file.zzCan't write to the ZIP file while there is another write handle open on it. Close the first handle before opening another.rqrrr��g�������?T)rgr}rr@rqrprorjrerr%rmr�r<rDr[rZrn�_writecheckrhrr�rO)r�r�r�r�rrrr�4s8
�

�
zZipFile._open_to_writecCs*|dkrt��}n
t�|�}|�|||�S)a#Extract a member from the archive to the current working directory,
           using its full name. Its file information is extracted as accurately
           as possible. `member' may be a filename or a ZipInfo object. You can
           specify a different directory using `path'.
        N)rz�getcwdr��_extract_member)r��memberr�r�rrr�extract_s

zZipFile.extractcCsH|dkr|��}|dkr"t��}n
t�|�}|D]}|�|||�q0dS)z�Extract all members from the archive to the current working
           directory. `path' specifies a different directory to extract to.
           `members' is optional and must be a subset of the list returned
           by namelist().
        N)r�rzr�r�r�)r�r��membersr�r-rrr�
extractallls

zZipFile.extractallcCs^|j}|s(d}t�|dt|��}||_|�|�}dd�|�|�D�}|�dd�|D��}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*�_css|]}|�d�VqdS)�.N)�rstrip�r�rarrr�	<genexpr>�sz1ZipFile._sanitize_windows_name.<locals>.<genexpr>css|]}|r|VqdSr�rr�rrrr��s)�!_windows_illegal_name_trans_tablerl�	maketransr0�	translate�splitr2)r�r��pathsep�tableZillegalrrr�_sanitize_windows_name}s
zZipFile._sanitize_windows_namec
sLt|t�s|�|�}|j�dtjj�}tjjrB|�tjjtjj�}tj�	|�d}dtjj
tjjf�tjj��fdd�|�
tjj�D��}tjjdkr�|�|tjj�}tj�||�}tj�|�}tj�|�}|r�tj�|�s�t�|�|���rtj�|��st�|�|S|j||d��(}t|d��}t�||�W5QRXW5QRX|S)	zbExtract the ZipInfo object 'member' to a physical
           file on the path targetpath.
        rwrr�c3s|]}|�kr|VqdSr�rr��Zinvalid_path_partsrrr��s�z*ZipFile._extract_member.<locals>.<genexpr>�\)r�rf)r�r
r�rBr|rzr�r{r�r��curdir�pardirr2r�r�r��dirname�exists�makedirsr�r��mkdirrA�shutil�copyfileobj)r�r�Z
targetpathr�r�Z	upperdirs�source�targetrr�rr��s2

&


� zZipFile._extract_membercCs�|j|jkr(ddl}|jd|jdd�|jdkr:td��|jsHtd��t|j�|j	s�d}t
|j�tkrpd	}n|j
tkr�d
}n|jtkr�d}|r�t|d��dS)
z6Check for errors before writing a file to the archive.rNzDuplicate name: %rrr��r`rarbz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closed�Files countZFilesizezZipfile size� would require ZIP64 extensions)rBr]r�r�r!r}r<r�rergr0r\�ZIP_FILECOUNT_LIMITrqr�rnr
)r�r�r��requires_zip64rrrr��s,
�


�zZipFile._writecheckc
CsP|jstd��|jrtd��tj|||jd�}|��rDd|_d|_n0|dk	rT||_	n|j
|_	|dk	rl||_n|j|_|���r|j
��|jr�|j�|j�|j��|_|j	tkr�|jdO_|�|�d|_|j�|�||j|j<|j�|�d��|j��|_W5QRXn<t|d	��,}|�|d
��}t�||d�W5QRXW5QRXdS)zLPut the bytes from filename into the archive under the name
        arcname.�7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsr�rNrTFr?r`i ) r<r}rr
r�rkr�rprorer�rfr�rr%rDr[rZrnrrjr�rhr\r1r]rBrr�rAr�r�)r�rBr�rer�r��src�destrrrr�sF���


z
ZipFile.writec
Cs�t|t�r|�d�}t|t�sxt|t�t���dd�d�}|j|_|j|_	|j
ddkrpd|_|jdO_q|d	|_n|}|js�t
d
��|jr�t
d��|dk	r�||_|dk	r�||_	t|�|_|j�*|j|dd
��}|�|�W5QRXW5QRXdS)aWrite a file into the archive.  The contents is 'data', which
        may be either a 'str' or a 'bytes' instance; if it is a 'str',
        it is encoded as UTF-8 first.
        'zinfo_or_arcname' is either a ZipInfo instance or
        the name of the file in the archive.r�Nr")rBrdr�rwi�Ar)r�r�z?Can't write to ZIP archive while an open writing handle exists.r`)r!)r�rlr�r
r�r�r�rer�rfrBrmr<r}rr0rqrrAr)r�Zzinfo_or_arcnamerVrer�r�r�rrr�writestr�s:


���
zZipFile.writestrcCs|��dS)z2Call the "close()" method in case the user forgot.Nrvr�rrr�__del__'szZipFile.__del__c	Cs||jdkrdS|jrtd��zB|jdkr\|jr\|j�"|jrJ|j�|j	�|�
�W5QRXW5|j}d|_|�|�XdS)zOClose the file, and for mode 'w', 'x' and 'a' write the ending
        records.NzvCan't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip.r�)r<rr}rsr!rhrr%rDr[�_write_end_recordrrrrr
+s
z
ZipFile.closecCs�|jD�]D}|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}g}|jtksr|jtkr�|�|j�|�|j�d
}d
}n|j}|j}|jtkr�|�|j�d
}n|j}|j}	d}
|�rt|	d�}	t	j
dd
t|�ddt|�f|��|	}	t}
|j
tk�r$tt|
�}
n|j
tk�r:tt|
�}
t|
|j�}t|
|j�}zZ|��\}
}t	�
tt||j||j||j
|||j||t|
�t|	�t|j�d|j|j|�}Wnltk
�rttt||j||j|j |j
|||j||t|j!�t|	�t|j�d|j|j|ft"j#d��YnX|j$�%|�|j$�%|
�|j$�%|	�|j$�%|j�q|j$�&�}t|j�}||j'}|j'}d}|t(k�r�d}n|tk�r�d}n|tk�r�d}|�r$|j)�s�t*|d��t	�
t+t,ddddd||||�}|j$�%|�t	�
t-t.d|d�}|j$�%|�t/|d�}t/|d
�}t/|d
�}t	�
t0t1dd||||t|j2��	}|j$�%|�|j$�%|j2�|j3dk�rt|j$�4�|j$�5�dS)Nrrvr$rr!rrr&r r�)rr,�Qrr�r�zCentral directory offsetzCentral directory sizer��,rrrb)6r\rdrqr�rpr1rnr3r8rFr�r0r�rerr_r�rr�rhrWr�r�r�rgrirorbrlrm�DeprecationWarningr�rjrBr~�stderrr<rrZr[r�rgr
rJrKrGrHrGr]r\rjr!�truncater�)r�r�r�r�r�r3rqrprnZ
extra_datar�rhrWrBrjr�Zpos2ZcentDirCountZcentDirSizeZ
centDirOffsetr�Zzip64endrecZzip64locrecrUrrrr�As$$
�


���
���





���


�
zZipFile._write_end_recordcCs4|jdkst�|jd8_|js0|js0|��dS)Nrr)ro�AssertionErrorrmr
rrrrrs�szZipFile._fpclose)N)N)r_N)F)NN)NNN)NNN)NN)$rrrrr<r�rr�rurzr�rrr�r�r�r�r�r�r^rb�setterr>rAr�r�r�r�r�r�r�rr�r�r
r�rsrrrrr�sT��ZT
	
		


f
+


*�
2�
)hc@s4eZdZdZdeddfdd�Zd
d	d
�Zdd�ZdS)rzDClass to create ZIP archives with Python library files and packages.r_Tr�cCstj|||||d�||_dS)N)r!r�rt)rr��	_optimize)r�rr!r�rt�optimizerrrr��s�zPyZipFile.__init__r�NcCs�t�|�}|rD||�sD|jr@tj�|�r,dnd}td||f�dStj�|�\}}tj�|��rhtj�|d�}tj�|��r�|r�d||f}n|}|jr�td|d|�|�	|d	d
�|�\}}	|jr�td|	�|�
||	�tt�|��}
|
�
d�|
D]�}tj�||�}tj�|�\}
}tj�|��rRtj�tj�|d���r�|j|||d�q�|d
kr�|�r~||��s~|jr�td|�q�|�	|d	d
�|�\}}	|j�r�td|	�|�
||	�q�n�|j�r�td|�tt�|��D]�}tj�||�}tj�|�\}
}|d
k�r�|�r,||��s,|j�r�td|��q�|�	|d	d
�|�\}}	|j�rVtd|	�|�
||	��q�nP|d
d�d
k�r�td��|�	|d	d
�|�\}}	|j�r�td|	�|�
||	�dS)a�Add all files from "pathname" to the ZIP archive.

        If pathname is a package directory, search the directory and
        all package subdirectories recursively for all *.py and enter
        the modules into the archive.  If pathname is a plain
        directory, listdir *.py and enter all modules.  Else, pathname
        must be a Python *.py file and the module will be put into the
        archive.  Added modules are always module.pyc.
        This method will compile the module.py into module.pyc if
        necessary.
        If filterfunc(pathname) is given, it is called with every argument.
        When it is False, the file or directory is skipped.
        r�rz%s %r skipped by filterfuncNz__init__.py�%s/%szAdding package in�asr���ZAdding)�
filterfunc�.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding file)rzr�rir�r�r�r�r2�isfile�
_get_codenamerr��listdir�remove�splitext�writepyr�)r��pathname�basenamer�Zlabel�dirr"Zinitnamer�r�ZdirlistrBr��rootZextrrrr��s�


��


�
�
zPyZipFile.writepyc
sd�fdd�	}|d}|d}tjj|dd�}tjj|dd�}tjj|d	d�}�jdk�r\tj�|�r�t�|�jt�|�jkr�|}	}
n�tj�|�r�t�|�jt�|�jkr�|}
|}	n�tj�|�r�t�|�jt�|�jkr�|}
|}	nvtj�|��rt�|�jt�|�jk�r|}
|}	nD||��rRt	j
jd
k�r4|}
nt	j
jdk�rH|}
n|}
|}	n|}
}	n��jd
k�rr|}
|}	n<|}	�jdk�r�|}
n&�jd	k�r�|}
nd��j�}t
|��tj�|
��r�t�|
�jt�|�jk�s�||�jd��s�|}
}	tj�|	�d}|�rd
||f}|
|fS)aReturn (filename, archivename) for the path.

        Given a module name path, return the correct file path and
        archive name, compiling if necessary.  For example, given
        /python/lib/string, return (/python/lib/string.pyc, string).
        r�c
sfddl}�jrtd|�z|j|d|d�Wn4|jk
r`}zt|j�WY�dSd}~XYnXdS)NrZ	CompilingT)�doraiser�F)�
py_compilerir��compile�PyCompileError�msg)rr�r��errr�rr�_compiles

z)PyZipFile._get_codename.<locals>._compiler�z.pycr�)�optimizationrrrz"invalid value for 'optimize': {!r})r�r�)r�)�	importlib�util�cache_from_sourcer�rzr�r�r�r�r~r�r��formatr}r�)
r�r�r�r�Zfile_pyZfile_pycZpycache_opt0Zpycache_opt1Zpycache_opt2r�r�r�Zarchivenamerr�rr�sj�
���

�zPyZipFile._get_codename)r�N)rrrrrr�r�r�rrrrr�s�

RcCst�t|�dd�S)a2
    Given a path with elements separated by
    posixpath.sep, generate all parents of that path.

    >>> list(_parents('b/d'))
    ['b']
    >>> list(_parents('/b/d/'))
    ['/b']
    >>> list(_parents('b/d/f/'))
    ['b/d', 'b']
    >>> list(_parents('b'))
    []
    >>> list(_parents(''))
    []
    rN)�	itertools�islice�	_ancestry)r�rrr�_parents^srccs2|�tj�}|�tj�r.|Vt�|�\}}qdS)a�
    Given a path with elements separated by
    posixpath.sep, generate all elements of that path.

    >>> list(_ancestry('b/d'))
    ['b/d', 'b']
    >>> list(_ancestry('/b/d/'))
    ['/b/d', '/b']
    >>> list(_ancestry('b/d/f/'))
    ['b/d/f', 'b/d', 'b']
    >>> list(_ancestry('b'))
    ['b']
    >>> list(_ancestry(''))
    []

    Multiple separators are treated like a single.

    >>> list(_ancestry('//b//d///f//'))
    ['//b//d///f', '//b//d', '//b']
    N)r��	posixpathr{r�)r��tailrrrrqsrcCst�t|�j|�S)zZ
    Return items in minuend not in subtrahend, retaining order
    with O(1) lookup.
    )r�filterfalse�set�__contains__)ZminuendZ
subtrahendrrr�_difference�sr
csHeZdZdZedd��Z�fdd�Zdd�Zdd	�Ze	d
d��Z
�ZS)�CompleteDirszk
    A ZipFile subclass that ensures that implied directories
    are always included in the namelist.
    cCs.tj�tt|��}dd�|D�}tt||��S)Ncss|]}|tjVqdSr�)rr{)r�r�rrrr��sz-CompleteDirs._implied_dirs.<locals>.<genexpr>)r�chain�
from_iterabler�r�_deduper
)�names�parentsZas_dirsrrr�
_implied_dirs�szCompleteDirs._implied_dirscs tt|���}|t|�|��Sr�)rIrr�r^r)r�rrJrrr��szCompleteDirs.namelistcCst|���Sr�)rr�r�rrr�	_name_set�szCompleteDirs._name_setcCs,|��}|d}||ko||k}|r(|S|S)zx
        If the name represents a directory, return that name
        as a directory (with the trailing slash).
        rw)r)r�r"rr�Z	dir_matchrrr�resolve_dir�szCompleteDirs.resolve_dircCsNt|t�r|St|t�s ||�Sd|jkr.t}|�|�}t|��t|��|S)zl
        Given a source (filename or zipfile), return an
        appropriate CompleteDirs subclass.
        r_)r�rrr!�__new__�vars�update)r�r��resrrr�make�s



zCompleteDirs.make)rrrr�staticmethodrr�rrr�rrNrrrJrr�s

rcs,eZdZdZ�fdd�Z�fdd�Z�ZS)�
FastLookupzV
    ZipFile subclass to ensure implicit
    dirs exist and are resolved rapidly.
    c
s:t�t��|jW5QR�SQRXtt|���|_|jSr�)�
contextlib�suppressr*Z_FastLookup__namesrIrr�r�rJrrr��szFastLookup.namelistc
s:t�t��|jW5QR�SQRXtt|���|_|jSr�)rrr*Z_FastLookup__lookuprIrrr�rJrrr�szFastLookup._name_set)rrrrr�rrNrrrJrr�src@s�eZdZdZdZd#dd�Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZeZed d!��Zd"S)$ru�
    A pathlib-compatible interface for zip files.

    Consider a zip file with this structure::

        .
        ├── a.txt
        └── b
            ├── c.txt
            └── d
                └── e.txt

    >>> data = io.BytesIO()
    >>> zf = ZipFile(data, 'w')
    >>> zf.writestr('a.txt', 'content of a')
    >>> zf.writestr('b/c.txt', 'content of c')
    >>> zf.writestr('b/d/e.txt', 'content of e')
    >>> zf.filename = 'abcde.zip'

    Path accepts the zipfile object itself or a filename

    >>> root = Path(zf)

    From there, several path operations are available.

    Directory iteration (including the zip file itself):

    >>> a, b = root.iterdir()
    >>> a
    Path('abcde.zip', 'a.txt')
    >>> b
    Path('abcde.zip', 'b/')

    name property:

    >>> b.name
    'b'

    join with divide operator:

    >>> c = b / 'c.txt'
    >>> c
    Path('abcde.zip', 'b/c.txt')
    >>> c.name
    'c.txt'

    Read text:

    >>> c.read_text()
    'content of c'

    existence:

    >>> c.exists()
    True
    >>> (b / 'missing.txt').exists()
    False

    Coercion to string:

    >>> str(c)
    'abcde.zip/b/c.txt'
    z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})r�cCst�|�|_||_dSr�)rrr��at)r�r�r rrrr�	sz
Path.__init__cCst�|jj|j�Sr�)�	functools�partialr�rAr r�rrrrA#	sz	Path.opencCst�|j�d��S�Nrw)rr�r r�r�rrrr"'	sz	Path.namec
Os6|���$}tj|f|�|���W5QR�SQRXdSr�)rAr4�
TextIOWrapperr>)r��args�kwargs�strmrrr�	read_text+	s
zPath.read_textc
Cs(|���}|��W5QR�SQRXdSr�r�)r�r'rrr�
read_bytes/	s
zPath.read_bytescCst�|j�d��|j�d�kSr#)rr�r r�)r�r�rrr�	_is_child3	szPath._is_childcCst|j|�Sr�)rr�)r�r rrr�_next6	sz
Path._nextcCs|jp|j�d�Sr#)r �endswithr�rrrr�9	szPath.is_dircCs
|��Sr�)r�r�rrr�is_file<	szPath.is_filecCs|j|j��kSr�)r r�rr�rrrr�?	szPath.existscCs.|��std��t|j|j���}t|j|�S)NzCan't listdir a file)r�r}r�r+r�r��filterr*)r�Zsubsrrr�iterdirB	szPath.iterdircCst�|jj|j�Sr�)rr2r�rBr r�rrr�__str__H	szPath.__str__cCs|jj|d�S)Nr�)�_Path__reprrr�rrrr�K	sz
Path.__repr__cCs t�|j|�}|�|j�|��Sr�)rr2r r+r�r)r��add�nextrrr�joinpathN	sz
Path.joinpathcCs(t�|j�d��}|r|d7}|�|�Sr#)rr�r r�r+)r�Z	parent_atrrr�parentT	szPath.parentN)r�)rrrrr1r�r^rAr"r(r)r*r+r�r-r�r/r0r�r4�__truediv__r5rrrrr�s*@


c
	s�ddl}d}|j|d�}|jdd�}|jdddd	d
�|jddd
ddd�|jdddddd�|jddddd
�|�|�}|jdk	r�|j}t|d��}|��}W5QRX|r�td�	|��td�n�|j
dk	r�|j
}t|d��}|��W5QRXn�|jdk	�r,|j\}}t|d��}|�
|�W5QRXn�|jdk	�r�|j�d�}	|j}
�fdd��t|	d��\}|
D]P}tj�|�}|�s�tj�tj�|��}|dtjtjfk�r�d}�|||��qfW5QRXdS) Nrz3A simple command-line interface for zipfile module.)�descriptionT)Zrequiredz-lz--list�	<zipfile>zShow listing of a zipfile)�metavar�helpz-ez	--extractr)r8z<output_dir>zExtract zipfile into target dir)�nargsr9r:z-cz--create�+)z<name>z<file>zCreate zipfile from sourcesz-tz--testzTest if a zipfile is validr_z.The following enclosed file is corrupted: {!r}zDone testingcsptj�|�r|�||t�nPtj�|�rl|r8|�||�tt�|��D]$}�|tj�||�tj�||��qFdSr�)	rzr�r�rrr�r�r�r2)rWr��zippathZnm��addToZiprrr?�	s�zmain.<locals>.addToZipr`r�)�argparse�ArgumentParserZadd_mutually_exclusive_group�add_argument�
parse_argsZtestrr�r�rr^r�r�r�Zcreate�poprzr�r�r�r�r�)
r%r@r7�parser�groupr�rWZbadfiler�Zzip_name�filesr�r=rr>r�main\	s\
�
�
�
�




rH�__main__)N)N)�rZbinasciir!�importlib.utilrr4rrzrr�r�rFr~rpr�rr�r��ImportErrorr�r��__all__�	Exceptionrr
rrr�r�r�rrrrr�r�r�r�r�r]r\r�r[rLrMrNrOrPrQrRrar�r�r�r�r�r�Z_CD_CREATE_VERSIONZ_CD_CREATE_SYSTEMZ_CD_EXTRACT_VERSIONZ_CD_EXTRACT_SYSTEMZ
_CD_FLAG_BITSZ_CD_COMPRESS_TYPEZ_CD_TIMEZ_CD_DATEZ_CD_CRCZ_CD_COMPRESSED_SIZEZ_CD_UNCOMPRESSED_SIZEr�r�r�Z_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESr�r�r�r�r�Z_FH_EXTRACT_VERSIONZ_FH_EXTRACT_SYSTEMr�Z_FH_COMPRESSION_METHODZ_FH_LAST_MOD_TIMEZ_FH_LAST_MOD_DATEZ_FH_CRCZ_FH_COMPRESSED_SIZEZ_FH_UNCOMPRESSED_SIZEr�r�rGrHrErJrKrIZ_CD64_SIGNATUREZ_CD64_DIRECTORY_RECSIZEZ_CD64_CREATE_VERSIONZ_CD64_EXTRACT_VERSIONZ_CD64_DISK_NUMBERZ_CD64_DISK_NUMBER_STARTZ_CD64_NUMBER_ENTRIES_THIS_DISKZ_CD64_NUMBER_ENTRIES_TOTALZ_CD64_DIRECTORY_SIZEZ_CD64_OFFSET_START_CENTDIRrZZStructr.r8r=r	rXr9�objectr
r�r�r�r�r�r�r�r�rrrr5rrOrrrr�dict�fromkeysrr
rrrrHrrrrr�<module>sl


�






+=s&�
&AN/2
=


Hacked By AnonymousFox1.0, Coded By AnonymousFox