Your IP : 18.117.168.40


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/zipfile.cpython-35.opt-2.pyc



���]��B@sRddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
yddlZWnek
r�ddl
ZYnXyddlZejZWn!ek
r�dZe
jZYnXyddlZWnek
rdZYnXyddlZWnek
r;dZYnXdddddddd	d
ddd
gZGdd�de�ZGdd
�d
e�ZeZZdd>dZdd>dZdd>dZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%e	j&e$�Z'dZ(dZ)dZ*dZ+dZ,dZ-d Z.d!Z/dZ0d"Z1d#Z2d$Z3e	j&e2�Z4dZ5dZ6dZ7dZ8dZ9dZ:d Z;d!Z<dZ=d"Z>d%Z?d&Z@dZAd'ZBdZCd(ZDdZEd)ZFd*ZGd+ZHd,ZIe	j&eH�ZJdZKdZLdZMdZNdZOdZPd ZQd!ZRdZSd"ZTd%ZUd&ZVd-ZWd.ZXe	j&eW�ZYd/ZZd0Z[e	j&eZ�Z\dZ]dZ^dZ_dZ`dZadZbd Zcd!ZddZed"Zfd1d2�Zgd3d	�Zhd4d5�Zid6d7�ZjGd8d
�d
ek�ZlGd9d:�d:�ZmGd;d<�d<�ZnGd=d>�d>�Zodd?dd@ddAddAddAddAd dBd!dCddDd"dEd%dBddFddGd*dHdIdJdKdLdMdNiZpdOdP�ZqdQdR�ZrdSdT�ZsGdUdV�dV�ZtGdWdX�dX�ZuGdYdZ�dZejv�ZwGd[d�d�ZxGd\d�dex�Zydd]d^�Zze{d_krNez�dS)`�N�
BadZipFile�
BadZipfile�error�
ZIP_STORED�ZIP_DEFLATED�	ZIP_BZIP2�ZIP_LZMA�
is_zipfile�ZipInfo�ZipFile�	PyZipFile�LargeZipFilec@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�,/opt/alt/python35/lib64/python3.5/zipfile.pyr+sc@seZdZdS)r
N)rrrrrrrr
/s��������-�.�?s<4s4H2LHsPK�������	z<4s4B4HL2L5H2LsPK�
��
���z<4s2B4HL2L2HsPKz<4sLQLsPKz
<4sQ2H2L4QsPKcCs-yt|�rdSWntk
r(YnXdS)NTF)�_EndRecData�OSError)�fprrr�_check_zipfile�s
r-cCsid}yJt|d�r*td|�}n%t|d��}t|�}WdQRXWntk
rdYnX|S)NF�readr,�rb)�hasattrr-�openr+)�filename�resultr,rrrr	�s
cCsoy|j|td�Wntk
r0|SYnX|jt�}t|�tkrV|Stjt|�\}}}}|tkr�|S|dks�|dkr�t	d��|j|tt
d�|jt
�}t|�t
kr�|Stjt|�\
}}}	}
}}}
}}}|tkr%|S||t
<||t<||t<|
|t<||t<||t<||t<|S)Nrrrz3zipfiles that span multiple disks are not supported)�seek�sizeEndCentDir64Locatorr+r.�len�struct�unpack�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�data�sigZdisknoZreloffZdisksZsz�create_versionZread_versionZdisk_numZdisk_dirZdircountZ	dircount2ZdirsizeZ	diroffsetrrr�
_EndRecData64�s6
	0






rKc	Cs�|jdd�|j�}y|jtd�Wntk
rIdSYnX|j�}t|�tkr�|dd�tkr�|dd�dkr�tjt	|�}t
|�}|jd�|j|t�t|t|�St
|d	td�}|j|d�|j�}|jt�}|dkr�|||t�}t|�tkrYdSt
tjt	|��}|t}||t|t|�}|j|�|j||�t|||||�SdS)
Nrrrs�rr���i)r4�tell�sizeEndCentDirr+r.r6�stringEndArchiver7r8�structEndArchive�list�appendrK�max�rfind�_ECD_COMMENT_SIZE)	rEZfilesizerHrGZmaxCommentStart�startZrecDataZcommentSize�commentrrrr*�s>
	


r*c@s[eZdZd#Zdd$dd�Zdd�Zddd�Zdd �Zd!d"�ZdS)%r
�
orig_filenamer2�	date_time�
compress_typerX�extra�
create_systemrJ�extract_version�reserved�	flag_bits�volume�
internal_attr�
external_attr�
header_offset�CRC�
compress_size�	file_size�	_raw_timeZNoName�rrcCs||_|jtd��}|dkr:|d|�}tjdkrmtj|krm|jtjd�}||_||_|ddkr�td��t	|_
d|_d|_t
jdkr�d|_n	d|_t|_t|_d|_d|_d|_d|_d|_dS)Nr�/i�z+ZIP does not support timestamps before 1980rL�win32r)rY�find�chr�os�sep�replacer2rZ�
ValueErrorrr[rXr\�sys�platformr]�DEFAULT_VERSIONrJr^r_r`rarbrc)�selfr2rZZ	null_byterrr�__init__@s.													zZipInfo.__init__cCs;d|jj|jfg}|jtkrN|jdtj|j|j��|jd?}|jd@}|r�|jdt	j
|��|r�|jd|�|jd
d�dk}|s�|jr�|jd	|j�|s�|jr!|jtks
|j|jkr!|jd
|j�|jd�dj
|�S)Nz<%s filename=%rz compress_type=%sri��z filemode=%rz external_attr=%#xrrjz
 file_size=%rz compress_size=%r�>����)�	__class__rr2r[rrS�compressor_names�getrc�stat�filemodergrf�join)rur3�hi�lo�isdirrrr�__repr__js(	


zZipInfo.__repr__NcCs|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}|jd
@rsd}}}n|j}|j}|j}|j}d}	|dkr�|tkp�|tk}|r�d}
|tj|
dtj	|
�d	||�}|tks|tkr5|s#t
d��d
}d
}t}	|jt
krVtt|	�}	n|jtkrttt|	�}	t|	|j�|_t|	|j�|_|j�\}}tjtt|j|j||j|||||t|�t|��
}
|
||S)Nri�r#rr rrr%rrz<HHQQz'Filesize would require ZIP64 extensionsl��)rZr`rerfrgr\�ZIP64_LIMITr7�pack�calcsizer
�
ZIP64_VERSIONr[rrT�
BZIP2_VERSIONr�LZMA_VERSIONr^rJ�_encodeFilenameFlags�structFileHeader�stringFileHeaderr_r6)ru�zip64�dt�dosdate�dostimererfrgr\�min_version�fmtr2r`�headerrrr�
FileHeader�sF	&&
				 zZipInfo.FileHeadercCsSy|jjd�|jfSWn/tk
rN|jjd�|jdBfSYnXdS)N�asciizutf-8i)r2�encoder`�UnicodeEncodeError)rurrrr��s
zZipInfo._encodeFilenameFlagscCs�|j}tj}xvt|�dkr�|d|dd��\}}|dkrs|dkrz|d|dd��}nx|dkr�|d|dd	��}nP|d
kr�|d|dd��}n(|d
kr�f}ntd|f��d
}|jdkr|||_|d7}|jdkrD|||_|d7}|jdkrs|j}|||_|d7}||dd�}qWdS)Nrz<HHr�z<QQQ�rz<QQrrz<QrrzCorrupt extra field %s��������)r�r�)r\r7r8r6�RuntimeErrorrgrfrd)rur\r8�tp�lnZcounts�idx�oldrrr�_decodeExtra�s4			



	

zZipInfo._decodeExtra)rYr2rZr[rXr\r]rJr^r_r`rarbrcrdrerfrgrh)rirrrrr)	rrr�	__slots__rvr�r�r�r�rrrrr
's0*.c@sReZdZdd�ZdZdd�Zdd�Zdd	�Zd
d�ZdS)�
_ZipDecryptercCs�d}dgd}xhtd�D]Z}|}xAtd�D]3}|d@r^|d?d@|A}q9|d?d@}q9W|||<q W|S)Nl q[r�rri���)�range)Zpoly�table�i�crc�jrrr�_GenerateCRCTable�s

z_ZipDecrypter._GenerateCRCTableNcCs|d?d@|j||Ad@AS)Nri����)�crctable)ruZchr�rrr�_crc32�sz_ZipDecrypter._crc32cCs[tjdkrtj�t_d|_d|_d|_x|D]}|j|�q@WdS)NixV4i�gE#i�xV4)r�r�r��key0�key1�key2�_UpdateKeys)ru�pwd�prrrrv�s			
z_ZipDecrypter.__init__cCsr|j||j�|_|j|jd@d@|_|jddd@|_|j|jd?d@|j�|_dS)Nr�l��i�rr�)r�r�r�r�)ru�crrrr�sz_ZipDecrypter._UpdateKeyscCs8|jdB}|||dAd?d@A}|j|�|S)Nrrrr�)r�r�)rur��krrr�__call__
s

z_ZipDecrypter.__call__)	rrrr�r�r�rvr�r�rrrrr��s
	r�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�LZMACompressorcCs
d|_dS)N)�_comp)rurrrrvszLZMACompressor.__init__cCsetjdtji�}tjtjdtjtj|�g�|_tjdddt	|��|S)N�id�filtersz<BBHr#r)
�lzma�_encode_filter_properties�FILTER_LZMA1r��
FORMAT_RAW�_decode_filter_propertiesr�r7r�r6)ruZpropsrrr�_initszLZMACompressor._initcCs9|jdkr)|j�|jj|�S|jj|�S)N)r�r��compress)rurHrrrr�"szLZMACompressor.compresscCs3|jdkr&|j�|jj�S|jj�S)N)r�r��flush)rurrrr�'szLZMACompressor.flushN)rrrrvr�r�r�rrrrr�sr�c@s(eZdZdd�Zdd�ZdS)�LZMADecompressorcCsd|_d|_d|_dS)NrLF)�_decomp�_unconsumed�eof)rurrrrv/s		zLZMADecompressor.__init__c	Cs�|jdkr�|j|7_t|j�dkr7dStjd|jdd��\}t|j�d|krvdStjtjdtjtj	|jdd|��g�|_|jd|d�}|`|jj
|�}|jj|_|S)NrrLz<Hrr�)r�r�r6r7r8r�r�r�r�r��
decompressr�)rurHZpsizer3rrrr�4s"#zLZMADecompressor.decompressN)rrrrvr�rrrrr�-sr��storeZshrink�reduceZimplode�tokenizeZdeflateZ	deflate64�bzip2r�Zterse�Zlz77�aZwavpack�bZppmdcCs�|tkrno|tkr0ts~td��nN|tkrQts~td��n-|tkrrts~td��ntd��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�zlibr�r�bz2rr�)�compressionrrr�_check_compression]sr�cCsV|tkr%tjtjtjd�S|tkr;tj�S|tkrNt	�SdSdS)Nr'i�)
rr��compressobj�Z_DEFAULT_COMPRESSION�DEFLATEDrr��
BZ2Compressorrr�)r[rrr�_get_compressorps

r�cCs�|tkrdS|tkr)tjd�S|tkr?tj�S|tkrRt�St	j
|�}|r�td||f��ntd|f��dS)Nr'zcompression type %d (%s)zcompression type %di�)rrr��
decompressobjrr��BZ2Decompressorrr�r{r|�NotImplementedError)r[Zdescrrrr�_get_decompressor|s

r�c@s7eZdZdd�Zd	dd�Zdd�ZdS)
�_SharedFilecCs(||_||_||_||_dS)N)�_file�_pos�_close�_lock)ru�file�pos�close�lockrrrrv�s			z_SharedFile.__init__rc	CsP|j�@|jj|j�|jj|�}|jj�|_|SWdQRXdS)N)r�r�r4r�r.rN)ru�nrHrrrr.�s

z_SharedFile.readcCs2|jdk	r.|j}d|_|j|�dS)N)r�r�)ru�fileobjrrrr��s		z_SharedFile.closeNry)rrrrvr.r�rrrrr��sr�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�	_TellablecCs||_d|_dS)Nr)r,rF)rur,rrrrv�s	z_Tellable.__init__cCs%|jj|�}|j|7_|S)N)r,�writerF)rurHr�rrrr��sz_Tellable.writecCs|jS)N)rF)rurrrrN�sz_Tellable.tellcCs|jj�dS)N)r,r�)rurrrr��sz_Tellable.flushcCs|jj�dS)N)r,r�)rurrrr��sz_Tellable.closeN)rrrrvr�rNr�r�rrrrr��s
r�cs�eZdZdZdZejd�Zdddd�Zd	d
�Z	ddd�Z
dd
d�Zdd�Zd dd�Z
dd�Zdd�Zdd�Zdd�Z�fdd�Z�S)!�
ZipExtFilerris*^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)NFcCs�||_||_||_|j|_|j|_|j|_t	|j�|_
d|_d|_d|_
d|k|_d|_|jdk	r�|jd8_||_|j|_t|d�r�|j|_td�|_n	d|_dS)NFrLr�Urre)�_fileobj�
_decrypter�_close_fileobjr[�_compress_typerf�_compress_leftrg�_leftr��
_decompressor�_eof�_readbuffer�_offset�
_universal�newlines�moder2�namer0re�
_expected_crc�crc32�_running_crc)rur�r��zipinfoZ	decrypterZ
close_fileobjrrrrv�s(								zZipExtFile.__init__cCs�d|jj|jjfg}|jsz|jd|j|jf�|jtkr�|jdt	j
|j|j��n
|jd�|jd�dj|�S)Nz<%s.%sz name=%r mode=%rz compress_type=%sz	 [closed]rwrx)rzrr�closedrSr�r�r�rr{r|r)rur3rrrr��s		

zZipExtFile.__repr__cCs�|jra|dkra|jjd|j�d}|dkra|j|j|�}||_|S|js}tjj||�Sd}x|dks�t|�|kr�|jd�}|dkr�|S|j	j
|�}|jd�}|dk	rD|jdkrg|_||jkr'|jj
|�|jt|�7_|dS|jd�}|dkry|d|t|��}|jt|�7_||7}q�W|S)Nrs
rrLr�newline�chunk)r�r�rlr��io�BufferedIOBase�readliner6�peek�PATTERN�search�groupr�rS)ru�limitr��lineZ	readahead�matchr�r�rrrr�s8		!
	zZipExtFile.readlinecCs�|t|j�|jkr~|j|�}t|�|jkri||j|jd�|_d|_n|jt|�8_|j|j|jd�S)Nri)r6r�r�r.)rur�r�rrrr%szZipExtFile.peekcCsdS)NTr)rurrr�readable2szZipExtFile.readablecCsm|dks|dkrj|j|jd�}d|_d|_x#|jse||j|j�7}qCW|S||j}|t|j�kr�|j|j|�}||_|S|t|j�}|j|jd�}d|_d|_x||dkrh|jrh|j|�}|t|�krK||_||_||d|�7}P||7}|t|�8}q�W|S)NrrL)r�r�r��_read1�MAX_Nr6)rur��buf�endrHrrrr.5s4		
					
zZipExtFile.readcCsZ|jdkrdSt||j�|_|jrV|j|jkrVtd|j��dS)NzBad CRC-32 for file %r)r�r�r�r�rr�)ru�newdatarrr�_update_crcVs
zZipExtFile._update_crccCsp|dks|dkrw|j|jd�}d|_d|_x0|jsr|j|j�}|rC||7}PqCW|S||j}|t|j�kr�|j|j|�}||_|S|t|j�}|j|jd�}d|_d|_|dkrlxf|jsk|j|�}|t|�krW||_||_||d|�7}P|r||7}PqW|S)NrrL)r�r�r�rrr6)rur�r
rHrrrr�read1`s>		

					
zZipExtFile.read1cCs�|js|dkrdS|jtkrf|jj}|t|�kru||j|t|��7}n|j|�}|jtkr�|jdk|_n�|jtkrt	||j
�}|jj||�}|jjp�|jdko�|jj|_|jrI||jj
�7}n0|jj|�}|jjpC|jdk|_|d|j�}|jt|�8_|jdkr�d|_|j|�|S)NrrLT)r�r�rr��unconsumed_tailr6�_read2rr�rT�
MIN_READ_SIZEr�r�r�r�r)rur�rHrrrr�s2 		
zZipExtFile._read1cCs�|jdkrdSt||j�}t||j�}|jj|�}|jt|�8_|sjt�|jdk	r�t	t
|j|��}|S)NrrL)r�rTr�minr�r.r6�EOFErrorr��bytes�map)rur�rHrrrr�szZipExtFile._read2c
s/z|jr|jj�Wdt�j�XdS)N)r�r�r��super)ru)rzrrr��s	zZipExtFile.close�i@ryry)rrrrr�re�compilerrvr�rrr
r.rrrrr�rr)rzrr��s 2
!
%$r�c@s�eZdZdZdZdeddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zddd�Z
dd�Zdd�Zdd�Zedd��Zejdd��Zddd�Zdddd �Zddd!d"�Zdddd#d$�Zed%d&��Zd'd(�Zd)d*�Zddd+d,�Zdd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!dS)7rN�rTcCs�|dkrtd��t|�||_d|_d|_i|_g|_||_||_d|_	d|_
t|t�r#d|_
||_dd	dd
dddddd
d
d
ddi}||}xyytj||�|_Wn.tk
r||kr||}w��YnXPq�Wn'd|_
||_t|dd�|_d|_tj�|_d|_yD|dkr�|j�n'|dkr/d|_y|jj�|_Wn<ttfk
r�t|j�|_d|_d|_Yq�Xy|jj|j�Wq�ttfk
r+d|_Yq�Xn|dkr�y!|j�|jj|j�Wq�tk
r�|jjdd�d|_|jj�|_Yq�Xntd��Wn*|j}d|_|j |��YnXdS)Nr�w�x�az+ZipFile requires mode 'r', 'w', 'x', or 'a'FrrLr/zw+bzx+bzr+b�wb�xbrr�Trz"Mode must be 'r', 'w', 'x', or 'a')rrrr )rr)!r�r��_allowZip64�
_didModify�debug�
NameToInfo�filelistr�r�r��_comment�
isinstance�str�_filePassedr2rr1r,r+�getattr�_fileRefCnt�	threading�RLockr��	_seekable�_RealGetContentsrN�	start_dir�AttributeErrorr�r4r�_fpclose)rur�r�r��
allowZip64ZmodeDictr~r,rrrrv�s|
											


				
		

			
zZipFile.__init__cCs|S)Nr)rurrr�	__enter__)szZipFile.__enter__cCs|j�dS)N)r�)ru�type�value�	tracebackrrr�__exit__,szZipFile.__exit__cCs�d|jj|jjfg}|jdk	r�|jrN|jd|j�n#|jdk	rq|jd|j�|jd|j�n
|jd�|jd�dj|�S)Nz<%s.%sz file=%rz filename=%rz mode=%rz	 [closed]rwrx)	rzrrr,r+rSr2r�r)rur3rrrr�/s	

zZipFile.__repr__cCs�|j}yt|�}Wntk
r9td��YnX|sLtd��|jdkret|�|t}|t}|t|_	|t
||}|ttkr�|t
t8}|jdkr�||}td|||�|||_|j|jd�|j|�}tj|�}d}xi||kr�|jt�}	t|	�tkrbtd��tjt|	�}	|	ttkr�td��|jdkr�t|	�|j|	t�}
|	d}|d	@r�|
jd
�}
n|
jd�}
t|
�}|j|	t�|_|j|	t �|_!|	t"|_#|	dd�\|_$|_%|_&|_'|_(|_)}
}|_*|_+|_,|j&t-kr�t.d
|j&d��|	dd�\|_/|_0|_1|
|_2|d?d|d?d@|d@|
d?|
d?d@|
d@df|_3|j4�|j#||_#|j5j6|�||j7|j8<|t|	t|	t|	t }|jdkr)td|�q)WdS)NzFile is not a zip filerrzgiven, inferred, offsetrzTruncated central directoryz&Bad magic number for central directoryr izutf-8�cp437rzzip file version %.1fr$r'r)r#i�rr%r�total)9r,r*r+rr%�printrCrD�_ECD_COMMENTr(�
_ECD_LOCATIONr>r=r;r5r2r4r.r�BytesIO�sizeCentralDirr6r7r8�structCentralDir�
_CD_SIGNATURE�stringCentralDir�_CD_FILENAME_LENGTH�decoder
�_CD_EXTRA_FIELD_LENGTHr\�_CD_COMMENT_LENGTHrX�_CD_LOCAL_HEADER_OFFSETrdrJr]r^r_r`r[rerfrg�MAX_EXTRACT_VERSIONr�rarbrcrhrZr�r'rSr&r2)rur,rGZsize_cdZ	offset_cd�concatZinferredrHr<�centdirr2�flagsr�t�drrrr1=sp	










L"	&
"zZipFile._RealGetContentscCsdd�|jD�S)NcSsg|]}|j�qSr)r2)�.0rHrrr�
<listcomp>�s	z$ZipFile.namelist.<locals>.<listcomp>)r')rurrr�namelist�szZipFile.namelistcCs|jS)N)r')rurrr�infolist�szZipFile.infolistcCsftdd	d|�xK|jD]@}d|jdd�}td|j||jfd|�qWdS)
Nz%-46s %19s %12s�	File Name�Modified    �Sizer�z%d-%02d-%02d %02d:%02d:%02dr!z
%-46s %s %12d)rTrUrV)r=r'rZr2rg)rur��zinfoZdaterrr�printdir�s
zZipFile.printdircCssd}xf|jD][}y9|j|jd��}x|j|�rFq4WWdQRXWqtk
rj|jSYqXqWdS)Nrrri)r'r1r2r.r)ruZ
chunk_sizerW�frrr�testzip�s
zZipFile.testzipcCs2|jj|�}|dkr.td|��|S)Nz(There is no item named %r in the archive)r&r|�KeyError)rur��inforrr�getinfo�s

zZipFile.getinfocCsK|r,t|t�r,tdt|���|r>||_n	d|_dS)Nzpwd: expected bytes, got %s)r)r�	TypeErrorr7r�)rur�rrr�setpassword�s
zZipFile.setpasswordcCs|jS)N)r()rurrrrX�szZipFile.commentcCs�t|t�s%tdt|���t|�tkrjddl}|jdtdd�|dt�}||_d|_	dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytes�
stacklevelrT)
r)rr^r7r6�ZIP_MAX_COMMENT�warnings�warnr(r$)rurXrbrrrrX�s		c	Cs-|j|d|��}|j�SWdQRXdS)Nr)r1r.)rur�r�r,rrrr.�szZipFile.readcCs�|dkrtd��d|krCddl}|jdtd�|rot|t�rotdt|���|js�td	��t|t	�r�|}n|j
|�}|jd
7_t|j|j
|j|j�}y�|jt�}t|�tkrtd��tjt|�}|ttkr9td��|j|t�}|trg|j|t�|jd
@r�td��|jd@r�td��|jd@r�|jd�}	n|jd�}	|	|jkr�td|j|f��|jd
@}
d}|
r�|s|j}|s-td|��t |�}|jd�}t!t"||dd���}
|jd@r�|j#d?d@}n|j$d?d@}|
d|kr�td|��t%||||d�SWn|j&��YnXdS)Nrr��rUz&open() requires mode "r", "U", or "rU"rz'U' mode is deprecatedrzpwd: expected bytes, got %sz3Attempt to read ZIP archive that was already closedrzTruncated file headerz Bad magic number for file header� z$compressed patched data (flag bit 5)�@zstrong encryption (flag bit 6)izutf-8r;z/File name in directory %r and header %r differ.z6File %s is encrypted, password required for extractionrrr�r�r%zBad password for fileT)rr�rd)'r�rbrc�DeprecationWarningr)rr^r7r,r
r]r-r�rdr4r�r.�sizeFileHeaderr6rr7r8r��
_FH_SIGNATUREr��_FH_FILENAME_LENGTH�_FH_EXTRA_FIELD_LENGTHr`r�rFrYr�r�rRrrhrer�r�)rur�r�r�rbrWZzef_fileZfheader�fnameZ	fname_strZis_encryptedZzdr��hZ
check_byterrrr1�sr	
			!




	


zZipFile.opencCsIt|t�s|j|�}|dkr6tj�}|j|||�S)N)r)r
r]rn�getcwd�_extract_member)ru�member�pathr�rrr�extract+s
zZipFile.extractcCs@|dkr|j�}x!|D]}|j|||�qWdS)N)rRrr)rurq�membersr�r�rrr�
extractall9s
zZipFile.extractallcCs�|j}|s:d}tj|dt|��}||_|j|�}dd�|j|�D�}|jdd�|D��}|S)Nz:<>|"?*�_css|]}|jd�VqdS)�.N)�rstrip)rPrrrr�	<genexpr>Osz1ZipFile._sanitize_windows_name.<locals>.<genexpr>css|]}|r|VqdS)Nr)rPrrrrrxQs)�!_windows_illegal_name_trans_tabler*�	maketransr6�	translate�splitr)�cls�arcname�pathsepr�Zillegalrrr�_sanitize_windows_nameEs		zZipFile._sanitize_windows_namecs�|jjdtjj�}tjjrE|jtjjtjj�}tjj|�d}dtjjtjjf�tjjj	�fdd�|j
tjj�D��}tjjdkr�|j|tjj�}tjj	||�}tjj|�}tjj
|�}|r6tjj|�r6tj|�|jd	dkrltjj|�shtj|�|S|j|d|��0}t|d��}tj||�WdQRXWdQRX|S)
Nrjrrxc3s!|]}|�kr|VqdS)Nr)rPr)�invalid_path_partsrrrxbsz*ZipFile._extract_member.<locals>.<genexpr>�\r�r!ry)r2rprnrqro�altsep�
splitdrive�curdir�pardirrr|r��normpath�dirname�exists�makedirsr��mkdirr1�shutil�copyfileobj)rurpZ
targetpathr�r~Z	upperdirs�source�targetr)r�rroTs*7

zZipFile._extract_membercCs�|j|jkr8ddl}|jd|jdd�|jdkrStd��|jshtd	��t|j�|j	s�d}t
|j�tkr�d
}n-|j
tkr�d}n|jtkr�d}|r�t|d
��dS)NrzDuplicate name: %rr`rrrr z&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedzFiles countZFilesizezZipfile sizez would require ZIP64 extensions)rrr )r2r&rbrcr�r�r,r�r[r#r6r'�ZIP_FILECOUNT_LIMITrgr�rdr
)rurWrb�requires_zip64rrr�_writecheck{s(		
			zZipFile._writecheckcCs�|jstd��tj|�}tj|j�}tj|j�}|dd�}|dkrj|}tj	j
tj	j|�d�}x0|dtjtj
fkr�|dd�}q�W|r�|d7}t||�}|dd@d>|_|rt|_n$|dkr |j|_n	||_|j|_d|_|j�U|jrd|jj|j�|jj�|_|jtkr�|jdO_|j|�d	|_|r)d|_d|_d|_ |jdO_|j!j"|�||j#|j$<|jj%|j&d
��|jj�|_dSt'|j�}	|jsP|jdO_t(|d���}
d|_ }d|_}|j)o�|jd
t*k}
|jj%|j&|
��d}xn|
j+d�}|s�P|t,|�}t-||�}|	r|	j.|�}|t,|�}|jj%|�q�WWdQRX|	rm|	j/�}|t,|�}|jj%|�||_n	||_||_ ||_|jd@r�|
r�dnd}|jj%t0j1||j |j|j��|jj�|_n�|
r'|j)r'|t*krtd��|t*kr'td��|jj�|_|jj|j�|jj%|j&|
��|jj|j�|j!j"|�||j#|j$<WdQRXdS)Nz7Attempt to write to ZIP archive that was already closedrr!rrji��rrTFrr/g�������?iz<LQQz<LLLz*File size has increased during compressingz-Compressed size larger than uncompressed sizei )2r,r�rnr}�S_ISDIR�st_mode�time�	localtime�st_mtimerqr�r�ror�r
rcrr[r��st_sizergr`r�r0r4r2rNrdrr�r$rfrer'rSr&r2r�r�r�r1r#r�r.r6r�r�r�r7r�)rur2r~r[�str��mtimerZrWZcmprr,rerfr�rgr
r�rrrr��s�		"
		
	
					

				

z
ZipFile.writec
Cs�t|t�r|jd�}t|t�s�td|dtjtj��dd��}|j|_|jddkr�d|_	|j	dO_	q�d|_	n|}|j
s�td
��t|�|_
|j��|jr�|j
j|j�|j
j�|_|dk	r||_|j
j�|_|dk	r?||_|jtkr]|jdO_|j|�d|_t|�|_t|j�}|r�|j|�|j�}t|�|_n|j
|_|j
tkp�|jtk}|r|jrt d
��|j
j!|j"|��|j
j!|�|jd@r{|rJdnd}|j
j!t#j$||j|j|j
��|j
j�|j
j�|_|j%j&|�||j'|j<WdQRXdS)Nzutf-8r2rZr!rrji�Ari�z7Attempt to write to ZIP archive that was already closedrTz'Filesize would require ZIP64 extensionsrz<LQQz<LLLryi�Ai�)(r)r*r�r
r�r�r�r[r2rcr,r�r6rgr�r0r4r2rNrdrr`r�r$r�rer�r�r�rfr�r#r
r�r�r7r�r'rSr&)ruZzinfo_or_arcnamerHr[rW�cor�r�rrr�writestr�s`"			
			
	


zZipFile.writestrcCs|j�dS)N)r�)rurrr�__del__9szZipFile.__del__cCs�|jdkrdSzS|jdkre|jre|j�+|jrT|jj|j�|j�WdQRXWd|j}d|_|j|�XdS)Nrrr )rrr )	r,r�r$r�r0r4r2�_write_end_recordr4)rur,rrrr�=s
			z
ZipFile.closecCs�x
|jD]�}|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}g}|jtks�|jtkr�|j|j�|j|j�d
}d
}n|j}|j}|jtkr�|j|j�d
}n	|j}|j}	d}
|rJtj	ddt
|�dd
t
|�|�|	}	t}
|jt
krktt|
�}
n|jtkr�tt|
�}
t|
|j�}t|
|j�}y�|j�\}
}tj	tt||j||j||j|||j||t
|
�t
|	�t
|j�d|j|j|�}Wn�tk
r�ttt||j||j|j|j|||j||t
|j �t
|	�t
|j�d|j|j|fdt!j"��YnX|j#j$|�|j#j$|
�|j#j$|	�|j#j$|j�q
W|j#j%�}t
|j�}||j&}|j&}d}|t'kr\d}n'|tkrqd}n|tkr�d}|r7|j(s�t)|d��tj	t*t+ddddd||||�}|j#j$|�tj	t,t-d|d�}|j#j$|�t.|d�}t.|d
�}t.|d
�}tj	t/t0dd||||t
|j1��	}|j#j$|�|j#j$|j1�|j#j2�dS)Nri�r#rr rrr%rl��z<HH�Qrr�zFiles countzCentral directory offsetzCentral directory sizez would require ZIP64 extensions�,ri��)3r'rZrgr�rfrSrdr\r7r�r6r�r[rrTr�rr�r^rJr�rBrDr]r_rerXrbrcrgr=r`r2rr�stderrr,r�rNr2r�r#r
r<r=r9r:rrQrPr(r�)rurWr�r�r�r\rgrfrdZ
extra_datar�r^rJr2r`rLZpos2ZcentDirCountZcentDirSizeZ
centDirOffsetr�Zzip64endrecZzip64locrecrGrrrr�Ns�	&&							

!
				
zZipFile._write_end_recordcCs1|jd8_|jr-|jr-|j�dS)Nr)r-r+r�)rur,rrrr4�szZipFile._fpclose)"rrrr,ryrrvr6r:r�r1rRrSrXrZr]r_�propertyrX�setterr.r1rrrt�classmethodr�ror�r�r�r�r�r�r4rrrrr�s8TN	
		
X'h?ec@sFeZdZdedddd�Zdddd	�Zd
d�ZdS)
rrTrc	Cs/tj||d|d|d|�||_dS)Nr�r�r5)rrv�	_optimize)rur�r�r�r5�optimizerrrrv�szPyZipFile.__init__rxNcCs�|rR||�rR|jrNtjj|�r4dnd}td||f�dStjj|�\}}tjj|�r1tjj|d�}tjj|�rP|r�d||f}n|}|jr�td|d|�|j|dd�|�\}}	|jrtd
|	�|j	||	�tj
|�}
|
jd�x�|
D]}tjj||�}tjj|�\}
}tjj|�r�tjjtjj|d��rI|j
||d|�qI|dkrI|r||�r|jrItd
|�qI|j|dd�|�\}}	|jr9td
|	�|j	||	�qIWq�|jrftd|�x2tj
|�D]�}tjj||�}tjj|�\}
}|dkrv|r�||�r�|jrvtd
|�qv|j|dd�|�\}}	|jrtd
|	�|j	||	�qvWnj|dd�dkrStd��|j|dd�|�\}}	|jr�td|	�|j	||	�dS)Nrqr�z%s "%s" skipped by filterfuncz__init__.pyz%s/%szAdding package in�asrrZAdding�
filterfuncz.pyzfile "%s" skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding file���r�r�r�r�)r%rnrqr�r=r|r�isfile�
_get_codenamer��listdir�remove�splitext�writepyr�)ru�pathname�basenamer�Zlabel�dirr�Zinitnamerlr~�dirlistr2rq�root�extrrrr��sv		"	


!
		
	
		
	"	
zPyZipFile.writepyc
s�d
�fdd�}|d}|d}tjj|dd�}tjj|dd�}tjj|dd�}�jdkr�tjj|�r�tj|�jtj|�jkr�|}	}
q�tjj|�rtj|�jtj|�jkr|}
|}	q�tjj|�rMtj|�jtj|�jkrM|}
|}	q�tjj|�r�tj|�jtj|�jkr�|}
|}	q�||�r�t	j
jd	kr�|}
n!t	j
jdkr�|}
n|}
|}	q�|}
}	n��jd	kr|}
|}	nT|}	�jdkr,|}
n6�jdkrD|}
nd
j�j�}t
|��tjj|
�o�tj|
�jtj|�jks�||d�j�s�|}
}	tjj|	�d}|r�d||f}|
|fS)Nrcsddl}�jr"td|�y|j|ddd|�Wn9|jk
rz}zt|j�dSWYdd}~XnXdS)NrZ	Compiling�doraiseTr�F)�
py_compiler%r=r�PyCompileError�msg)r�r�r��err)rurr�_compiles	

z)PyZipFile._get_codename.<locals>._compilez.pyz.pyc�optimizationrxrrz"invalid value for 'optimize': {!r}r�z%s/%sryry)�	importlib�util�cache_from_sourcer�rnrqr�r}r�rrrMr��formatrqr|)
rur�r�r�Zfile_pyZfile_pycZpycache_opt0Zpycache_opt1Zpycache_opt2r~rlr�Zarchivenamer)rurr�s`

$
$	$	$				
			$
zPyZipFile._get_codenamery)rrrrrvr�r�rrrrr�sQcs�ddl}|jd�}|dkr:tjdd�}|sQ|ddkrht|�tjd�|ddkr�t|�dkr�t|�tjd�t|dd	��}|j�WdQRXn�|ddkrSt|�dkrt|�tjd�t|dd	��}|j	�}WdQRX|rFtd
j
|��td�nT|ddkr�t|�dkr�t|�tjd�t|dd	��}|j|d�WdQRXn�|ddkr�t|�dkr�t|�tjd��fd
d��t|dd���}x|dd�D]m}tj
j|�}|sktj
jtj
j|��}|dtjtjfkr�d}�|||�q/WWdQRXdS)NraE        Usage:
            zipfile.py -l zipfile.zip        # Show listing of a zipfile
            zipfile.py -t zipfile.zip        # Test if a zipfile is valid
            zipfile.py -e zipfile.zip target # Extract zipfile into target dir
            zipfile.py -c zipfile.zip src ... # Create zipfile from sources
        r�-l�-c�-e�-trrz.The following enclosed file is corrupted: {!r}zDone testingrcs�tjj|�r(|j||t�nptjj|�r�|rP|j||�xEtj|�D]4}�|tjj||�tjj||��q`WdS)N)rnrqr�r�rr�r�r)�zfrq�zippathZnm)�addToZiprrr��szmain.<locals>.addToZiprrx)r�r�r�r�)�textwrap�dedentrr�argvr=�exitr6rrXrZr�rtrnrqr�r�r�r�)�argsr�ZUSAGEr�Zbadfilerqr�r)r�r�maingsT	










r��__main__)|rrnr�importlib.utilr�rrr�r}r�r7Zbinasciir.�ImportError�dummy_threadingr�r�r�r��__all__�	Exceptionrr
rrr�r�rarrrrrtr�r�r�rJrQrPr�rOr>r?r@rArBrCrDrVr>r?rBrDrArCZ_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_SIZErErGrHZ_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESrIr�r�rhriZ_FH_EXTRACT_VERSIONZ_FH_EXTRACT_SYSTEMZ_FH_GENERAL_PURPOSE_FLAG_BITSZ_FH_COMPRESSION_METHODZ_FH_LAST_MOD_TIMEZ_FH_LAST_MOD_DATEZ_FH_CRCZ_FH_COMPRESSED_SIZEZ_FH_UNCOMPRESSED_SIZErjrkr9r:r5r<r=r;Z_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_CENTDIRr-r	rKr*�objectr
r�r�r�r{r�r�r�r�r�rr�rrr�rrrrr�<module>s,




	

+=�=�����B

?>