Viewing File: /opt/alt/python35/lib64/python3.5/__pycache__/zipfile.cpython-35.opt-1.pyc



YfB@sXdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZyddlZWne
k
rddlZYnXyddlZejZWn!e
k
rdZejZYnXyddlZWne
k
rdZYnXyddlZWne
k
rAdZYnXddddddd	d
ddd
dgZGdddeZGdddeZeZZdd>dZdd>dZdd>dZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&e
j'e%Z(dZ)dZ*dZ+dZ,dZ-d Z.d!Z/d"Z0dZ1d#Z2d$Z3d%Z4e
j'e3Z5dZ6dZ7dZ8dZ9dZ:d Z;d!Z<d"Z=dZ>d#Z?d&Z@d'ZAdZBd(ZCdZDd)ZEdZFd*ZGd+ZHd,ZId-ZJe
j'eIZKdZLdZMdZNdZOdZPd ZQd!ZRd"ZSdZTd#ZUd&ZVd'ZWd.ZXd/ZYe
j'eXZZd0Z[d1Z\e
j'e[Z]dZ^dZ_dZ`dZadZbd Zcd!Zdd"ZedZfd#Zgd2d3Zhd4d
Zid5d6Zjd7d8ZkGd9ddelZmGd:d;d;ZnGd<d=d=ZoGd>d?d?Zpdd@ddAddBddBddBd dBd!dCd"dDddEd#dFd&dCddGddHd+dIdJdKdLdMdNdOiZqdPdQZrdRdSZsdTdUZtGdVdWdWZuGdXdYdYZvGdZd[d[ejwZxGd\ddZyGd]d
d
eyZzdd^d_Z{e|d`krTe{dS)azP
Read and write ZIP files.

XXX references to utf-8 need further investigation.
N
BadZipFile
BadZipfileerror
ZIP_STOREDZIP_DEFLATED	ZIP_BZIP2ZIP_LZMA
is_zipfileZipInfoZipFile	PyZipFileLargeZipFilec@seZdZdS)rN)__name__
__module____qualname__rr,/opt/alt/python35/lib64/python3.5/zipfile.pyr+sc@seZdZdZdS)r
zu
    Raised when writing a zipfile, the zipfile requires ZIP64 extensions
    and those extensions are disabled.
    N)rrr__doc__rrrrr
/s-.?s<4s4H2LHsPK	z<4s4B4HL2L5H2LsPK

z<4s2B4HL2L2HsPKz<4sLQLsPKz
<4sQ2H2L4QsPKcCs-yt|rdSWntk
r(YnXdS)NTF)_EndRecDataOSError)fprrr_check_zipfiles
r.cCsid}yJt|dr*td|}n%t|d}t|}WdQRXWntk
rdYnX|S)zQuickly 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.
    Freadr-rbN)hasattrr.openr,)filenameresultr-rrrr	s
cCsoy|j|tdWntk
r0|SYnX|jt}t|tkrV|Stjt|\}}}}|tkr|S|dks|dkrt	d|j|tt
d|jt
}t|t
kr|Stjt|\
}}}	}
}}}
}}}|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)seeksizeEndCentDir64Locatorr,r/lenstructunpackstructEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64structEndArchive64stringEndArchive64_ECD_SIGNATURE_ECD_DISK_NUMBER_ECD_DISK_START_ECD_ENTRIES_THIS_DISK_ECD_ENTRIES_TOTAL	_ECD_SIZE_ECD_OFFSET)fpinoffsetendrecdataZsigZdisknoZreloffZdisksZszcreate_versionZread_versionZdisk_numZdisk_dirZdircountZ	dircount2ZdirsizeZ	diroffsetrrr
_EndRecData64s6
	0






rKc	Cs|jdd|j}y|jtdWntk
rIdSYnX|j}t|tkr|ddtkr|d	ddkrtjt	|}t
|}|jd|j|tt|t|St
|d
td}|j|d|j}|jt}|dkr|||t}t|tkrYdSt
tjt	|}|t}||t|t|}|j||j||t|||||SdS)zReturn 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 srri)r5tellsizeEndCentDirr,r/r7stringEndArchiver8r9structEndArchivelistappendrKmaxrfind_ECD_COMMENT_SIZE)	rFZfilesizerIrHZmaxCommentStartstartZrecDataZcommentSizecommentrrrr+s>
	


r+c@saeZdZdZd$Zdd%ddZddZdddZd d!Zd"d#Z	dS)&r
z>Class with attributes describing each file in the ZIP archive.
orig_filenamer3	date_time
compress_typerXextra
create_systemrJextract_versionreserved	flag_bitsvolume
internal_attr
external_attr
header_offsetCRC
compress_size	file_size	_raw_timeZNoNamerrcCs||_|jtd}|dkr:|d|}tjdkrmtj|krm|jtjd}||_||_|ddkrtdt	|_
d|_d|_t
jdkrd|_n	d|_t|_t|_d|_d|_d|_d|_d|_dS)Nr/iz+ZIP does not support timestamps before 1980rLwin32r)rYfindchrossepreplacer3rZ
ValueErrorrr[rXr\sysplatformr]DEFAULT_VERSIONrJr^r_r`rarbrc)selfr3rZZ	null_byterrr__init__@s.													zZipInfo.__init__cCs;d|jj|jfg}|jtkrN|jdtj|j|j|jd?}|jd@}|r|jdt	j
||r|jd||jd
ddk}|s|jr|jd	|j|s|jr!|jtks
|j|jkr!|jd
|j|jddj
|S)Nz<%s filename=%rz compress_type=%sriz filemode=%rz external_attr=%#xrrjz
 file_size=%rz compress_size=%r>)	__class__rr3r[rrScompressor_namesgetrcstatfilemodergrfjoin)rur4hiloisdirrrr__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}|rd}
|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)z'Return the per-file header as a string.rir$rr!rrr&r rNz<HHQQz'Filesize would require ZIP64 extensionsl)rZr`rerfrgr\ZIP64_LIMITr8packcalcsizer

ZIP64_VERSIONr[rrT
BZIP2_VERSIONrLZMA_VERSIONr^rJ_encodeFilenameFlagsstructFileHeaderstringFileHeaderr_r7)ruzip64dtdosdatedostimererfrgr\min_versionfmtr3r`headerrrr
FileHeadersF	&&
				 zZipInfo.FileHeadercCsSy|jjd|jfSWn/tk
rN|jjd|jdBfSYnXdS)Nasciizutf-8i)r3encoder`UnicodeEncodeError)rurrrrs
zZipInfo._encodeFilenameFlagscCs|j}tj}xvt|dkr|d|dd\}}|dkrs|dkrz|d|dd}nx|dkr|d|dd	}nP|d
kr|d|dd}n(|d
krf}ntd|fd
}|jdkr|||_|d7}|jdkrD|||_|d7}|jdkrs|j}|||_|d7}||dd}qWdS)Nr z<HHrz<QQQrz<QQrrz<QrrzCorrupt extra field %s)rr)r\r8r9r7RuntimeErrorrgrfrd)rur\r9tplnZcountsidxoldrrr_decodeExtras4			



	

zZipInfo._decodeExtra)rYr3rZr[rXr\r]rJr^r_r`rarbrcrdrerfrgrh)rirrrrr)
rrrr	__slots__rvrrrrrrrrr
's2*.c@sXeZdZdZddZdZddZddZd	d
ZddZ	dS)

_ZipDecrypteraClass to handle decryption of files stored within a ZIP archive.

    ZIP supports a password-based form of encryption. Even though known
    plaintext attacks have been found against it, it is still useful
    to be able to get data out of such a file.

    Usage:
        zd = _ZipDecrypter(mypwd)
        plain_char = zd(cypher_char)
        plain_text = map(zd, cypher_text)
    cCsd}dgd}xhtdD]Z}|}xAtdD]3}|d@r^|d?d@|A}q9|d?d@}q9W|||<q W|S)zGenerate a CRC-32 table.

        ZIP encryption uses the CRC32 one-byte primitive for scrambling some
        internal keys. We noticed that a direct implementation is faster than
        relying on binascii.crc32().
        l q[rrri)range)Zpolytableicrcjrrr_GenerateCRCTables

z_ZipDecrypter._GenerateCRCTableNcCs|d?d@|j||Ad@AS)z(Compute the CRC32 primitive on one byte.ri)crctable)ruZchrrrr_crc32sz_ZipDecrypter._crc32cCs[tjdkrtjt_d|_d|_d|_x|D]}|j|q@WdS)NixV4igE#ixV4)rrrkey0key1key2_UpdateKeys)rupwdprrrrvs			
z_ZipDecrypter.__init__cCsr|j||j|_|j|jd@d@|_|jddd@|_|j|jd?d@|j|_dS)Nrlirr)rrrr)rucrrrrsz_ZipDecrypter._UpdateKeyscCs8|jdB}|||dAd?d@A}|j||S)zDecrypt a single character.rrrr)rr)rurkrrr__call__
s

z_ZipDecrypter.__call__)
rrrrrrrrvrrrrrrrs	rc@s@eZdZddZddZddZddZd	S)
LZMACompressorcCs
d|_dS)N)_comp)rurrrrvszLZMACompressor.__init__cCsetjdtji}tjtjdtjtj|g|_tjdddt	||S)Nidfiltersz<BBHr$r )
lzmaZ_encode_filter_propertiesFILTER_LZMA1r
FORMAT_RAW_decode_filter_propertiesrr8rr7)ruZpropsrrr_initszLZMACompressor._initcCs9|jdkr)|j|jj|S|jj|S)N)rrcompress)rurIrrrr"szLZMACompressor.compresscCs3|jdkr&|j|jjS|jjS)N)rrflush)rurrrr'szLZMACompressor.flushN)rrrrvrrrrrrrrsrc@s(eZdZddZddZdS)LZMADecompressorcCsd|_d|_d|_dS)NrLF)_decomp_unconsumedeof)rurrrrv/s		zLZMADecompressor.__init__c	Cs|jdkr|j|7_t|jdkr7dStjd|jdd\}t|jd|krvdStjtjdtjtj	|jdd|g|_|jd|d}|`|jj
|}|jj|_|S)Nr rLz<Hrr)rrr7r8r9rrrrr
decompressr)rurIZpsizer4rrrr4s"#zLZMADecompressor.decompressN)rrrrvrrrrrr-srZstoreZshrinkreduceZimplodetokenizeZdeflateZ	deflate64Zbzip2rZterseZlz77aZwavpackbZppmdcCs|tkrno|tkr0ts~tdnN|tkrQts~tdn-|tkrrts~tdntddS)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)rrzlibrrbz2rr)compressionrrr_check_compression]srcCsV|tkr%tjtjtjdS|tkr;tjS|tkrNt	SdSdS)Nr(i)
rrZcompressobjZZ_DEFAULT_COMPRESSIONZDEFLATEDrrZ
BZ2Compressorrr)r[rrr_get_compressorps

rcCs|tkrdS|tkr)tjdS|tkr?tjS|tkrRtSt	j
|}|rtd||fntd|fdS)Nr(zcompression type %d (%s)zcompression type %di)rrrZ
decompressobjrrZBZ2Decompressorrrr{r|NotImplementedError)r[Zdescrrrr_get_decompressor|s

rc@s7eZdZddZd	ddZddZdS)
_SharedFilecCs(||_||_||_||_dS)N)_file_pos_close_lock)rufileposcloselockrrrrvs			z_SharedFile.__init__rc	CsP|j@|jj|j|jj|}|jj|_|SWdQRXdS)N)rrr5rr/rN)runrIrrrr/s

z_SharedFile.readcCs2|jdk	r.|j}d|_|j|dS)N)rr)rufileobjrrrrs		z_SharedFile.closeNry)rrrrvr/rrrrrrsrc@sLeZdZddZddZddZddZd	d
ZdS)	_TellablecCs||_d|_dS)Nr)r-rG)rur-rrrrvs	z_Tellable.__init__cCs%|jj|}|j|7_|S)N)r-writerG)rurIrrrrrsz_Tellable.writecCs|jS)N)rG)rurrrrNsz_Tellable.tellcCs|jjdS)N)r-r)rurrrrsz_Tellable.flushcCs|jjdS)N)r-r)rurrrrsz_Tellable.closeN)rrrrvrrNrrrrrrrs
rcseZdZdZdZdZejdZdddd	Z	d
dZ
d dd
ZdddZddZ
d!ddZddZddZddZddZfddZS)"
ZipExtFilezZFile-like object for reading an archive member.
       Is returned by ZipFile.open().
    rris*^(?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|dr|j|_td|_n	d|_dS)NFrLrUrre)_fileobj
_decrypter_close_fileobjr[_compress_typerf_compress_leftrg_leftr
_decompressor_eof_readbuffer_offset
_universalnewlinesmoder3namer1re
_expected_crccrc32_running_crc)rurrzipinfoZ	decrypterZ
close_fileobjrrrrvs(								zZipExtFile.__init__cCsd|jj|jjfg}|jsz|jd|j|jf|jtkr|jdt	j
|j|jn
|jd|jddj|S)Nz<%s.%sz name=%r mode=%rz compress_type=%sz	 [closed]rwrx)rzrrclosedrSrrrrr{r|r)rur4rrrrs		

zZipExtFile.__repr__cCs|jra|dkra|jjd|jd}|dkra|j|j|}||_|S|js}tjj||Sd}x|dkst||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}qW|S)	zrRead and return a line from the stream.

        If limit is specified, at most limit bytes will be read.
        rs
rrLrnewlineNchunk)rrrlrioBufferedIOBasereadliner7peekPATTERNsearchgrouprrS)rulimitrlineZ	readaheadmatchrrrrrrs8		!
	zZipExtFile.readlinecCs|t|j|jkr~|j|}t||jkri||j|jd|_d|_n|jt|8_|j|j|jdS)z6Returns buffered bytes without advancing the position.Nri)r7rrr/)rurrrrrr%szZipExtFile.peekcCsdS)NTr)rurrrreadable2szZipExtFile.readablecCsm|dks|dkrj|j|jd}d|_d|_x#|jse||j|j7}qCW|S||j}|t|jkr|j|j|}||_|S|t|j}|j|jd}d|_d|_x||dkrh|jrh|j|}|t|krK||_||_||d|7}P||7}|t|8}qW|S)zRead and return up to n bytes.
        If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
        NrrL)rrr_read1MAX_Nr7)rurbufendrIrrrr/5s4		
					
zZipExtFile.readcCsZ|jdkrdSt||j|_|jrV|j|jkrVtd|jdS)NzBad CRC-32 for file %r)rrrrrr)runewdatarrr_update_crcVs
zZipExtFile._update_crccCsp|dks|dkrw|j|jd}d|_d|_x0|jsr|j|j}|rC||7}PqCW|S||j}|t|jkr|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkrlxf|jsk|j|}|t|krW||_||_||d|7}P|r||7}PqW|S)z7Read up to n bytes with at most one read() system call.NrrL)rrrrrr7)rurrrIrrrrread1`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_|jdkrd|_|j||S)NrrLT)rrrrZunconsumed_tailr7_read2rrrT
MIN_READ_SIZErrrrr)rurrIrrrrs2 		
zZipExtFile._read1cCs|jdkrdSt||j}t||j}|jj|}|jt|8_|sjt|jdk	rt	t
|j|}|S)NrrL)rrTr
minrr/r7EOFErrorrbytesmap)rurrIrrrr	szZipExtFile._read2c
s/z|jr|jjWdtjXdS)N)rrrsuper)ru)rzrrrs	zZipExtFile.closei@ryry)rrrrrr
recompilerrvrrrrr/rrrr	rrr)rzrrs  2
!
%$rc@seZdZdZdZdZdedddZddZd	d
Z	ddZ
d
dZddZddZ
dddZddZddZddZeddZejddZdddZddd d!Zddd"d#Zdddd$d%Zed&d'Zd(d)Zd*d+Zddd,d-Zdd.d/Zd0d1Zd2d3Z d4d5Z!d6d7Z"dS)8ra Class with methods to open, read, write, close, list zip files.

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

    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.

    NrTcCs|dkrtdt|||_d|_d|_i|_g|_||_||_d|_	d	|_
t|tr#d|_
||_dd
dddddd
d
dddddi}||}xyytj|||_Wn.tk
r||kr||}wYnXPqWn'd|_
||_t|dd|_d|_tj|_d|_yD|dkr|jn'|dkr/d|_y|jj|_Wn<ttfk
rt|j|_d|_d|_YqXy|jj|jWqttfk
r+d|_YqXn|dkry!|j|jj|jWqtk
r|jjddd|_|jj|_YqXntdWn*|j}d|_|j |YnXdS)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
        or append 'a'.rwxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNrLr0zw+bzx+bzr+bwbZxbrrTrz"Mode must be 'r', 'w', 'x', or 'a')rrrr)rr)!rr_allowZip64
_didModifydebug
NameToInfofilelistrrr_comment
isinstancestr_filePassedr3rr2r-r,getattr_fileRefCnt	threadingRLockr	_seekable_RealGetContentsrN	start_dirAttributeErrorrr5r_fpclose)rurrr
allowZip64ZmodeDictr~r-rrrrvs|
											


				
		

			
zZipFile.__init__cCs|S)Nr)rurrr	__enter__)szZipFile.__enter__cCs|jdS)N)r)rutypevalue	tracebackrrr__exit__,szZipFile.__exit__cCsd|jj|jjfg}|jdk	r|jrN|jd|jn#|jdk	rq|jd|j|jd|jn
|jd|jddj|S)Nz<%s.%sz file=%rz filename=%rz mode=%rz	 [closed]rwrx)	rzrrr-r rSr3rr)rur4rrrr/s	

zZipFile.__repr__cCs|j}yt|}Wntk
r9tdYnX|sLtd|jdkret||t}|t}|t|_	|t
||}|ttkr|t
t8}|jdkr||}td||||||_|j|jd|j|}tj|}d}xi||kr|jt}	t|	tkrbtdtjt|	}	|	ttkrtd|jdkrt|	|j|	t}
|	d}|d	@r|
jd
}
n|
jd}
t|
}|j|	t|_|j|	t |_!|	t"|_#|	dd\|_$|_%|_&|_'|_(|_)}
}|_*|_+|_,|j&t-krt.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)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!izutf-8cp437rzzip file version %.1fr%r(r*r$irr&rtotalN)9r-r+r,rrprintrDrE_ECD_COMMENTr
_ECD_LOCATIONr?r>r<r6r'r5r/rBytesIOsizeCentralDirr7r8r9structCentralDir
_CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHdecoder
_CD_EXTRA_FIELD_LENGTHr\_CD_COMMENT_LENGTHrX_CD_LOCAL_HEADER_OFFSETrdrJr]r^r_r`r[rerfrgMAX_EXTRACT_VERSIONrrarbrcrhrZrrrSrr3)rur-rHZsize_cdZ	offset_cdconcatZinferredrIr1centdirr3flagsrtdrrrr&=sp	










L"	&
"zZipFile._RealGetContentscCsdd|jDS)z+Return a list of file names in the archive.cSsg|]}|jqSr)r3).0rIrrr
<listcomp>s	z$ZipFile.namelist.<locals>.<listcomp>)r)rurrrnamelistszZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the
        archive.)r)rurrrinfolistszZipFile.infolistcCsftdd
d|xK|jD]@}d|jdd}td	|j||jfd|qWdS)z+Print a table of contents for the zip file.z%-46s %19s %12s	File NameModified    Sizerz%d-%02d-%02d %02d:%02d:%02dNr"z
%-46s %s %12d)rIrJrK)r2rrZr3rg)rurzinfoZdaterrrprintdirs
zZipFile.printdircCssd}xf|jD][}y9|j|jd}x|j|rFq4WWdQRXWqtk
rj|jSYqXqWdS)z%Read all the files and check the CRC.rrrNi)rr2r3r/r)ruZ
chunk_sizerLfrrrtestzips
zZipFile.testzipcCs2|jj|}|dkr.td||S)z,Return the instance of ZipInfo given 'name'.Nz(There is no item named %r in the archive)rr|KeyError)rurinforrrgetinfos

zZipFile.getinfocCsK|r,t|tr,tdt||r>||_n	d|_dS)z)Set default password for encrypted files.zpwd: expected bytes, got %sN)rr
	TypeErrorr,r)rurrrrsetpasswords
zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)r)rurrrrXszZipFile.commentcCst|ts%tdt|t|tkrjddl}|jdtdd|dt}||_d|_	dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytes
stacklevelrT)
rr
rSr,r7ZIP_MAX_COMMENTwarningswarnrr)rurXrWrrrrXs		c	Cs-|j|d|}|jSWdQRXdS)z)Return file bytes (as a string) for name.rN)r2r/)rurrr-rrrr/szZipFile.readcCs|dkrtdd|krCddl}|jdtd|rot|trotd	t||jstd
t|t	r|}n|j
|}|jd7_t|j|j
|j|j}y|jt}t|tkrtdtjt|}|ttkr9td
|j|t}|trg|j|t|jd@rtd|jd@rtd|jd@r|jd}	n|jd}	|	|jkrtd|j|f|jd@}
d}|
r|s|j}|s-td|t |}|jd}t!t"||dd}
|jd@r|j#d?d@}n|j$d?d@}|
d|krtd|t%||||dSWn|j&YnXdS)z#Return file-like object for 'name'.rrrUz&open() requires mode "r", "U", or "rU"rNz'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-8r0z/File name in directory %r and header %r differ.z6File %s is encrypted, password required for extractionrrrrr&zBad password for fileT)rrrY)'rrWrXDeprecationWarningrr
rSr,r-r
rRr"rrdr)rr/sizeFileHeaderr7rr8r9r
_FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHr`rr;rYrrrRrrhrerr)rurrrrWrLZzef_fileZfheaderfnameZ	fname_strZis_encryptedZzdrhZ
check_byterrrr2sr	
			!




	


zZipFile.opencCsIt|ts|j|}|dkr6tj}|j|||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)rr
rRrngetcwd_extract_member)rumemberpathrrrrextract+s
zZipFile.extractcCs@|dkr|j}x!|D]}|j|||qWdS)zExtract 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)rGrg)rurfZmembersrrrrr
extractall9s
zZipFile.extractallcCs|j}|s:d}tj|dt|}||_|j|}dd|j|D}|jdd|D}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*_css|]}|jdVqdS).N)rstrip)rErrrr	<genexpr>Osz1ZipFile._sanitize_windows_name.<locals>.<genexpr>css|]}|r|VqdS)Nr)rErrrrrlQs)!_windows_illegal_name_trans_tabler	maketransr7	translatesplitr)clsarcnamepathseprZillegalrrr_sanitize_windows_nameEs		zZipFile._sanitize_windows_namecs|jjdtjj}tjjrE|jtjjtjj}tjj|d}dtjjtjjftjjj	fdd|j
tjjD}tjjdkr|j|tjj}tjj	||}tjj|}tjj
|}|r6tjj|r6tj||jd
dkrltjj|shtj||S|j|d|0}t|d}tj||Wd	QRXWd	QRX|S)zbExtract the ZipInfo object 'member' to a physical
           file on the path targetpath.
        rjrrxc3s!|]}|kr|VqdS)Nr)rEr)invalid_path_partsrrrlbsz*ZipFile._extract_member.<locals>.<genexpr>\rrNry)r3rprnrfroaltsep
splitdrivecurdirpardirrrprtnormpathdirnameexistsmakedirsrmkdirr2shutilZcopyfileobj)rureZ
targetpathrrrZ	upperdirssourcetargetr)rurrdTs*7

zZipFile._extract_membercCs|j|jkr8ddl}|jd|jdd|jdkrStd	|jshtd
t|j|j	sd}t
|jtkrd}n-|j
tkrd}n|jtkrd
}|rt|ddS)z6Check for errors before writing a file to the archive.rNzDuplicate name: %rrUrrrrz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedzFiles countZFilesizezZipfile sizez would require ZIP64 extensions)rrr)r3rrWrXrrr-rr[rr7rZIP_FILECOUNT_LIMITrgrrdr
)rurLrWrequires_zip64rrr_writecheck{s(		
			zZipFile._writecheckcCs|jstdtj|}tj|j}tj|j}|dd}|dkrj|}tj	j
tj	j|d}x0|dtjtj
fkr|dd}qW|r|d7}t||}|dd@d>|_|rt|_n$|dkr |j|_n	||_|j|_d|_|jU|jrd|jj|j|jj|_|jtkr|jd	O_|j|d
|_|r)d|_d|_d|_ |jdO_|j!j"|||j#|j$<|jj%|j&d|jj|_dSt'|j}	|jsP|jdO_t(|d
}
d|_ }d|_}|j)o|jdt*k}
|jj%|j&|
d}xn|
j+d}|sP|t,|}t-||}|	r|	j.|}|t,|}|jj%|qWWdQRX|	rm|	j/}|t,|}|jj%|||_n	||_||_ ||_|jd@r|
rdnd}|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)zLPut the bytes from filename into the archive under the name
        arcname.z7Attempt to write to ZIP archive that was already closedrr"NrrjirrTFrr0g?iz<LQQz<LLLz*File size has increased during compressingz-Compressed size larger than uncompressed sizei )2r-rrnr}S_ISDIRst_modetime	localtimest_mtimerfr{rxrorwr
rcrr[rst_sizergr`rr%r5r'rNrdrrrrfrerrSrr3rrrr2rrr/r7rrrr8r)rur3rrr[strmtimerZrLZcmprr-rerfrrgrrrrrrs		"
		
	
					

				

z
ZipFile.writec
Cst|tr|jd}t|tstd|dtjtjdd}|j|_|jddkrd|_	|j	d	O_	qd|_	n|}|j
stdt||_
|j|jr|j
j|j|j
j|_|dk	r||_|j
j|_|dk	r?||_|jtkr]|jdO_|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)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.zutf-8r3rZNr"rrjiAriz7Attempt to write to ZIP archive that was already closedrTz'Filesize would require ZIP64 extensionsrz<LQQz<LLLryiAi)(rrrr
rrrr[r3rcr-rr7rgrr%r5r'rNrdrr`rrrrerrrrfrrr
rrr8rrrSr)ruZzinfo_or_arcnamerIr[rLcorrrrrwritestrs`"			
			
	


zZipFile.writestrcCs|jdS)z2Call the "close()" method in case the user forgot.N)r)rurrr__del__9szZipFile.__del__cCs|jdkrdSzS|jdkre|jre|j+|jrT|jj|j|jWdQRXWd|j}d|_|j|XdS)zOClose the file, and for mode 'w', 'x' and 'a' write the ending
        records.Nrrr)rrr)	r-rrrr%r5r'_write_end_recordr))rur-rrrr=s
			z
ZipFile.closecCsx
|jD]}|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}g}|jtks|jtkr|j|j|j|jd
}d
}n|j}|j}|jtkr|j|jd
}n	|j}|j}	d}
|rJtj	ddt
|dd
t
|||	}	t}
|jt
krktt|
}
n|jtkrtt|
}
t|
|j}t|
|j}y|j\}
}tj	tt||j||j||j|||j||t
|
t
|	t
|jd|j|j|}Wntk
rttt||j||j|j|j|||j||t
|j t
|	t
|jd|j|j|fdt!j"YnX|j#j$||j#j$|
|j#j$|	|j#j$|jq
W|j#j%}t
|j}||j&}|j&}d}|t'kr\d}n'|tkrqd}n|tkrd}|r7|j(st)|dtj	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#j2dS)Nrir$rr!rrr&r lz<HHQrrzFiles countzCentral directory offsetzCentral directory sizez would require ZIP64 extensions,ri)3rrZrgrrfrSrdr\r8rr7rr[rrTrrrr^rJrr7r9r]r_rerXrbrcr\r2r`r3rrstderrr-rrNr'rrr
r=r>r:r;rrQrPrr)rurLrrrr\rgrfrdZ
extra_datarr^rJr3r`rAZpos2ZcentDirCountZcentDirSizeZ
centDirOffsetrZzip64endrecZzip64locrecrHrrrrNs	&&							

!
				
zZipFile._write_end_recordcCs1|jd8_|jr-|jr-|jdS)Nr)r"r r)rur-rrrr)szZipFile._fpclose)#rrrrr-rmrrvr+r/rr&rGrHrMrOrRrTpropertyrXsetterr/r2rgrhclassmethodrtrdrrrrrrr)rrrrrs:TN	
		
X'h?ec@sLeZdZdZdedd
ddZddd	d
ZddZdS)rzDClass to create ZIP archives with Python library files and packages.rTrc	Cs/tj||d|d|d|||_dS)Nrrr*)rrv	_optimize)rurrrr*optimizerrrrvszPyZipFile.__init__rxNcCs|rR||rR|jrNtjj|r4dnd}td||fdStjj|\}}tjj|r1tjj|d}tjj|rP|rd||f}n|}|jrtd|d||j|d	d|\}}	|jrtd|	|j	||	tj
|}
|
jdx|
D]}tjj||}tjj|\}
}tjj|rtjjtjj|drI|j
||d|qI|d
krI|r||r|jrItd|qI|j|d	d|\}}	|jr9td|	|j	||	qIWq|jrftd|x2tj
|D]}tjj||}tjj|\}
}|d
krv|r||r|jrvtd|qv|j|d	d|\}}	|jrtd|	|j	||	qvWnj|ddd
krStd|j|d	d|\}}	|jrtd|	|j	||	dS)aAdd 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.
        rfrz%s "%s" skipped by filterfuncNz__init__.pyz%s/%szAdding package inasrrZAdding
filterfuncz.pyzfile "%s" skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding filerrrr)rrnrfrr2rprisfile
_get_codenamerlistdirremovesplitextwritepyr)rupathnamebasenamerZlabeldirrZinitnamerarrZdirlistr3rfrootZextrrrrsv		"	


!
		
	
		
	"	
zPyZipFile.writepyc
sd
fdd}|d}|d}tjj|dd}tjj|dd}tjj|dd}jdkrtjj|rtj|jtj|jkr|}	}
qtjj|rtj|jtj|jkr|}
|}	qtjj|rMtj|jtj|jkrM|}
|}	qtjj|rtj|jtj|jkr|}
|}	q||rt	j
jd	kr|}
n!t	j
jdkr|}
n|}
|}	q|}
}	njd	kr|}
|}	nT|}	jdkr,|}
n6jdkrD|}
nd
jj}t
|tjj|
otj|
jtj|jks||djs|}
}	tjj|	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).
        rcsddl}jr"td|y|j|ddd|Wn9|jk
rz}zt|jdSWYdd}~XnXdS)NrZ	CompilingdoraiseTrF)
py_compilerr2rPyCompileErrormsg)rrrerr)rurr_compiles	

z)PyZipFile._get_codename.<locals>._compilez.pyz.pycoptimizationrxrrz"invalid value for 'optimize': {!r}rz%s/%sryry)	importlibutilcache_from_sourcerrnrfrr}rrrrBrformatrqrp)
rurrrZfile_pyZfile_pycZpycache_opt0Zpycache_opt1Zpycache_opt2rrrarZarchivenamer)rurrs`

$
$	$	$				
			$
zPyZipFile._get_codenamery)rrrrrrvrrrrrrrs
Qcsddl}|jd}|dkr:tjdd}|sQ|ddkrht|tjd|ddkrt|dkrt|tjdt|dd	}|jWdQRXn|ddkrSt|dkrt|tjdt|dd	}|j	}WdQRX|rFtd
j
|tdnT|ddkrt|dkrt|tjdt|dd	}|j|dWdQRXn|ddkrt|dkrt|tjdfd
dt|dd}x|ddD]m}tj
j|}|sktj
jtj
j|}|dtjtjfkrd}|||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 testingrcstjj|r(|j||tnptjj|r|rP|j||xEtj|D]4}|tjj||tjj||q`WdS)N)rnrfrrrrrr)zfrfzippathZnm)addToZiprrrszmain.<locals>.addToZiprrx)rrrr)textwrapdedentrrargvr2exitr7rrMrOrrhrnrfrr|ryrz)argsrZUSAGErZbadfilerfrr)rrmaingsT	










r__main__)}rrrnrimportlib.utilrrrrr}rr8Zbinasciir#ImportErrorZdummy_threadingrrrr__all__	Exceptionrr
rrrrrVrrrrrtrrrr?rQrPrrOr?r@rArBrCrDrErVr3r4r7r9r6r8Z_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>rrr]r^Z_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_SIZEr_r`r:r;r6r=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
rrrr{rrrrrrrrrrrrrrr<module>s.




	

+==B
Back to Directory File Manager