grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î ¤ fà ã$@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z yddl Z e j Z Wn!ek rºdZ e j Z YnXyddlZWnek rådZYnXyddlZWnek rdZYnXddddddd d d d d dg ZGdd„deƒZGdd„deƒZeZZdd>dZdd>dZdd>dZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$e j%e#ƒZ&dZ'dZ(dZ)dZ*dZ+d Z,d!Z-d"Z.dZ/d#Z0d$Z1d%Z2e j%e1ƒZ3dZ4dZ5dZ6dZ7dZ8d Z9d!Z:d"Z;dZ<d#Z=d&Z>d'Z?dZ@d(ZAdZBd)ZCdZDd*ZEd+ZFd,ZGd-ZHe j%eGƒZIdZJdZKdZLdZMdZNd ZOd!ZPd"ZQdZRd#ZSd&ZTd'ZUd.ZVd/ZWe j%eVƒZXd0ZYd1ZZe j%eYƒZ[dZ\dZ]dZ^dZ_dZ`d Zad!Zbd"ZcdZdd#Zed2d3„Zfd4d „Zgd5d6„Zhd7d8„ZiGd9d „d ejƒZkGd:d;„d;ƒZlGd<d=„d=ƒZmGd>d?„d?ƒZnid@d6dAd6dBd6dBd6dBd6dBd 6dCd!6dDd"6dEd6dFd#6dCd&6dGd6dHd6dId+6dJdK6dLdM6dNdO6ZodPdQ„ZpdRdS„ZqdTdU„ZrGdVdW„dWejsƒZtGdXd „d ƒZuGdYd „d euƒZvddZd[„Zwexd\krewƒndS)]zP Read and write ZIP files. XXX references to utf-8 need further investigation. éNÚ BadZipFileÚ BadZipfileÚerrorÚ ZIP_STOREDÚ ZIP_DEFLATEDÚ ZIP_BZIP2ÚZIP_LZMAÚ is_zipfileÚZipInfoÚZipFileÚ PyZipFileÚ LargeZipFilec@seZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©rrú,/opt/alt/python34/lib64/python3.4/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 <4sQ2H2L4QsPKc Cs-yt|ƒrdSWntk r(YnXdS)NTF)Ú _EndRecDataÚOSError)ÚfprrrÚ_check_zipfile£s   r.cCshd}yIt|dƒr*td|ƒ}n$t|dƒ�}t|ƒ}WdQXWntk rcYnX|S)zˆQuickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too. FÚreadr-ÚrbN)Úhasattrr.Úopenr,)ÚfilenameÚresultr-rrrr «s cCsry|j|tdƒWntk r0|SYnX|jtƒ}t|ƒtkrV|Stjt|ƒ\}}}}|tkr„|S|dksœ|dkr«t dƒ‚n|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)Ú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ÚdataZsigZdisknoZreloffZdisksZszÚcreate_versionZ read_versionZdisk_numZdisk_dirZdircountZ dircount2ZdirsizeZ diroffsetrrrÚ _EndRecData64»s6   0        rKc CsÑ|jddƒ|jƒ}y|jt dƒWntk rIdSYnX|jƒ}t|ƒtkrá|dd…tkrá|d d…dkrátjt |ƒ}t |ƒ}|j dƒ|j |tƒt |t |ƒSt |d tdƒ}|j|dƒ|jƒ}|jtƒ}|dkrÍ|||t…}t|ƒtkrYdSt tjt |ƒƒ}|t}||t|t|…}|j |ƒ|j ||ƒt |||||ƒSdS) zÔReturn data from the "End of Central Directory" record, or None. The data is a list of the nine items in the ZIP "End of central dir" record followed by a tenth item, the file seek offset of this record.rrNr sórréþÿÿÿi)r5ÚtellÚsizeEndCentDirr,r/r7ÚstringEndArchiver8r9ÚstructEndArchiveÚlistÚappendrKÚmaxÚrfindÚ_ECD_COMMENT_SIZE) rFZfilesizerIrHZmaxCommentStartÚstartZrecDataZ commentSizeÚcommentrrrr+æs>          r+c@sUeZdZdZd"Zdd#dd„Zddd„Zdd„Zd d!„ZdS)$r z>Class with attributes describing each file in the ZIP archive.Ú orig_filenamer3Ú 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|…}ntjdkrstj|krs|jtjdƒ}n||_||_|ddkr¤tdƒ‚nt |_ 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Úreplacer3rZÚ ValueErrorrr[rXr\ÚsysÚplatformr]ÚDEFAULT_VERSIONrJr^r_r`rarbrc)Úselfr3rZZ null_byterrrÚ__init__<s.               zZipInfo.__init__NcCs|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd @rsd}}}n|j}|j}|j}|j}d} |d krÄ|tkp¾|tk}n|rÿd } |tj| dtj | ƒd ||ƒ}n|tks|tkrA|s,t d ƒ‚nd}d}t } n|j t krbtt| ƒ} n!|j tkrƒtt| ƒ} nt| |jƒ|_t| |jƒ|_|jƒ\} } tjtt|j|j| |j |||||t| ƒt|ƒƒ } | | |S)z'Return the per-file header as a string.ri¼r$rr!rrr&r rNz[^\r\n]+)|(?P\n|\r\n?)NFcCsø||_||_||_|j|_|j|_|j|_t |jƒ|_ d|_ d|_ d|_ d|k|_d|_|jdk r¥|jd8_n||_|j|_t|dƒrë|j|_tdƒd@|_n d|_dS)NFrLrÚUrrelÿÿ)Ú_fileobjÚ _decrypterÚ_close_fileobjr[Ú_compress_typerfÚ_compress_leftrgÚ_leftrÉÚ _decompressorÚ_eofÚ _readbufferÚ_offsetÚ _universalÚnewlinesÚmoder3Únamer1reÚ _expected_crcÚcrc32Ú _running_crc)ruZfileobjrØÚzipinfoZ decrypterÚ close_fileobjrrrrv�s(             zZipExtFile.__init__cCs¬|j rd|dkrd|jjd|jƒd}|dkrd|j|j|…}||_|Sn|js€tjj||ƒSd}x|dks§t|ƒ|kr§|jdƒ}|dkrÆ|S|j j |ƒ}|j dƒ}|dk rM|j dkrg|_ n||j kr0|j j |ƒn|jt|ƒ7_|dS|j dƒ}|dkr…|d|t|ƒ…}n|jt|ƒ7_||7}q‰W|S) zrRead and return a line from the stream. If limit is specified, at most limit bytes will be read. rs rrLrÚnewlineNÚchunk)rÖrÔrlrÕÚioÚBufferedIOBaseÚreadliner7ÚpeekÚPATTERNÚsearchÚgroupr×rS)ruÚlimitr™ÚlineZ readaheadÚmatchrßràrrrrã¢s8   !     zZipExtFile.readlinecCsœ|t|jƒ|jkr�|j|ƒ}t|ƒ|jkri||j|jd…|_d|_q�|jt|ƒ8_n|j|j|jd…S)z6Returns buffered bytes without advancing the position.Nri)r7rÔrÕr/)ruÚnràrrrräÔs zZipExtFile.peekcCsdS)NTr)rurrrÚreadableászZipExtFile.readablecCsp|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|dkrk|j rk|j|ƒ}|t|ƒkrN||_||_||d|…7}Pn||7}|t|ƒ8}qíW|S)z�Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached.. NrrL)rÔrÕrÓÚ_read1ÚMAX_Nr7)rurëÚbufÚendrIrrrr/äs4          zZipExtFile.readcCsa|jdkrdSt||jƒd@|_|jr]|j|jkr]td|jƒ‚ndS)NlÿÿzBad CRC-32 for file %r)rÚrÛrÜrÓrrÙ)ruÚnewdatarrrÚ _update_crcs zZipExtFile._update_crccCs||dks|dkrz|j|jd…}d|_d|_x3|jsu|j|jƒ}|rC||7}PqCqCW|S||j}|t|jƒkr¿|j|j|…}||_|S|t|jƒ}|j|jd…}d|_d|_|dkrxxo|jst|j|ƒ}|t|ƒkr]||_||_||d|…7}Pn|r ||7}Pq q Wn|S)z7Read up to n bytes with at most one read() system call.NrrL)rÔrÕrÓrírîr7)rurërïrIrðrrrÚread1s>              zZipExtFile.read1cCs£|js|dkrdS|jtkri|jj}|t|ƒkrx||j|t|ƒƒ7}qxn|j|ƒ}|jtkrœ|jdk|_n³|jtkrt ||j ƒ}|jj ||ƒ}|jj p÷|jdko÷|jj |_|jrO||jj ƒ7}qOn0|jj |ƒ}|jj pI|jdk|_|d|j…}|jt|ƒ8_|jdkr’d|_n|j|ƒ|S)NrrLT)rÓrÏrrÒZunconsumed_tailr7Ú_read2rrÐrTÚ MIN_READ_SIZEr»rºr¶rÑrò)rurërIrrrrí4s2 #    zZipExtFile._read1cCs›|jdkrdSt||jƒ}t||jƒ}|jj|ƒ}|jt|ƒ8_|smt‚n|jdk r—t t |j|ƒƒ}n|S)NrrL) rÐrTrõÚminrÌr/r7ÚEOFErrorrÍÚbytesÚmap)rurërIrrrrôXs zZipExtFile._read2c s2z|jr|jjƒnWdtƒjƒXdS)N)rÎrÌÚcloseÚsuper)ru)Ú __class__rrrúhs zZipExtFile.closeéi@éÿÿÿÿrþ)rrrrrîrõÚreÚcompilerårvrãrärìr/ròrórírôrúrr)rürrÊss  2 ! % $ rÊc@sxeZdZdZdZdZdeddd„Zdd„Zd d „Z d d „Z d d„Z dd„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.d/„Zd0d1„ZdS)2r a¨ 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" 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. NÚrTcCs6|dkrtdƒ‚nt|ƒ||_d|_d|_i|_g|_||_|jddƒd|_ }d |_ d |_ t |t ƒr0d|_||_id d6d d6d d6}ytj|||ƒ|_WqWtk r,|dkr%d}}tj|||ƒ|_n‚YqWXn'd|_||_t|dd ƒ|_y¥|dkrs|jƒnˆ|dkr‹d|_np|dkrïy$|jƒ|jj|jdƒWqûtk rë|jjddƒd|_YqûXn tdƒ‚Wn3|j}d |_|js*|jƒn‚YnXd S)z>Open the ZIP file with mode read "r", write "w" or append "a".rÚwÚaz(ZipFile() requires mode "r", "w", or "a"FrÚbÚNrLr0Úwbzr+brrÙTrzMode must be "r", "w" or "a")rrr)r�rÄÚ _allowZip64Ú _didModifyÚdebugÚ NameToInfoÚfilelistrÃrprØr¤Ú_commentr§ÚstrÚ _filePassedr3rár2r-r,ÚgetattrÚ_RealGetContentsr5Ú start_dirrrú)ruÚfilerØrÃÚ allowZip64ÚkeyZmodeDictr-rrrrvƒsZ                             zZipFile.__init__cCs|S)Nr)rurrrÚ __enter__ÄszZipFile.__enter__cCs|jƒdS)N)rú)ruÚtypeÚvalueÚ tracebackrrrÚ__exit__ÇszZipFile.__exit__cCs±|j}yt|ƒ}Wntk r9tdƒ‚YnX|sOtdƒ‚n|jdkrkt|ƒn|t}|t}|t|_ |t ||}|t t kr¿|t t8}n|jdkrî||}td|||ƒn|||_|j|jdƒ|j|ƒ}tj|ƒ}d}xx||kr¬|jtƒ} t| ƒtkrqtdƒ‚ntjt| ƒ} | ttkr¢tdƒ‚n|jdkr¾t| ƒn|j| tƒ} | d} | d @r÷| jd ƒ} n| jd ƒ} t| ƒ} |j| tƒ| _|j| t ƒ| _!| t"| _#| dd …\ | _$| _%| _&| _'| _(| _)} }| _*| _+| _,| j&t-krÀt.d | j&dƒ‚n| dd…\| _/| _0| _1| | _2|d?d|d?d@|d@| d?| d?d@| d@df| _3| j4ƒ| j#|| _#|j5j6| ƒ| |j7| j8<|t| t| t| t }|jdkr5td|ƒq5q5WdS)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-8Úcp437rzzip file version %.1fr%r(r*r$i¼rr&rÚtotalN)9r-r+r,rr ÚprintrDrEÚ _ECD_COMMENTr Ú _ECD_LOCATIONr?r>r<r6rr5r/ráÚBytesIOÚsizeCentralDirr7r8r9Ú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 r3)rur-rHZsize_cdZ offset_cdÚconcatZinferredrIrÚcentdirr3ÚflagsÚxÚtÚdrrrrÊsp             L" & "zZipFile._RealGetContentscCsdd„|jDƒS)z+Return a list of file names in the archive.cSsg|]}|j‘qSr)r3)Ú.0rIrrrú s z$ZipFile.namelist..)r )rurrrÚnamelistszZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the archive.)r )rurrrÚinfolistszZipFile.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)r4r5r6)rr rZr3rg)rurÚzinfoZdaterrrÚprintdir!s  zZipFile.printdircCsrd}xe|jD]Z}y8|j|jdƒ�}x|j|ƒrFq4WWdQXWqtk ri|jSYqXqWdS)z%Read all the files and check the CRC.rrrNi)r r2r3r/r)ruZ chunk_sizer7ÚfrrrÚtestzip*s zZipFile.testzipcCs5|jj|ƒ}|dkr1td|ƒ‚n|S)z,Return the instance of ZipInfo given 'name'.Nz(There is no item named %r in the archive)r rÇÚKeyError)rurÙÚinforrrÚgetinfo7s  zZipFile.getinfocCsN|r/t|tƒ r/tdt|ƒƒ‚n|rA||_n d|_dS)z)Set default password for encrypted files.zpwd: expected bytes, got %sN)r§røÚ TypeErrorrr¤)rur¤rrrÚ setpassword@s  zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)r )rurrrrXIszZipFile.commentcCs†t|tƒs(tdt|ƒƒ‚nt|ƒtkrpddl}|jdtddƒ|dt…}n||_d|_ dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesÚ stacklevelrT) r§rør>rr7ÚZIP_MAX_COMMENTÚwarningsÚwarnr r)rurXrBrrrrXNs   cCs,|j|d|ƒ�}|jƒSWdQXdS)z)Return file bytes (as a string) for name.rN)r2r/)rurÙr¤r-rrrr/[sz ZipFile.readc Cs5|dkrtdƒ‚nd|krIddl}|jdtdƒn|rxt|tƒ rxtd t|ƒƒ‚n|js�td ƒ‚n|j r¥|j}nt j |j d ƒ}ySt|t ƒrÕ|}n|j|ƒ}|j|jdƒ|jtƒ}t|ƒtkr'td ƒ‚ntjt|ƒ}|ttkrXtd ƒ‚n|j|tƒ}|tr‰|j|tƒn|jd@r¥tdƒ‚n|jd@rÁtdƒ‚n|jd@rà|jdƒ} n|jdƒ} | |jkrtd|j|fƒ‚n|jd@} d} | rï|sE|j }n|s^td|ƒ‚nt!|ƒ} |jdƒ} t"t#| | dd…ƒƒ} |jd@r¹|j$d?d@}n|j%d?d@}| d|krïtd|ƒ‚qïnt&|||| d|j ƒSWn!|j s)|j'ƒn‚YnXdS) z#Return file-like object for 'name'.rrËÚrUz&open() requires mode "r", "U", or "rU"rNz'U' mode is deprecatedrzpwd: expected bytes, got %sz3Attempt to read ZIP archive that was already closedr0zTruncated file headerz Bad magic number for file headeré z$compressed patched data (flag bit 5)é@zstrong encryption (flag bit 6)izutf-8rz/File name in directory %r and header %r differ.rz6File %s is encrypted, password required for extractionrrr�r‹r&zBad password for filerÞ)rrËrD)(r�rBrCÚDeprecationWarningr§rør>rr-rrár2r3r r=r5rdr/ÚsizeFileHeaderr7rr8r9r~Ú _FH_SIGNATURErÚ_FH_FILENAME_LENGTHÚ_FH_EXTRA_FIELD_LENGTHr`rÈr%rYr¤r•rRrùrhrerÊrú)rurÙrØr¤rBZzef_filer7ZfheaderÚfnameZ fname_strZ is_encryptedZzdr†ÚhZ check_byterrrr2`sz                     z ZipFile.opencCsOt|tƒs!|j|ƒ}n|dkr<tjƒ}n|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)r§r r=rnÚgetcwdÚ_extract_member)ruÚmemberÚpathr¤rrrÚextractÀs  zZipFile.extractcCsC|dkr|jƒ}nx!|D]}|j|||ƒq"WdS)zõExtract all members from the archive to the current working directory. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by namelist(). N)r2rR)rurQZmembersr¤rÝrrrÚ extractallÎs  zZipFile.extractallcCsˆ|j}|s=d}tj|dt|ƒƒ}||_n|j|ƒ}dd„|j|ƒDƒ}|jdd„|Dƒƒ}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*Ú_css|]}|jdƒVqdS)Ú.N)Úrstrip)r0r-rrrú äsz1ZipFile._sanitize_windows_name..css|]}|r|VqdS)Nr)r0r-rrrrWæs)Ú!_windows_illegal_name_trans_tabler Ú maketransr7Ú translateÚsplitÚjoin)ÚclsÚarcnameÚpathsepr˜ZillegalrrrÚ_sanitize_windows_nameÚs  zZipFile._sanitize_windows_namecsÂ|jjdtjjƒ}tjjrH|jtjjtjjƒ}ntjj|ƒd}dtjjtjjf‰tjjj ‡fdd†|j tjjƒDƒƒ}tjjdkrÝ|j |tjjƒ}ntjj ||ƒ}tjj |ƒ}tjj |ƒ}|r?tjj|ƒ r?tj|ƒn|jd dkrxtjj|ƒsttj|ƒn|S|j|d|ƒ�/}t|dƒ�}tj||ƒWd QXWd QX|S) zbExtract the ZipInfo object 'member' to a physical file on the path targetpath. rjrrc3s!|]}|ˆkr|VqdS)Nr)r0r-)Úinvalid_path_partsrrrW÷sz*ZipFile._extract_member..ú\r¤rNrþ)r3rprnrQroÚaltsepÚ splitdriveÚcurdirÚpardirr\r[r`ÚnormpathÚdirnameÚexistsÚmakedirsÚisdirÚmkdirr2ÚshutilZ copyfileobj)rurPZ targetpathr¤r^Z upperdirsÚsourceÚtargetr)rarrOés* !7zZipFile._extract_membercCsû|j|jkr;ddl}|jd|jddƒn|jdkrYtdƒ‚n|jsqtd ƒ‚nt|jƒ|j s÷d}t |j ƒt kr«d }n0|j tkrÃd }n|jtkrÛd }n|r÷t|d ƒ‚q÷ndS)z6Check for errors before writing a file to the archive.rNzDuplicate name: %rr@rrrz write() requires mode "w" or "a"z4Attempt to write ZIP archive that was already closedz Files countZFilesizez Zipfile sizez would require ZIP64 extensions)rr)r3r rBrCrØr�r-rÄr[rr7r ÚZIP_FILECOUNT_LIMITrgrwrdr )rur7rBÚrequires_zip64rrrÚ _writechecks(        zZipFile._writecheckc Cs |jstdƒ‚ntj|ƒ}tj|jƒ}tj|jƒ}|dd…}|dkrp|}ntj j tj j |ƒdƒ}x0|dtj tj fkrÄ|dd…}q•W|rØ|d7}nt||ƒ}|dd@d>|_|rt|_n$|dkr)|j|_n ||_|j|_d|_|jjƒ|_|jtkrz|jd O_n|j|ƒd |_|rýd|_d|_d|_|jdO_|jj|ƒ||j|j <|jj!|j"d ƒƒdSt#|jƒ} t$|d ƒ�×} d|_} d|_} |j%oQ|jd t&k} |jj!|j"| ƒƒd}xx| j'dƒ}|s�Pn|t(|ƒ}t)|| ƒd@} | rÚ| j*|ƒ}| t(|ƒ} n|jj!|ƒqvWWdQX| r2| j+ƒ}| t(|ƒ} |jj!|ƒ| |_n ||_| |_||_| r–|j%r–|t&krxtdƒ‚n| t&kr–tdƒ‚q–n|jjƒ}|jj,|jdƒ|jj!|j"| ƒƒ|jj,|dƒ|jj|ƒ||j|j |dd>B|d B}|d d >|d d>B|dd B}g}|jtksÆ|jtkrõ|j |jƒ|j |jƒd }d }n|j}|j}|j tkr/|j |j ƒd } n |j } |j } d} |rŠt j ddt|ƒddt|ƒ|Œ| } t} n|jtkr«tt| ƒ} n!|jtkrÌtt| ƒ} nt| |jƒ} t| |jƒ} y…|jƒ\}}t j tt| |j| |j||j|||j||t|ƒt| ƒt|jƒd|j|j | ƒ}Wn‘t!k rt"tt| |j| |j|j#|j|||j||t|j$ƒt| ƒt|jƒd|j|j | fdt%j&ƒ‚YnX|jj'|ƒ|jj'|ƒ|jj'| ƒ|jj'|jƒqGW|jjƒ}t|jƒ}||}|}d}|t(kr™d}n*|tkr®d}n|tkrÃd}n|r}|j)såt*|dƒ‚nt j t+t,ddddd||||ƒ }|jj'|ƒt j t-t.d|dƒ}|jj'|ƒt/|dƒ}t/|d ƒ}t/|d ƒ}nt j t0t1dd||||t|j2ƒƒ }|jj'|ƒ|jj'|j2ƒ|jj3ƒnWd|j}d|_|j4s |j5ƒnXdS)zJClose the file, and for mode "w" and "a" write the ending records.Nrrri¼r$rr!rrr&r lÿÿzr:r;rörQrPr r¶rrú)ruZpos1r7r�r‚rƒr\rgrfrdZ extra_datar„r^rJr3r`r+Zpos2Z centDirCountZ centDirSizeZ centDirOffsetrqZ zip64endrecZ zip64locrecrHr-rrrrú¾s¾ &&             !               z ZipFile.close) rrrrr-rXrrvrrrr2r3r8r:r=r?ÚpropertyrXÚsetterr/r2rRrSÚ classmethodr`rOrrrzr~rrúrrrrr ps4 A   N    `  ' [8 c@sLeZdZdZdedd dd„Zddd d „Zd d „ZdS)r zDClass to create ZIP archives with Python library files and packages.rTrc Cs/tj||d|d|d|ƒ||_dS)NrØrÃr)r rvÚ _optimize)rurrØrÃrÚoptimizerrrrv4szPyZipFile.__init__rNcCsÌ|rU||ƒ rU|jrQtjj|ƒr4dnd}td||fƒndStjj|ƒ\}}tjj|ƒrXtjj|dƒ}tjj|ƒrh|r¿d||f}n|}|jrätd|d|ƒn|j|d d…|ƒ\}} |jrtd | ƒn|j || ƒtj |ƒ} | j dƒx| D]} tjj|| ƒ} tjj | ƒ\} }tjj| ƒrÔtjjtjj| dƒƒra|j | |d |ƒqaqR|d krR|r|| ƒ r|jrRtd| ƒqRqRn|j| d d…|ƒ\}} |jrNtd | ƒn|j || ƒqRqRWqÈ|jr�td|ƒnxDtj |ƒD]À} tjj|| ƒ} tjj | ƒ\} }|d kr‘|r|| ƒ r|jr‘td| ƒq‘q‘n|j| d d…|ƒ\}} |jr>td | ƒn|j || ƒq‘q‘Wnp|dd…d kr}tdƒ‚n|j|d d…|ƒ\}} |jr¸td| ƒn|j || ƒdS)a´Add all files from "pathname" to the ZIP archive. If pathname is a package directory, search the directory and all package subdirectories recursively for all *.py and enter the modules into the archive. If pathname is a plain directory, listdir *.py and enter all modules. Else, pathname must be a Python *.py file and the module will be put into the archive. Added modules are always module.pyo or 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. rQrz%s "%s" skipped by filterfuncNz __init__.pyz%s/%szAdding package inÚasrrZAddingÚ filterfuncz.pyzfile "%s" skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding fileéýÿÿÿrŠrŠrŠrŠ)r rnrQrkrr[r\ÚisfileÚ _get_codenamerzÚlistdirÚremoveÚsplitextÚwritepyr�)ruÚpathnameÚbasenamer‰ZlabelÚdirrÙZinitnamerLr^Zdirlistr3rQÚrootZextrrrr�:sv  "   !         " zPyZipFile.writepyc szd ‡fdd†}|d}|d}|d}tjj|dƒ}tjj|dƒ}ˆjd kr¼tjj|ƒr¯tj|ƒjtj|ƒjkr¯|} } qAtjj|ƒròtj|ƒjtj|ƒjkrò|} } qAtjj|ƒr7tj|ƒjtj|ƒjkr7|} |} qAtjj|ƒr|tj|ƒjtj|ƒjkr||} |} qA||ƒr¯t r”|n|} t r¦|n|} qA|} } n…ˆjd krÚ|} |} n |} |} tjj| ƒotj| ƒjtj|ƒjksA||d ˆjƒsA|} } qAntjj | ƒd} |rpd || f} n| | 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). rcs‚ddl}ˆjr%td|ƒny|j|ddd|ƒWn9|jk r}}zt|jƒdSWYdd}~XnXdS)NrZ CompilingÚdoraiseTr‡F)Ú py_compiler rrÚPyCompileErrorÚmsg)rr‡r–Úerr)rurrÚ_compile’s   z)PyZipFile._get_codename.._compilez.pyz.pycz.pyoTFrr‡z%s/%srþrþ) Ú importlibÚutilÚcache_from_sourcer†rnrQr‹rsrxÚ __debug__r[) rur‘r’ršZfile_pyZfile_pycZfile_pyoZ pycache_pycZ pycache_pyor^rLZ archivenamer)rurrŒ‹sL   $ $ $ $    $zPyZipFile._get_codenamerþ)rrrrrrvr�rŒrrrrr 1s Qc sÅddl}|jdƒ}|dkr=tjdd…}n| sT|ddkrnt|ƒtjdƒn|ddkrÓt|ƒdkrªt|ƒtjdƒnt|dd ƒ�}|jƒWdQXnî|ddkr`t|ƒdkrt|ƒtjdƒnt|dd ƒ�}|j ƒ}WdQX|rStd j |ƒƒntd ƒna|ddkrÌt|ƒd krœt|ƒtjdƒnt|dd ƒ�}|j |dƒWdQXnõ|ddkrÁt|ƒd krt|ƒtjdƒn‡fd d†‰t|ddƒ��}x…|dd…D]s}t j j|ƒ}|s€t j jt j j|ƒƒ}n|dt jt jfkr¤d}nˆ|||ƒqAWWdQXndS)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ƒnvtjj|ƒrž|rS|j||ƒnxHtj|ƒD]4}ˆ|tjj||ƒtjj||ƒƒqcWndS)N)rnrQr‹rzrrkr�r\)ÚzfrQÚzippathZnm)ÚaddToZiprrr¥ÿszmain..addToZiprr)rŸr r¡r¢)ÚtextwrapÚdedentrrÚargvrÚexitr7r r8r:ÚformatrSrnrQr’rhrerf)Úargsr¦ZUSAGEr£ZbadfilerQr¤r)r¥rÚmainÑsT          ! r¬Ú__main__)yrrárnrÿÚimportlib.utilr›rrrvrsrmr8ZbinasciirÁrÛÚ ImportErrorrÂr°Ú__all__Ú Exceptionrr rrrwrprArrrrrtrzr{r|r)rQrPryrOr?r@rArBrCrDrErVrrr!r#r r"Z_CD_CREATE_VERSIONZ_CD_CREATE_SYSTEMZ_CD_EXTRACT_VERSIONZ_CD_EXTRACT_SYSTEMZ _CD_FLAG_BITSZ_CD_COMPRESS_TYPEZ_CD_TIMEZ_CD_DATEZ_CD_CRCZ_CD_COMPRESSED_SIZEZ_CD_UNCOMPRESSED_SIZEr$r&r'Z_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESr(r~rrHrIZ_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_SIZErJrKr: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 r•r¬r·rÆrÄrÅrÉrârÊr r r¬rrrrrÚs"                        + =œ=   ýÿÿàB