�`^c @s9dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZyddlZej
Z
Wn ek
r�eZej
Z
nXddddddd d
dg Zdefd��YZdefd
��YZeZdd>dZdd>Zdd>dZdZdZdZdZeje�ZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)eje(�Z*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6d Z7d!Z8d"Z9d#Z:dZ;d$Z<d%Z=d&Z>d'Z?eje>�Z@dZAdZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdZLd(ZMd)ZNejeM�ZOd*ZPd+ZQejeP�ZRdZSdZTdZUdZVdZWdZXdZYdZZdZ[dZ\d,�Z]d-�Z^d.�Z_d/�Z`deafd0��YZbd1fd2��YZcid3d6d4d6d5d6d5d6d5d6d5d6d6d6d7d6d8d6d9d6d6d6d:d 6d;d"6d<d%6d=d>6d?d@6dAdB6ZddCe jefdD��YZfd eafdE��YZgd
egfdF��YZhedG�ZiejdHkr5ei�ndS(Is
Read and write ZIP files.
i�Nt
BadZipfileterrort
ZIP_STOREDtZIP_DEFLATEDt
is_zipfiletZipInfotZipFilet PyZipFiletLargeZipFilecBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/zipfile.pyRscBseZdZRS(su
Raised when writing a zipfile, the zipfile requires ZIP64 extensions
and those extensions are disabled.
(R R
t__doc__(((s/sys/lib/python2.7/zipfile.pyRsiiiiis<4s4H2LHsPKiiiiiii s<4s4B4HL2L5H2LsPKi
iii
iiiis<4s2B4HL2L2HsPKs<4sLQLsPKs
<4sQ2H2L4QsPKcCs,yt|�rtSWntk
r'nXtS(N(t_EndRecDatatTruetIOErrortFalse(tfp((s/sys/lib/python2.7/zipfile.pyt_check_zipfile�s
cCsgt}yIt|d�r*td|�}n$t|d��}t|�}WdQXWntk
rbnX|S(s�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.
treadRtrbN(RthasattrRtopenR(tfilenametresultR((s/sys/lib/python2.7/zipfile.pyR�s
c
Csny|j|td�Wntk
r,|SX|jt�}t|�tkrR|Stjt|�\}}}}|tkr�|S|dks�|dkr�t d��n|j|tt
d�|jt
�}t|�t
kr�Stjt|�\
}}} }
}}}
}}}|tkr$|S||t
<||t<||t<|
|t<||t<||t<||t<|S(sM
Read the ZIP64 end-of-archive records and use that to update endrec
iiis3zipfiles that span multiple disks are not supported(tseektsizeEndCentDir64LocatorRRtlentstructtunpacktstructEndArchive64LocatortstringEndArchive64LocatorRtsizeEndCentDir64tstructEndArchive64tstringEndArchive64t_ECD_SIGNATUREt_ECD_DISK_NUMBERt_ECD_DISK_STARTt_ECD_ENTRIES_THIS_DISKt_ECD_ENTRIES_TOTALt _ECD_SIZEt_ECD_OFFSET(tfpintoffsettendrectdatatsigtdisknotrelofftdiskstsztcreate_versiontread_versiontdisk_numtdisk_dirtdircountt dircount2tdirsizet diroffset((s/sys/lib/python2.7/zipfile.pyt
_EndRecData64�s6
0
c Cs�|jdd�|j�}y|jtd�Wntk
rEd SX|j�}t|�tkr�|dd!tkr�|ddkr�tj t
|�}t|�}|jd�|j|t�t
|t|�St|d
td�}|j|d�|j�}|jt�}|dkr�|||t!}t|�tkrId Sttj t
|��}|t}||t|t|!}|j|�|j||�t
|||||�Sd S(s�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.iiii�ttiiNi(RttelltsizeEndCentDirRtNoneRRtstringEndArchiveRRtstructEndArchivetlisttappendR:tmaxtrfindt_ECD_COMMENT_SIZE( R)tfilesizeR,R+tmaxCommentStarttstarttrecDatatcommentSizetcomment((s/sys/lib/python2.7/zipfile.pyR�s>
cBsJeZdZdZddd�Zdd�Zd�Zd�Zd�Z RS( s>Class with attributes describing each file in the ZIP archive.t
orig_filenameRt date_timet
compress_typeRLtextrat
create_systemR2textract_versiontreservedt flag_bitstvolumet
internal_attrt
external_attrt
header_offsettCRCt
compress_sizet file_sizet _raw_timetNoNamei�iicCs#||_|jtd��}|dkr:|d|!}ntjdkrptj|krp|jtjd�}n||_||_|ddkr�td��nt |_
d|_d|_t
jdkr�d|_n d|_d|_d|_d|_d|_d|_d|_d|_dS( Nit/i�s+ZIP does not support timestamps before 1980R<twin32ii(RMtfindtchrtostseptreplaceRRNt
ValueErrorRRORLRPtsystplatformRQR2RRRSRTRURVRW(tselfRRNt null_byte((s/sys/lib/python2.7/zipfile.pyt__init__s. c
Cs�|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd
@rsd}}}n|j}|j}|j}|j}|dkr�|tkp�|tk}n|r�} |tj | dtj
| �d ||�}n|tks|tkr_|s&td��nd
}d
}td|j
�|_
td|j
�|_n|j�\}
}tj tt|j
|j||j|||||t|
�t|��}||
|S(s'Return the per-file header as a string.ii�i iiiiiiis<HHQQs'Filesize would require ZIP64 extensionsl�i-N(RNRTRYRZR[RPR?tZIP64_LIMITRtpacktcalcsizeRRDRRR2t_encodeFilenameFlagststructFileHeadertstringFileHeaderRSROR(
Rhtzip64tdttdosdatetdostimeRYRZR[RPtfmtRRTtheader((s/sys/lib/python2.7/zipfile.pyt
FileHeaderIs: &&
#cCstt|jt�r`y|jjd�|jfSWqptk
r\|jjd�|jdBfSXn|j|jfSdS(Ntasciisutf-8i(t
isinstanceRtunicodetencodeRTtUnicodeEncodeError(Rh((s/sys/lib/python2.7/zipfile.pyRnps
!cCs(|jd@r|jjd�S|jSdS(Nisutf-8(RTRtdecode(Rh((s/sys/lib/python2.7/zipfile.pyt_decodeFilenameys
cCs�|j}tj}xjt|�dkr~|d|d �\}}|dkrm|dkrq|d|dd!�}no|dkr�|d|dd !�}nJ|d
kr�|d|dd!�}n%|d
kr�d}ntd|f�d
}|jdkr|||_|d7}n|jdkr8|||_|d7}n|jdkrm|j}|||_|d7}qmn||d}qWdS(Nis<HHiis<QQQiis<QQiis<QiisCorrupt extra field %sl��l�((l��l�(RPRRRtRuntimeErrorR[RZRX(RhRPRttptlntcountstidxtold((s/sys/lib/python2.7/zipfile.pyt_decodeExtras4
(s
orig_filenamesfilenames date_times
compress_typescommentsextras
create_systemscreate_versionsextract_versionsreserveds flag_bitssvolumes
internal_attrs
external_attrs
header_offsetsCRCs
compress_sizes file_sizes _raw_time(i�iiiiiN(
R R
Rt __slots__RjR?RwRnR~R�(((s/sys/lib/python2.7/zipfile.pyRs2*' t
_ZipDecryptercBsDeZdZd�Ze�Zd�Zd�Zd�Zd�ZRS(sClass 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)
cCs�d}dgd}xhtd�D]Z}|}xAtd�D]3}|d@r^|d?d@|A}q9|d?d@}q9W|||<q W|S(s�Generate 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[iiiii�(trange(tpolyttabletitcrctj((s/sys/lib/python2.7/zipfile.pyt_GenerateCRCTable�s
cCs%|d?d@|j|t|�Ad@AS(s(Compute the CRC32 primitive on one byte.ii�i�(tcrctabletord(RhtchR�((s/sys/lib/python2.7/zipfile.pyt_crc32�scCs=d|_d|_d|_x|D]}|j|�q"WdS(NixV4i�E#i�V4(tkey0tkey1tkey2t_UpdateKeys(Rhtpwdtp((s/sys/lib/python2.7/zipfile.pyRj�s
cCsx|j||j�|_|j|jd@d@|_|jddd@|_|jt|jd?d@�|j�|_dS(Ni�l�i�ii(R�R�R�RaR�(Rhtc((s/sys/lib/python2.7/zipfile.pyR��scCsPt|�}|jdB}|||dAd?d@A}t|�}|j|�|S(sDecrypt a single character.iiii�(R�R�RaR�(RhR�tk((s/sys/lib/python2.7/zipfile.pyt__call__�s
( R R
RR�R�R�RjR�R�(((s/sys/lib/python2.7/zipfile.pyR��s tstoretshrinktreducetimplodettokenizetdeflatet deflate64tbzip2tlzmattersetlz77itwavpackiatppmdibt
ZipExtFilecBs�eZdZdd>ZdZejd�Zde d�Z
dd�Zdd�Zd �Z
dd
�Zd�Zd�Zd
�ZRS(sZFile-like object for reading an archive member.
Is returned by ZipFile.open().
iiis*^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)cCsf||_||_||_|j|_|j|_|j|_|jtkrct j
d�|_n\|jtkr�t
j|j�}|r�td|j|f��q�td|jf��nd|_d|_d|_d|k|_d|_|jdk r|jd8_n||_|j|_t|d�rY|j|_td�d @|_n d|_dS(
Ni�scompression type %d (%s)scompression type %dR<itUiRYl�(t_fileobjt
_decryptert_close_fileobjROt_compress_typeRZt_compress_sizet_compress_leftRtzlibt
decompressobjt
_decompressorRtcompressor_namestgettNotImplementedErrort_unconsumedt_readbuffert_offsett
_universalR?tnewlinestmodeRtnameRRYt
_expected_crctcrc32t_running_crc(RhtfileobjR�tzipinfot decryptert
close_fileobjtdescr((s/sys/lib/python2.7/zipfile.pyRjs4 i�cCs�|jra|dkra|jjd|j�d}|dkra|j|j|!}||_|Sn|js}tjj||�Sd}x|dks�t|�|kr�|jd�}|dkr�|S|j j
|�}|jd�}|dk rJ|j
dkrg|_
n||j
kr-|j
j|�n|jt|�7_|dS|jd�}|dkr|||t|� }n|jt|�7_||7}q�W|S( srRead and return a line from the stream.
If limit is specified, at most limit bytes will be read.
is
iR<itnewlinetchunkN(R�R�R`R�tiotBufferedIOBasetreadlineRtpeektPATTERNtsearchtgroupR?R�RC(RhtlimitR�tlinet readaheadtmatchR�R�((s/sys/lib/python2.7/zipfile.pyR�+s8 !
cCs�|t|j�|jkr{|j|�}t|�|jkrc||j|j|_d|_q{|jt|�8_n|j|j|jd!S(s6Returns buffered bytes without advancing the position.ii(RR�R�R(RhtnR�((s/sys/lib/python2.7/zipfile.pyR�]scCstS(N(R
(Rh((s/sys/lib/python2.7/zipfile.pytreadablejscCs�d}|dkrd}nxztr�|dkrB|j|�}n2|t|�krp|j|t|��}n|St|�dkr�|S||7}qWdS(s�Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
R<i�iN(R?R
tread1R(RhR�tbufR,((s/sys/lib/python2.7/zipfile.pyRms cCs^|jdkrdSt||j�d@|_|rZ|j|jkrZtd|j��ndS(Nl�sBad CRC-32 for file %r(R�R?R�R�RR�(Rhtnewdatateof((s/sys/lib/python2.7/zipfile.pyt_update_crcs
cCsg|dks|dkr$|j}nt|j�|j}|jdkrW||t|j�krW||t|j�}t||j�}t ||j�}|j
j|�}|jt|�8_|r�jdk r�j
t|j|��}n|jtkrE|j|d|jdk�|j|j||_d|_qW|j|7_nt|j�dkr4||kr4|jtkr4|jj|jt|||j��}|jj|_t|j�dko�|jdk}|r�|jj�7}n|j|d|�|j|j||_d|_n|j|j|j|!}|jt|�7_|S(s7Read up to n bytes with at most one read() system call.iR<R�N(R?tMAX_NRR�R�R�R�RDt
MIN_READ_SIZEtminR�RR�tjointmapR�RR�RR�t
decompresstunconsumed_tailtflush(RhR�tlen_readbuffertnbytesR,R�((s/sys/lib/python2.7/zipfile.pyR��s>(! $cCs8z|jr|jj�nWdtt|�j�XdS(N(R�R�tclosetsuperR�(Rh((s/sys/lib/python2.7/zipfile.pyR��s iN(R R
RR�R�tretcompileR�R?RRjR�R�R�RR�R�R�(((s/sys/lib/python2.7/zipfile.pyR��s
'2
4cBseZdZdZdeed�Zd�Zd�Z d�Z
d�Zd�Zd�Z
d �Zd
�Zd�Zed��Zejd
��Zdd�Zddd�Zddd�Zdddd�Zd�Zd�Zddd�Zdd�Zd�Zd�ZRS(sd Class with methods to open, read, write, close, list zip files.
z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=False)
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" or append "a".
compression: ZIP_STORED (no compression) or ZIP_DEFLATED (requires zlib).
allowZip64: if True ZipFile will create files with ZIP64 extensions when
needed, otherwise it will raise an exception when this would
be necessary.
trcCs\|dkrtd��n|tkr*n*|tkrKtsTtd�qTn td�||_t|_d|_i|_g|_ ||_
|jdd �d|_}d|_d |_t|t�rXd|_||_id
d6dd6dd6}yt|||�|_Wqtk
rT|dkrNd}}t|||�|_qU�qXn'd
|_||_t|dd�|_y�|dkr�|j�n�|dkr�t|_no|dkry$|j�|jj|jd�Wq"tk
r|jjdd�t|_q"Xntd��Wn2|j}d|_|jsQ|j�n�nXdS(s>Open the ZIP file with mode read "r", write "w" or append "a".R�twtas(ZipFile() requires mode "r", "w", or "a"s.Compression requires the (missing) zlib modules(That compression method is not supporteditbR<Rtwbsr+biR�isMode must be "r", "w" or "a"N(R�R�R�(RRRR�t_allowZip64Rt
_didModifytdebugt
NameToInfotfilelisttcompressionRdR�R?R�t_commentRyt
basestringt_filePassedRRRRtgetattrt_RealGetContentsR
Rt start_dirRR�(RhtfileR�R�t
allowZip64tkeytmodeDictR((s/sys/lib/python2.7/zipfile.pyRj�sf
cCs|S(N((Rh((s/sys/lib/python2.7/zipfile.pyt __enter__scCs|j�dS(N(R�(Rhttypetvaluet traceback((s/sys/lib/python2.7/zipfile.pyt__exit__ scCsH|j}yt|�}Wntk
r8td��nX|sKtd�n|jdkrb|GHn|t}|t}|t|_|t ||}|t
tkr�|tt
8}n|jdkr�|}dG|G|G|GHn|||_|j|jd�|j|�}tj|�}d}x||krC|jt�} t| �tkrftd��ntjt| �} | ttkr�td��n|jdkr�| GHn|j| t�}
t|
�}|j| t�|_|j| t�|_| t |_!| dd!\|_"|_#|_$|_%|_&|_'}}
|_(|_)|_*| d d
!\|_+|_,|_-||_.|
d?d|
d
?d @|
d@|d?|d
?d@|d@df|_/|j0�|j!||_!|j1�|_2|j3j4|�||j5|j2<|t| t| t| t}|jdkr*dG|GHq*q*WdS(s/Read in the table of contents for the ZIP file.sFile is not a zip fileiisgiven, inferred, offsetisTruncated central directorys&Bad magic number for central directoryiiii i�iiii?ttotalN(6RRRRR�R'R(t_ECD_COMMENTR�t
_ECD_LOCATIONR"R!RRR�RRt cStringIOtStringIOtsizeCentralDirRRRtstructCentralDirt
_CD_SIGNATUREtstringCentralDirt_CD_FILENAME_LENGTHRt_CD_EXTRA_FIELD_LENGTHRPt_CD_COMMENT_LENGTHRLt_CD_LOCAL_HEADER_OFFSETRXR2RQRRRSRTRORYRZR[RURVRWR\RNR�R~RR�RCR�(RhRR+tsize_cdt offset_cdtconcattinferredR,RtcentdirRtxtttd((s/sys/lib/python2.7/zipfile.pyR�#sd
I &
"cCs.g}x!|jD]}|j|j�qW|S(s+Return a list of file names in the archive.(R�RCR(RhtlR,((s/sys/lib/python2.7/zipfile.pytnamelisthscCs|jS(sJReturn a list of class ZipInfo instances for files in the
archive.(R�(Rh((s/sys/lib/python2.7/zipfile.pytinfolistoscCsJdd GHx:|jD]/}d|jd }d|j||jfGHqWdS(
s+Print a table of contents for the zip file.s%-46s %19s %12ss File NamesModified tSizes%d-%02d-%02d %02d:%02d:%02dis
%-46s %s %12dN(s File NamesModified R(R�RNRR[(Rhtzinfotdate((s/sys/lib/python2.7/zipfile.pytprintdirts cCsnd}xa|jD]V}y8|j|jd��}x|j|�rFq4WWdQXWqtk
re|jSXqWdS(s%Read all the files and check the CRC.iiR�Ni(R�RRRR(Rht
chunk_sizeRtf((s/sys/lib/python2.7/zipfile.pyttestzip{s
cCs5|jj|�}|dkr1td|��n|S(s,Return the instance of ZipInfo given 'name'.s(There is no item named %r in the archiveN(R�R�R?tKeyError(RhR�tinfo((s/sys/lib/python2.7/zipfile.pytgetinfo�s
cCs
||_dS(s)Set default password for encrypted files.N(R�(RhR�((s/sys/lib/python2.7/zipfile.pytsetpassword�scCs|jS(s.The comment text associated with the ZIP file.(R�(Rh((s/sys/lib/python2.7/zipfile.pyRL�scCsXt|�tkrBddl}|jdtdd�|t }n||_t|_dS(Ni�s3Archive comment is too long; truncating to %d bytest
stackleveli(RtZIP_MAX_COMMENTtwarningstwarnR�R
R�(RhRLR'((s/sys/lib/python2.7/zipfile.pyRL�s
cCs|j|d|�j�S(s)Return file bytes (as a string) for name.R�(RR(RhR�R�((s/sys/lib/python2.7/zipfile.pyR�scCsd|dkrtd�n|js-td�n|jrH|j}t}nt|jd�}t}y�|t�r{|}n|j |�}|j
|jd�|jt
�}t|�t
kr�td��ntjt|�}|ttkr�d ��n|j|t�}|tr/|j|t�n||jkrWtd
|j|f�n|jd@} d}
| r&|s�|j}n|s�td|�nt|�}
|jd
�}t|
|dd
!�}|jd@r�jd?d@}
n|jd?d@}
t|d�|
kr&td|��q&nt ||||
d|�SWn|rY|j!�n�nXdS(s#Return file-like object for 'name'.R�R�trUs&open() requires mode "r", "U", or "rU"s3Attempt to read ZIP archive that was already closedRisTruncated file headers Bad magic number for file headers3File name in directory "%s" and header "%s" differ.is6File %s is encrypted, password required for extractioniii�iisBad password for fileR�N(R�R�srU("RRR�RRRR
RyRR#RRXRtsizeFileHeaderRRRRRot
_FH_SIGNATURERpt_FH_FILENAME_LENGTHt_FH_EXTRA_FIELD_LENGTHRMRTR?R�R�R�R\RYR�R�R�(RhR�R�R�tzef_filetshould_closeRtfheadertfnametis_encryptedtzdtbytestht
check_byte((s/sys/lib/python2.7/zipfile.pyR�sd
cCsOt|t�s!|j|�}n|dkr<tj�}n|j|||�S(s#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(RyRR#R?Rbtgetcwdt_extract_member(RhtmembertpathR�((s/sys/lib/python2.7/zipfile.pytextract�s
cCsC|dkr|j�}nx!|D]}|j|||�q"WdS(s�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?RR;(RhR:tmembersR�R�((s/sys/lib/python2.7/zipfile.pyt
extractalls
c
Cs|jjdtjj�}tjjrH|jtjjtjj�}ntjj|�d}tjjjd�|jtjj�D��}tjjdkr2d}t |t
�r�d�|D�}ntj|dt
|��}|j|�}d�|jtjj�D�}tjjjd �|D��}ntjj||�}tjj|�}tjj|�}|r�tjj|�r�tj|�n|jd
dkr�tjj|�s�tj|�n|S|j|d|��}t|d��} tj|| �Wd
QXWd
QX|S(sbExtract the ZipInfo object 'member' to a physical
file on the path targetpath.
R^icss6|],}|dtjjtjjfkr|VqdS(R<N(RbR:tcurdirtpardir(t.0R((s/sys/lib/python2.7/zipfile.pys <genexpr>ss\s:<>|"?*cSs%i|]}td�t|��qS(t_(R�(R@R�((s/sys/lib/python2.7/zipfile.pys
<dictcomp>%s RAcss|]}|jd�VqdS(t.N(trstrip(R@R((s/sys/lib/python2.7/zipfile.pys <genexpr>*scss|]}|r|VqdS(N((R@R((s/sys/lib/python2.7/zipfile.pys <genexpr>+si�R�R�N(RRdRbR:Rctaltsept
splitdriveR�tsplitRyRztstringt maketransRt translatetnormpathtdirnametexiststmakedirstisdirtmkdirRR�tshutiltcopyfileobj(
RhR9t
targetpathR�tarcnametillegalR�t upperdirstsourcettarget((s/sys/lib/python2.7/zipfile.pyR8s4!."cCs|j|jkr;ddl}|jd|jdd�n|jdkrVtd�n|jsktd �n|jtkr�t r�td
�n|jt
tfkr�td�n|jtkr�|j
s�td��q�n|jtkr|j
std
��qndS(s6Check for errors before writing a file to the archive.i�NsDuplicate name: %rR%iR�R�s write() requires mode "w" or "a"s4Attempt to write ZIP archive that was already closeds.Compression requires the (missing) zlib modules(That compression method is not supporteds'Filesize would require ZIP64 extensionss+Zipfile size would require ZIP64 extensions(R�R�(RR�R'R(R�RRRORR�RR[RkR�RRX(RhRR'((s/sys/lib/python2.7/zipfile.pyt_writecheck@s( cCs�|jstd��ntj|�}tj|j�}tj|j�}|dd!}|dkrm|}ntj
jtj
j|�d�}x*|dtj
tjfkr�|d}q�W|r�|d7}nt||�}|dd@d>|_|dkr|j|_n ||_|j|_d|_|jj�|_|j|�t|_|r�d|_d|_d|_|jj|�||j|j <|jj!|j"t#��dSt$|d ��} d|_}
d|_}|j%o�jd
t&k}|jj!|j"|��|jt'kr@t(j)t(j*t(j+d�}
nd}
d}xw| j,d�}|shPn|t-|�}t.||
�d@}
|
r�|
j/|�}|t-|�}n|jj!|�qOWdQX|
r
|
j0�}|t-|�}|jj!|�||_n ||_|
|_||_|rn|j%rn|t&krPtd��n|t&krntd��qnn|jj�}|jj1|jd�|jj!|j"|��|jj1|d�|jj|�||j|j <dS(sLPut the bytes from filename into the archive under the name
arcname.s7Attempt to write to ZIP archive that was already closediiiR^i�lNRg�����il�s*File size has increased during compressings-Compressed size larger than uncompressed sizei (2RRRbtstattS_ISDIRtst_modettimet localtimetst_mtimeR?R:RJRERcRDRRWR�ROtst_sizeR[RTR=RXRXR
R�RZRYR�RCR�RtwriteRwRRR�RkRR�tcompressobjtZ_DEFAULT_COMPRESSIONtDEFLATEDRRR�tcompressR�R(RhRRSROtstRNtmtimeRNRRRYRZRqtcmprR[R�tposition((s/sys/lib/python2.7/zipfile.pyR`Ws�
"
cCst|t�sOtd|dtjtj��d �}|j|_d|_n|}|jsmtd��n|d
k r�||_nt
|�|_|jj�|_
|j|�t|_t|�d@|_|jtkr$tjtjtjd�}|j|�|j�}t
|�|_n|j|_|jtkpK|jtk}|rm|jrmtd ��n|jj|j|��|jj|�|j d
@r�r�dnd}|jjt!j"||j|j|j��n|jj�|j#j$|�||j%|j&<d
S(s�Write a file into the archive. The contents is the string
'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive.RRNii�is7Attempt to write to ZIP archive that was already closedl�i�s'Filesize would require ZIP64 extensionsis<LQQs<LLLNi�('RyRR\R]R�RORWRRR?RR[R=RXRXR
R�R�RYRR�RaRbRcRdR�RZRkR�RR`RwRTRRlR�RCR�R(Rhtzinfo_or_arcnameR4RORtcoRqRu((s/sys/lib/python2.7/zipfile.pytwritestr�sF
cCs|j�dS(s2Call the "close()" method in case the user forgot.N(R�(Rh((s/sys/lib/python2.7/zipfile.pyt__del__�scCs�|jdkrdSzO|jdkra|jrad}|jj�}x�|jD]�}|d}|j}|ddd>|dd>B|d B}|d
d>|dd>B|dd B}g}|jtks�|j tkr|j
|j�|j
|j �d
}d
} n|j}|j } |jtkr?|j
|j�d
}
n |j}
|j}|r�t
jddt|�ddt|�|�|}td|j�}td|j�}
n|j}|j}
y�|j�\}}t
jtt|
|j||j||j|||j| |t|�t|�t|j�d|j|j|
�}Wn�tk
r�tjtt|
|j||j|j |j|||j| |t|j!�t|�t|j�d|j|j|
fIJ�nX|jj"|�|jj"|�|jj"|�|jj"|j�qMW|jj�}|}||}|}|t#ksf|tksf|tkr�jt$t%ddddd||||�}|jj"|�t
jt&t'd|d�}|jj"|�t(|d�}t(|d
�}t(|d
�}nt
jt)t*dd||||t|j+��}|jj"|�|jj"|j+�|jj,�nWd|j}d|_|j-s�|j.�nXdS(sJClose the file, and for mode "w" and "a" write the ending
records.NR�R�iii�i iiiiil�s<HHtQii-i,i�(R�R�(/RR?R�R�R=R�RNR[RkRZRCRXRPRRlRRDRRR2RnRR
RQRSRORYRLRVRWtDeprecationWarningRftstderrRTRR`tZIP_FILECOUNT_LIMITR R!RRR�RAR@R�R�R�R�(Rhtcounttpos1RRrRsRtRPR[RZRXt
extra_dataRRR2RRTRtpos2tcentDirCounttcentDirSizet
centDirOffsettzip64endrectzip64locrecR+R((s/sys/lib/python2.7/zipfile.pyR��s�
&&
!
N(R R
RR?RRRRjR�RR�RRRR R#R$tpropertyRLtsetterRRR;R=R8RXR`RkRlR�(((s/sys/lib/python2.7/zipfile.pyR�s0
G E
O . Y/ cBs#eZdZdd�Zd�ZRS(sDClass to create ZIP archives with Python library files and packages.R<c
Cs�tjj|�\}}tjj|�r|tjj|d�}tjj|�r�|rjd||f}n|}|jr�dG|GdG|GHn|j|dd!|�\}}|jr�dG|GHn|j||�tj |�}|j
d�x�|D]�} tjj|| �}
tjj| �\}}tjj|
�rptjjtjj|
d��r�|j|
|�q�q�dkr�j|
dd!|�\}}|jr�dG|GHn|j||�q�Wq�|jr�d G|GHnx�j |�D]�} tjj|| �}
tjj| �\}}|dkr�j|
dd!|�\}}|jrbdG|GHn|j||�q��n`|ddkr�t
d
�n|j|dd!|�\}}|jr�dG|GHn|j||�dS(
s,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.pyo or module.pyc.
This method will compile the module.py into module.pyc if
necessary.
s__init__.pys%s/%ssAdding package intasii�tAddings.pysAdding files from directorys.Files added with writepy() must end with ".py"sAdding fileN(RbR:RFRNR�tisfileR�t
_get_codenameR`tlistdirtremovetsplitexttwritepyR(
RhtpathnametbasenametdirR�tinitnameR1RStdirlistRR:troottext((s/sys/lib/python2.7/zipfile.pyR�PsZ
! c
Cs8|d}|d}|d}tjj|�r]tj|�jtj|�jkr]|}n�tjj|�s�tj|�jtj|�jkr�dl}|jr�dG|GHny|j||dt �Wn|j
k
r�}|jGHnX|}n|}tjj|�d} |r.d|| f} n|| fS( sReturn (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).
s.pys.pycs.pyoi�Nt Compilingis%s/%s(
RbR:R~RYR^t
py_compileR�R�R?R
tPyCompileErrortmsgRF(
RhR�R�tfile_pytfile_pyctfile_pyoR1R�terrtarchivename((s/sys/lib/python2.7/zipfile.pyR�s*
$ $ (R R
RR�R(((s/sys/lib/python2.7/zipfile.pyRMsAcs�ddl}|jd�}|dkr7tjd}n|sN|ddkrc|GHtjd�n|ddkr�t|�d kr�|GHtjd�nt|dd
��}|j�WdQXn3|ddkrAt|�d kr�GHtjd�nt|dd
��}|j �}WdQX|r9dj
|�GHndGHn�|ddkrZt|�d
krx|GHtjd�nt|dd
��}|d }x�|j�D]�}|jd�r�t
jj||d �}nt
jj||�}t
jj|�}t
jj|�st
j|�nt|d��} | j|j|��WdQXq�WWdQXn�|ddkr�|�d
kr�|GHtjd�n�fd��t|dddt��}x.|d D]"}
�||
t
jj|
��q�WWdQXndS(Ni�sE 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
iis-ls-cs-es-tiR�s.The following enclosed file is corrupted: {!r}sDone testingis./R�cs�tjj|�r(|j||t�n]tjj|�r�xHtj|�D]4}�|tjj||�tjj||��qJWndS(N(RbR:R~R`RRNR�R�(tzfR:tzippathtnm(taddToZip(s/sys/lib/python2.7/zipfile.pyR��sR�R�(s-ls-cs-es-t(ttextwraptdedentR?RftargvtexitRRRR tformatRt
startswithRbR:R�RKRLRMRR`RR
R�(targsR�tUSAGER�tbadfiletoutR:ttgtttgtdirRtsrc((R�s/sys/lib/python2.7/zipfile.pytmain�s\
) t__main__(kRRRbR\RfRPtbinasciiRRYR�R�RGR�R�tImportErrorR?t__all__t ExceptionRRRRkRpR&RRRAR@RmR>R"R#R$R%R&R'R(RFRRRR
RR t_CD_CREATE_VERSIONt_CD_CREATE_SYSTEMt_CD_EXTRACT_VERSIONt_CD_EXTRACT_SYSTEMt
_CD_FLAG_BITSt_CD_COMPRESS_TYPEt_CD_TIMEt_CD_DATEt_CD_CRCt_CD_COMPRESSED_SIZEt_CD_UNCOMPRESSED_SIZERRR
t_CD_DISK_NUMBER_STARTt_CD_INTERNAL_FILE_ATTRIBUTESt_CD_EXTERNAL_FILE_ATTRIBUTESRRoRpR*R+t_FH_EXTRACT_VERSIONt_FH_EXTRACT_SYSTEMt_FH_GENERAL_PURPOSE_FLAG_BITSt_FH_COMPRESSION_METHODt_FH_LAST_MOD_TIMEt_FH_LAST_MOD_DATEt_FH_CRCt_FH_COMPRESSED_SIZEt_FH_UNCOMPRESSED_SIZER,R-RRRR R!Rt_CD64_SIGNATUREt_CD64_DIRECTORY_RECSIZEt_CD64_CREATE_VERSIONt_CD64_EXTRACT_VERSIONt_CD64_DISK_NUMBERt_CD64_DISK_NUMBER_STARTt_CD64_NUMBER_ENTRIES_THIS_DISKt_CD64_NUMBER_ENTRIES_TOTALt_CD64_DIRECTORY_SIZEt_CD64_OFFSET_START_CENTDIRRRR:RtobjectRR�R�R�R�RRR�R (((s/sys/lib/python2.7/zipfile.pyt<module>s�<$
+ =�<
���cF
|