HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.7/__pycache__/zipfile.cpython-37.pyc
B

{a9@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZyddlZej
Z
Wnek
rdZe
j
Z
YnXyddlZWnek
rdZYnXyddlZWnek
rdZYnXddddddd	d
ddd
dgZGdddeZGdddeZeZZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$e	%e#Z&dZ'dZ(dZ)dZ*dZ+d Z,d!Z-d"Z.dZ/d#Z0d$Z1d%Z2e	%e1Z3dZ4dZ5dZ6dZ7dZ8d Z9d!Z:d"Z;dZ<d#Z=d&Z>d'Z?dZ@d(ZAdZBd)ZCd*ZDd+ZEd,ZFd-ZGd.ZHe	%eGZIdZJdZKdZLdZMdZNd ZOd!ZPd"ZQdZRd#ZSd&ZTd'ZUd/ZVd0ZWe	%eVZXd1ZYd2ZZe	%eYZ[dZ\dZ]dZ^dZ_dZ`d Zad!Zbd"ZcdZdd#Zed3Zfe	gd4Zhd5d6Zid7d8Zjd9d
Zkd:d;Zld<d=ZmGd>ddenZodapd?d@ZqdAdBZrGdCdDdDZsGdEdFdFZtdGdHdIdIdIdIdJdKdLdMdJdNdOdPdQdRdSdTZudUdVZvdhdWdXZwdYdZZxGd[d\d\ZyGd]d^d^ZzGd_d`d`ej{Z|Gdadbdbej{Z}GdcddZ~Gddd
d
e~ZdidedfZedgkredS)jzP
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@seZdZdS)rN)__name__
__module____qualname__rr/usr/lib/python3.7/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
*sii-.?s<4s4H2LHsPK	z<4s4B4HL2L5H2LsPK

z<4s2B4HL2L2HsPKz<4sLQLsPKz
<4sQ2H2L4QsPKiPKz<HHc
Cstj}d}g}d}}xf|dt|kr|||||d\}}|d|}	||krv||krn|||||	}d}|	}qW|s|Sd|S)NFrrT)_EXTRA_FIELD_STRUCTunpacklenappendjoin)
extraZxidsr,ZmodifiedbufferstartiZxidZxlenjrrr_strip_extras r5cCs*yt|rdSWntk
r$YnXdS)NTF)_EndRecDataOSError)fprrr_check_zipfilesr9c	CsVd}y8t|drt|d}nt|d}t|}WdQRXWntk
rPYnX|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.
    Fread)r8rbN)hasattrr9openr7)filenameresultr8rrrr	s
c
Csy||tdWntk
r(|SX|t}t|tkrD|Stt|\}}}}|tkrd|S|dkst|dkr|t	d||tt
d|t
}t|t
kr|Stt|\
}}}	}
}}}
}}}|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)seeksizeEndCentDir64Locatorr7r:r-structr,structEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64structEndArchive64stringEndArchive64_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

 rTc	Csf|dd|}y|tdWntk
r:dSX|}t|tkr|ddtkr|dddkrtt	|}t
|}|d||tt|t|St
|dtd}||d|}|t}|dkrb|||t}t|tkrdSt
tt	|}|t}||t|t|}|||||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.rrNrsr*i)r@tellsizeEndCentDirr7r:r-stringEndArchiverBr,structEndArchivelistr.rTmaxrfind_ECD_COMMENT_SIZE)	rOZfilesizerRrQZmaxCommentStartr2ZrecDataZcommentSizecommentrrrr6s>



r6c@sVeZdZdZdZdddZddZdd
dZdd
ZddZ	e
dddZddZd	S)r
z>Class with attributes describing each file in the ZIP archive.)
orig_filenamer>	date_time
compress_type_compresslevelr^r0
create_systemrSextract_versionreserved	flag_bitsvolume
internal_attr
external_attr
header_offsetCRC
compress_size	file_size	_raw_timeNoNameirrrrrcCs||_|td}|dkr(|d|}tjdkrJtj|krJ|tjd}||_||_|ddkrjtdt	|_
d|_d|_d|_
tjdkrd|_nd|_t|_t|_d|_d|_d|_d|_d|_dS)Nr/iz+ZIP does not support timestamps before 1980r*Zwin32r)r_findchrossepreplacer>r`
ValueErrorrrarbr^r0sysplatformrcDEFAULT_VERSIONrSrdrerfrgrhri)selfr>r`Z	null_byterrr__init__Ss0
zZipInfo.__init__cCsd|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=%rz compress_type=%sr'iz filemode=%rz external_attr=%#xz
 file_size=%rz compress_size=%r>)	__class__rr>rarr.compressor_namesgetristatfilemodeis_dirrmrlr/)r{r?hiloisdirrrr__repr__~s(






zZipInfo.__repr__NcCs||j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}|jd
@rfd}}}n|j}|j}|j}|j}d}	|dkr|tkp|tk}|rd}
|t|
dt	|
d	||}|tks|tkr|st
d
d}d}t}	|jt
krtt|	}	n|jtkrtt|	}	t|	|j|_t|	|j|_|\}}ttt|j|j||j|||||t|t|
}
|
||S)z-Return the per-file header as a bytes object.rir"rrrrr$rrNz<HHQQz'Filesize would require ZIP64 extensionsl)r`rfrkrlrmr0ZIP64_LIMITrBpackcalcsizer

ZIP64_VERSIONrarr[
BZIP2_VERSIONrLZMA_VERSIONrdrS_encodeFilenameFlagsstructFileHeaderstringFileHeaderrer-)r{zip64dtdosdatedostimerkrlrmr0min_versionfmtr>rfheaderrrr
FileHeadersF$$



zZipInfo.FileHeadercCs>y|jd|jfStk
r8|jd|jdBfSXdS)Nasciizutf-8i)r>encoderfUnicodeEncodeError)r{rrrrszZipInfo._encodeFilenameFlagscCsJ|j}tj}x6t|dkrD|d|dd\}}|dt|krTtd||f|dkr2|dkrz|d|dd}nV|dkr|d	|dd
}n:|dkr|d|dd
}n|dkrd}ntd||fd}|jdkr|||_|d7}|jdkr|||_|d7}|jdkr2|j}|||_|d7}||dd}qWdS)Nrz<HHz"Corrupt extra field %04x (size=%d)rz<QQQr'z<QQrrz<Qrrr)lll)r0rBr,r-rrmrlrj)r{r0r,tpZlnZcountsidxoldrrr_decodeExtras8




zZipInfo._decodeExtracCst|tjrt|}t|}t|j}t|j	}|dd}|dkrP|}tj
tj
|d}x$|dtj
tjfkr|dd}qjW|r|d7}|||}|jd@d>|_|rd|_|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 Nrrqir')
isinstancertPathLikefspathrS_ISDIRst_modetime	localtimest_mtimepathnormpath
splitdriverualtseprirmst_size)clsr>arcnamestrmtimer`zinforrr	from_files(



zZipInfo.from_filecCs|jddkS)z2Return True if this archive member is a directory.rq)r>)r{rrrrszZipInfo.is_dir)rorp)N)N)
rrrr	__slots__r|rrrrclassmethodrrrrrrr
9s
+
.&!cCs4x.tdD]"}|d@r$|d?dA}q
|dL}q
W|S)Nrrl q[)range)crcr4rrr_gen_crcs
rcspdddtdkr&ttttdatfddfddx|D]}|qNWfd	d
}|S)NixV4igE#ixV4cs|d?||Ad@AS)z(Compute the CRC32 primitive on one byte.rr)Zchr)crctablerrcrc324sz_ZipDecrypter.<locals>.crc32cs<|d@d@ddd@d?dS)Nrlirrr)c)rkey0key1key2rrupdate_keys8s
z"_ZipDecrypter.<locals>.update_keyscsRt}|j}x<|D]4}dB}|||dAd?d@N}|||qWt|S)zDecrypt a bytes object.rrrr)	bytearrayr.bytes)rRr?r.rk)rrrr	decrypterBs
z _ZipDecrypter.<locals>.decrypter)	_crctablerZmaprr)pwdprr)rrrrrrr
_ZipDecrypter*s
rc@s,eZdZddZddZddZddZd	S)
LZMACompressorcCs
d|_dS)N)_comp)r{rrrr|RszLZMACompressor.__init__cCsFtdtji}tjtjttj|gd|_tdddt	||S)Nid)filtersz<BBHr"r)
lzmaZ_encode_filter_propertiesFILTER_LZMA1r
FORMAT_RAW_decode_filter_propertiesrrBrr-)r{Zpropsrrr_initUszLZMACompressor._initcCs*|jdkr||j|S|j|S)N)rrcompress)r{rRrrrr\s
zLZMACompressor.compresscCs&|jdkr||jS|jS)N)rrflush)r{rrrras
zLZMACompressor.flushN)rrrr|rrrrrrrrPsrc@seZdZddZddZdS)LZMADecompressorcCsd|_d|_d|_dS)Nr*F)_decomp_unconsumedeof)r{rrrr|iszLZMADecompressor.__init__c	Cs|jdkr|j|7_t|jdkr*dStd|jdd\}t|jd|krXdStjtjttj	|jdd|gd|_|jd|d}|`|j
|}|jj|_|S)Nrr*z<Hr)r)rrr-rBr,rrrrr
decompressr)r{rRZpsizer?rrrrns

zLZMADecompressor.decompressN)rrrr|rrrrrrgsrZstoreZshrinkreduceZimplodetokenizeZdeflateZ	deflate64Zbzip2rZterseZlz77ZwavpackZppmd)rrrrrrr r!rr"r#rrr)abcCsX|tkr
nJ|tkr tsTtdn4|tkr6tsTtdn|tkrLtsTtdntddS)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)	rrzlibRuntimeErrorrbz2rrNotImplementedError)compressionrrr_check_compressionsrcCsj|tkr2|dk	r t|tjdSttjtjdS|tkrT|dk	rLt|StS|tkrbt	SdSdS)Ni)
rrZcompressobjZDEFLATEDZZ_DEFAULT_COMPRESSIONrrZ
BZ2Compressorrr)ra
compresslevelrrr_get_compressors
rcCsn|tkrdS|tkrtdS|tkr.tS|tkr<tSt	
|}|r\td||fntd|fdS)Nizcompression type %d (%s)zcompression type %d)rrrZ
decompressobjrrZBZ2Decompressorrrrrr)raZdescrrrr_get_decompressors

rc@s0eZdZddZdddZd
ddZd	d
ZdS)_SharedFilecCs2||_||_||_||_||_|j|_|j|_dS)N)_file_pos_close_lock_writingseekablerV)r{fileposcloselockZwritingrrrr|sz_SharedFile.__init__rc	CsB|j2|rtd|j|||j|_|jSQRXdS)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.)rrrwrr@rVr)r{rPwhencerrrr@sz_SharedFile.seekrc	CsL|j<|rtd|j|j|j|}|j|_|SQRXdS)NzyCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rrrwrr@rr:rV)r{nrRrrrr:sz_SharedFile.readcCs$|jdk	r |j}d|_||dS)N)rr)r{fileobjrrrrs
z_SharedFile.closeN)r)r)rrrr|r@r:rrrrrrs	


rc@s4eZdZddZddZddZddZd	d
ZdS)	_TellablecCs||_d|_dS)Nr)r8rP)r{r8rrrr|sz_Tellable.__init__cCs|j|}|j|7_|S)N)r8writerP)r{rRrrrrrsz_Tellable.writecCs|jS)N)rP)r{rrrrVsz_Tellable.tellcCs|jdS)N)r8r)r{rrrrsz_Tellable.flushcCs|jdS)N)r8r)r{rrrrsz_Tellable.closeN)rrrr|rrVrrrrrrrs
rcseZdZdZdZdZdZd&ddZd	d
Zd'dd
Z	d(ddZ
ddZd)ddZddZ
ddZddZddZfddZdd Zd*d"d#Zd$d%ZZS)+
ZipExtFilezZFile-like object for reading an archive member.
       Is returned by ZipFile.open().
    i@iiNFcCs||_||_||_|j|_|j|_|j|_t	|j|_
d|_d|_d|_
d|_|jdk	rf|jd8_||_|j|_t|dr|j|_td|_nd|_d|_y4|r||_|j|_|j|_|j|_d|_Wntk
rYnXdS)NFr*rrrkT)_fileobj
_decrypter_close_fileobjra_compress_typerl_compress_leftrm_leftr
_decompressor_eof_readbuffer_offsetnewlinesmoder>namer<rk
_expected_crcr_running_crc	_seekablerrV_orig_compress_start_orig_compress_size_orig_file_size_orig_start_crcAttributeError)r{rrzipinforZ
close_fileobjrrrr|s:



zZipExtFile.__init__cCsvd|jj|jjfg}|jsX|d|j|jf|jtkrb|dt	
|j|jn
|d|dd|S)Nz<%s.%sz name=%r mode=%rz compress_type=%sz	 [closed]r}r~)rrrclosedr.r	rrrrrr/)r{r?rrrr>s


zZipExtFile.__repr__rcCsL|dkr>|jd|jd}|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)rrrrioBufferedIOBasereadline)r{limitr3linerrrrLszZipExtFile.readlinercCsr|t|j|jkr\||}t||jkrJ||j|jd|_d|_n|jt|8_|j|j|jdS)z6Returns buffered bytes without advancing the position.Nri)r-rrr:)r{rchunkrrrpeek\s
zZipExtFile.peekcCsdS)NTr)r{rrrreadableiszZipExtFile.readablecCs|dks|dkrL|j|jd}d|_d|_x|jsF|||j7}q.W|S||j}|t|jkr~|j|j|}||_|S|t|j}|j|jd}d|_d|_x^|dkr|js||}|t|kr||_||_||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..
        Nrr*)rrr_read1MAX_Nr-)r{rbufendrRrrrr:ls4

zZipExtFile.readcCs@|jdkrdSt||j|_|jr<|j|jkr<td|jdS)NzBad CRC-32 for file %r)r
rrrrr	)r{newdatarrr_update_crcs

zZipExtFile._update_crccCs|dks|dkrV|j|jd}d|_d|_x$|jsP||j}|r.||7}Pq.W|S||j}|t|jkr|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkrxN|js
||}|t|kr||_||_||d|7}P|r||7}PqW|S)z7Read up to n bytes with at most one read() system call.Nrr*)rrrrrr-)r{rrrRr rrrread1s>



zZipExtFile.read1cCs"|js|dkrdS|jtkrH|jj}|t|krR|||t|7}n
||}|jtkrj|jdk|_nx|jtkrt	||j
}|j||}|jjp|jdko|jj|_|jr||j
7}n |j|}|jjp|jdk|_|d|j}|jt|8_|jdkrd|_|||S)Nrr*T)rrrrZunconsumed_tailr-_read2rrr[
MIN_READ_SIZErrrrr")r{rrRrrrrs2





zZipExtFile._read1cCsd|jdkrdSt||j}t||j}|j|}|jt|8_|sLt|jdk	r`||}|S)Nrr*)	rr[r%minrr:r-EOFErrorr)r{rrRrrrr$s


zZipExtFile._read2cs&z|jr|jWdtXdS)N)rrrsuper)r{)rrrrszZipExtFile.closecCs|jS)N)r)r{rrrrszZipExtFile.seekablercCs*|jstd|}|dkr&|}n.|dkr8||}n|dkrL|j|}ntd||jkrd|j}|dkrpd}||}||j}|dkr|t|jkr||_d}nP|dkr|j	
|j|j|_
|j|_|j|_d|_d|_t|j|_d|_|}x,|dkr t|j|}||||8}qW|S)Nz!underlying stream is not seekablerrrzCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r*F)rrUnsupportedOperationrVrrwrr-rrr@r
rrrrrrrrrr&
MAX_SEEK_READr:)r{rPrZcurr_posZnew_posZread_offsetZbuff_offsetZread_lenrrrr@sD




zZipExtFile.seekcCs0|jstd|j|jt|j|j}|S)Nz!underlying stream is not seekable)rrr)rrr-rr)r{ZfileposrrrrV(s
zZipExtFile.tell)NF)r)r)r)r)rrrrrr%r*r|rrrrr:r"r#rr$rrr@rV
__classcell__rr)rrrs&
*



!
%$
.rcs@eZdZddZeddZddZddZfd	d
ZZ	S)
_ZipWriteFilecCs8||_||_||_t|j|j|_d|_d|_d|_	dS)Nr)
_zinfo_zip64_zipfilerrarb_compressor
_file_size_compress_size_crc)r{zfrrrrrr|0s
z_ZipWriteFile.__init__cCs|jjS)N)r/r8)r{rrrr:sz_ZipWriteFile._fileobjcCsdS)NTr)r{rrrwritable>sz_ZipWriteFile.writablecCsf|jrtdt|}|j|7_t||j|_|jrV|j|}|jt|7_|j	
||S)NzI/O operation on closed file.)rrwr-r1rr3r0rr2rr)r{rRnbytesrrrrAsz_ZipWriteFile.writec	sX|jr
dSt|jrN|j}|jt|7_|j||j|j	_
n
|j|j	_
|j|j	_
|j|j	_|j	jd@r|jrdnd}|jt|t|j	j
|j	j
|j	j|j|j_nn|js|jtkrtd|jtkrtd|j|j_|j|j	j|j|j	|j|j|jjd|j_|jj|j	|j	|jj|j	j <dS)Nrz<LLQQz<LLLLz+File size unexpectedly exceeded ZIP64 limitz1Compressed size unexpectedly exceeded ZIP64 limitF)!rr(rr0rr2r-rrr-rlr1r3rkrmrfr.rBr
_DD_SIGNATURErVr/	start_dirrrr@rjrrfilelistr.
NameToInfor>)r{rr)rrrrMs8






z_ZipWriteFile.close)
rrrr|propertyrr5rrr+rr)rrr,/s

r,c@seZdZdZdZdZdeddfddZddZd	d
Z	ddZ
d
dZddZddZ
d<ddZddZddZddZeddZejddZd=ddZd>d d!d"d#Zd?d$d%Zd@d&d'ZdAd(d)Zed*d+Zd,d-Zd.d/ZdBd0d1ZdCd2d3Zd4d5Z d6d7Z!d8d9Z"d:d;Z#dS)Drai 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.

    NrTc		CsL|dkrtdt|||_d|_d|_i|_g|_||_||_||_	d|_
d|_t|t
jrjt
|}t|trd|_||_ddd	d
dddd
}||}x^yt|||_Wn(tk
r||kr||}wYnXPqWnd|_||_t|dd|_d|_t|_d|_d|_y|dkr0|n|dkrd|_y|j|_ Wn2t!tfk
rt"|j|_d|_ d|_Yn6Xy|j#|j Wn t!tfk
rd|_YnXnf|dkry||j#|j Wn6t$k
r|j#ddd|_|j|_ YnXntdWn$|j}d|_|%|YnXdS)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
        or append 'a'.)r<wxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNr*r;zw+bzx+bzr+bwbZxb)r<r=r>r?zr+bzw+bzx+brr	Tr<)r=r>r?rz"Mode must be 'r', 'w', 'x', or 'a')&rwr_allowZip64
_didModifydebugr:r9rrrr_commentrrtrrstr_filePassedr>rr=r8r7getattr_fileRefCnt	threadingRLockrrr_RealGetContentsrVr8rrr@r_fpclose)	r{rrr
allowZip64rZmodeDictrr8rrrr|s







zZipFile.__init__cCs|S)Nr)r{rrr	__enter__szZipFile.__enter__cCs|dS)N)r)r{typevalue	tracebackrrr__exit__szZipFile.__exit__cCsd|jj|jjfg}|jdk	rd|jr8|d|jn|jdk	rR|d|j|d|jn
|d|dd|S)Nz<%s.%sz file=%rz filename=%rz mode=%rz	 [closed]r}r~)	rrrr8rFr.r>rr/)r{r?rrrrs



zZipFile.__repr__cCs|j}yt|}Wntk
r.tdYnX|s<td|jdkrNt||t}|t}|t|_	|t
||}|ttkr|t
t8}|jdkr||}td||||||_||jd||}t|}d}x||kr|t}	t|	tkrtdtt|	}	|	ttkr0td|jdkrDt|	||	t}
|	d}|d	@rp|
d
}
n
|
d}
t|
}||	t|_||	t |_!|	t"|_#|	dd\|_$|_%|_&|_'|_(|_)}
}|_*|_+|_,|j&t-krt.d
|j&d|	dd\|_/|_0|_1|
|_2|d?d|d?d@|d@|
d?|
d?d@|
d@df|_3|4|j#||_#|j56|||j7|j8<|t|	t|	t|	t }|jdkrtd|qWdS)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 directoryrizutf-8cp437rzzip file version %.1fr#r&r)r"ir$rtotalN)9r8r6r7rrCprintrMrN_ECD_COMMENTrD
_ECD_LOCATIONrHrGrErAr8r@r:rBytesIOsizeCentralDirr-rBr,structCentralDir
_CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHdecoder
_CD_EXTRA_FIELD_LENGTHr0_CD_COMMENT_LENGTHr^_CD_LOCAL_HEADER_OFFSETrjrSrcrdrerfrarkrlrmMAX_EXTRACT_VERSIONrrgrhrirnr`rr9r.r:r>)r{r8rQZsize_cdZ	offset_cdconcatZinferredrRrUcentdirr>flagsr>tdrrrrKsp









4  
zZipFile._RealGetContentscCsdd|jDS)z+Return a list of file names in the archive.cSsg|]
}|jqSr)r>).0rRrrr
<listcomp>Qsz$ZipFile.namelist.<locals>.<listcomp>)r9)r{rrrnamelistOszZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the
        archive.)r9)r{rrrinfolistSszZipFile.infolistcCsPtdd|dx:|jD]0}d|jdd}td|j||jf|dqWdS)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)rVr9r`r>rm)r{rrZdaterrrprintdirXszZipFile.printdirc
Cs^d}xT|jD]J}y.||jd}x||r0q$WWdQRXWqtk
rT|jSXqWdS)z%Read all the files and check the CRC.ir<N)r9r=r>r:r)r{Z
chunk_sizerfrrrtestzipas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:rKeyError)r{r	inforrrgetinfons

zZipFile.getinfocCs6|r t|ts tdt|j|r,||_nd|_dS)z)Set default password for encrypted files.zpwd: expected bytes, got %sN)rr	TypeErrorrOrr)r{rrrrsetpasswordws
zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)rD)r{rrrr^szZipFile.commentcCs^t|tstdt|jt|tkrNddl}|jdtdd|dt}||_	d|_
dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr)
stacklevelT)rrrsrOrr-ZIP_MAX_COMMENTwarningswarnrDrB)r{r^rwrrrr^s
c	Cs"||d|
}|SQRXdS)zReturn file bytes for name.r<N)r=r:)r{r	rr8rrrr:szZipFile.readF)force_zip64csv|dkrtd|r0t|ts0tdt|j|rD|dkrDtdjsRtdt|trb|}n,|dkrt|}j|_	j
|_n
|}|dkrj
||dSjrtdjd	7_tj|jjjfd
d}yx|t}t|tkrtdtt|}|ttkr&td
||t}|trL||t|jd@r`t d|jd@rtt d|jd@r|!d}	n
|!d}	|	|j"krtd|j"|f|jd	@}
d}|
rL|sԈj#}|st$d|t%|}|d}||dd}
|jd@r$|j&d?d@}n|j'd?d@}|
d|krLt$d|t(||||dS|)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"zpwd: expected bytes, got %sr=z'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closed)ryzyCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.rcsjS)N)rr)r{rr<lambda>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)izutf-8rSz/File name in directory %r and header %r differ.Nz6File %r is encrypted, password required for extractionrrrrrr$zBad password for file %rT)*rwrrrsrOrr8r
rrarrbrr_open_to_writerrHrrjrLrr:sizeFileHeaderr-rrBr,r
_FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrfrr_r_rrrrnrkrr)r{r	rrryrZzef_fileZfheaderfnameZ	fname_strZis_encryptedZzdrhZ
check_byter)r{rr=s








zZipFile.opencCs|r|jstd|jr tdt|ds0d|_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.rmrrrig?T)rArwrr<rmrlrkrfrarrrirr8r@r8rVrj_writecheckrBrrr,)r{rryrrrrr}	s4



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)rtgetcwdr_extract_member)r{memberrrrrrextract4s

zZipFile.extractcCsL|dkr|}|dkr"t}n
t|}x|D]}||||q2WdS)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)rkrtrrr)r{rmembersrrrrr
extractallAs


zZipFile.extractallcCs^|j}|s(d}t|dt|}||_||}dd||D}|dd|D}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*_css|]}|dVqdS).N)rstrip)rir>rrr	<genexpr>\sz1ZipFile._sanitize_windows_name.<locals>.<genexpr>css|]}|r|VqdS)Nr)rir>rrrr^s)!_windows_illegal_name_trans_tablerE	maketransr-	translatesplitr/)rrpathseptableZillegalrrr_sanitize_windows_nameRs
zZipFile._sanitize_windows_namec
sLt|ts||}|jdtjj}tjjrB|tjjtjj}tj	|d}dtjj
tjjftjjfdd|
tjjD}tjjdkr||tjj}tj||}tj|}tj|}|rtj|st||rtj|st||S|j||d(}t|d}t||Wd	QRXWd	QRX|S)
zbExtract the ZipInfo object 'member' to a physical
           file on the path targetpath.
        rqrr~c3s|]}|kr|VqdS)Nr)rir>)invalid_path_partsrrrrsz*ZipFile._extract_member.<locals>.<genexpr>\)rr@N)rr
rrr>rvrtrrurrcurdirpardirr/rrrdirnameexistsmakedirsrrmkdirr=shutilcopyfileobj)r{rZ
targetpathrrZ	upperdirssourcetargetr)rrras.

&


 zZipFile._extract_membercCs|j|jkr(ddl}|jd|jdd|jdkr:td|jsHtdt|j|j	sd}t
|jtkrpd	}n|j
tkrd
}n|jtkrd}|rt|ddS)
z6Check for errors before writing a file to the archive.rNzDuplicate name: %rr)ru)r=r>r?z&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedzFiles countZFilesizezZipfile sizez would require ZIP64 extensions)r>r:rwrxrrwr8rrarAr-r9ZIP_FILECOUNT_LIMITrmrrjr
)r{rrwrequires_zip64rrrrs(



zZipFile._writecheckc
CsJ|jstd|jrtdt||}|r>d|_d|_n0|dk	rN||_n|j	|_|dk	rf||_
n|j|_
|r
|j|j
r|j|j|j|_|jtkr|jdO_||d|_|j|||j|j<|j|d|j|_WdQRXn<t|d,}||d	}t||d
WdQRXWdQRXdS)zLPut the bytes from filename into the archive under the name
        arcname.z7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsrNrTFr;r=i )r8rwrr
rrrlrkrarrbrrrr@r8rVrjrrfrrBr9r.r:r>rrr=rr)r{r>rrarrsrcdestrrrrs>


z
ZipFile.writec
Cst|tr|d}t|tsxt|ttddd}|j|_|j|_	|j
ddkrpd|_|jdO_q|d	|_n|}|jst
d
|jrt
d|dk	r||_|dk	r||_	t||_|j*|j|dd
}||WdQRXWdQRXdS)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-8Nr )r>r`rrqiAr'iz7Attempt to write to ZIP archive that was already closedz?Can't write to ZIP archive while an open writing handle exists.r=)r)rrErr
rrrrarrbr>rir8rwrr-rmrr=r)r{Zzinfo_or_arcnamerRrarrrrrrwritestrs4



zZipFile.writestrcCs|dS)z2Call the "close()" method in case the user forgot.N)r)r{rrr__del__szZipFile.__del__c	Cs||jdkrdS|jrtdzB|jdkr\|jr\|j"|jrJ|j|j|	WdQRXWd|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>r?)r8rrwrrBrrr@r8_write_end_recordrL)r{r8rrrrs
z
ZipFile.closecCsrxP|jD]D}|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}g}|jtksv|jtkr||j||jd
}d
}n|j}|j}|jtkr||jd
}n|j}|j}	d}
|rt|	d}	t	j
dd
t|ddt|f||	}	t}
|j
tkr(tt|
}
n|j
tkr>tt|
}
t|
|j}t|
|j}yZ|\}
}t	
tt||j||j||j
|||j||t|
t|	t|jd|j|j|}Wnltk
rttt||j||j|j |j
|||j||t|j!t|	t|jd|j|j|ft"j#dYnX|j$%||j$%|
|j$%|	|j$%|jq
W|j$&}t|j}||j'}|j'}d}|t(krd}n|tkrd}n|tkrd}|r*|j)st*|dt	
t+t,ddddd||||}|j$%|t	
t-t.d|d}|j$%|t/|d}t/|d
}t/|d
}t	
t0t1dd||||t|j2	}|j$%||j$%|j2|j$3dS)Nrir"rrrrr$rl)rz<HHQr)rzFiles countzCentral directory offsetzCentral directory sizez would require ZIP64 extensions,ri)4r9r`rmrrlr.rjr0r5rBrr-rrarr[rrrrdrSrr[r]rcrerkr^rhriDeprecationWarningrVrfr>rxstderrr8rrVr8rrAr
rFrGrCrDr&rYrXrDr)r{rrrrr0rmrlrjZ
extra_datarrdrSr>rfreZpos2ZcentDirCountZcentDirSizeZ
centDirOffsetrZzip64endrecZzip64locrecrQrrrrs$$



















zZipFile._write_end_recordcCs4|jdkst|jd8_|js0|js0|dS)Nrr)rHAssertionErrorrFr)r{r8rrrrL{szZipFile._fpclose)N)N)r<N)F)NN)NNN)NNN)NN)$rrrrr8rrr|rNrRrrKrkrlrmrorrrtr;r^setterr:r=r}rrrrrrrrrrrrLrrrrrzs@XN
	
		
r
+

*
0
(fc@s4eZdZdZdeddfddZd
d	d
ZddZdS)rzDClass to create ZIP archives with Python library files and packages.r<TrcCstj|||||d||_dS)N)rrrM)rr|	_optimize)r{rrrrMoptimizerrrr|szPyZipFile.__init__r~NcCst|}|rD||sD|jr@tj|r,dnd}td||fdStj|\}}tj|rptj|d}tj|r|rd||f}n|}|jrtd|d||	|d	d
|\}}	|jrtd|	|
||	tt|}
|

dx|
D]}tj||}tj|\}
}tj|rTtjtj|dr|j|||dq|d
kr|r||s|jrtd|q|	|d	d
|\}}	|jrtd|	|
||	qWn|jrtd|xtt|D]}tj||}tj|\}
}|d
kr|r2||s2|jrtd|q|	|d	d
|\}}	|jr\td|	|
||	qWnP|d
dd
krtd|	|d	d
|\}}	|jrtd|	|
||	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.
        rrz%s %r skipped by filterfuncNz__init__.pyz%s/%szAdding package inasrZAdding)
filterfuncz.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding file)rtrrCrrrVrr/isfile
_get_codenamersortedlistdirremovesplitextwritepyr)r{pathnamebasenamerZlabeldirr	ZinitnamerrZdirlistr>rrootZextrrrrsx











zPyZipFile.writepyc
sdfdd	}|d}|d}tjj|dd}tjj|dd}tjj|d	d}jdkr\tj|rt|jt|jkr|}	}
ntj|rt|jt|jkr|}
|}	ntj|rt|jt|jkr|}
|}	nvtj|rt|jt|jkr|}
|}	nD||rRt	j
jd
kr4|}
nt	j
jdkrH|}
n|}
|}	n|}
}	njd
krr|}
|}	n<|}	jdkr|}
n&jd	kr|}
ndj}t
|tj|
rt|
jt|jks||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).
        rc
s`ddl}jrtd|y|j|d|dWn.|jk
rZ}zt|jdSd}~XYnXdS)NrZ	CompilingT)doraiserF)
py_compilerCrVcompilePyCompileErrormsg)rrrerr)r{rr_compiles

z)PyZipFile._get_codename.<locals>._compilez.pyz.pycr~)optimizationrrrz"invalid value for 'optimize': {!r})rz%s/%s)r)	importlibutilcache_from_sourcerrtrrrrrxrfrformatrwr)
r{rrrZfile_pyZfile_pycZpycache_opt0Zpycache_opt1Zpycache_opt2rrrZarchivenamer)r{rrs`


zPyZipFile._get_codename)r~N)rrrrrr|rrrrrrrs

Rc
	sddl}d}|j|d}|jdd}|jdddd	d
|jddd
ddd|jdddddd|jddddd
||}|jdk	r|j}t|d}|}WdQRX|rtd	|tdn|j
dk	r|j
}t|d}|WdQRXn|jdk	r.|j\}}t|d}|
|WdQRXn|jdk	r|jd}	|j}
fddt|	d`}xX|
D]P}tj|}|stjtj|}|dtjtjfkrd}|||qjWWdQRXdS) Nrz3A simple command-line interface for zipfile module.)descriptionT)Zrequiredz-lz--listz	<zipfile>zShow listing of a zipfile)metavarhelpz-ez	--extractr)z	<zipfile>z<output_dir>zExtract zipfile into target dir)nargsrrz-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 testingcsttj|r|||tnTtj|rp|r8|||x6tt|D]$}|tj||tj||qHWdS)N)	rtrrrrrrrr/)r4rzippathZnm)addToZiprrrXszmain.<locals>.addToZipr=r~)argparseArgumentParserZadd_mutually_exclusive_groupadd_argument
parse_argsZtestrrorVrrZrmrrZcreatepoprtrrrrr)
argsrrparsergrouprr4ZbadfilerZzip_nameZfilesrrr)rrmain0sT








r__main__)N)N)rrrtimportlib.utilrrxrrrrBZbinasciirIrrImportErrorrr__all__	Exceptionrr
rrrrrvrrrrrzrrrrcrYrXrrWrHrIrJrKrLrMrNr]rWrXr[r]rZr\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`raZ_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESrbrrr~rZ_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_SIZErrrCrDrArFrGrEZ_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_CENTDIRr7ZStructr+r5r9r	rTr6objectr
rrrrrrrrrrrrrr,rrrrrrrr<module>s@









+=a&
&,K/
<