grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ÿ“qcÈãB@sXdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z yddl Z Wne k r®ddlZ YnXyddlZejZWn!e k rëdZe jZYnXyddlZWne k rdZYnXyddlZWne k rAdZYnXddddddd d d d d dg ZGdd„deƒZGdd„deƒZeZZdd>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'e3ƒZ5dZ6dZ7dZ8dZ9dZ:d Z;d!Z<d"Z=dZ>d#Z?d&Z@d'ZAdZBd(ZCdZDd)ZEdZFd*ZGd+ZHd,ZId-ZJe j'eIƒZKdZLdZMdZNdZOdZPd ZQd!ZRd"ZSdZTd#ZUd&ZVd'ZWd.ZXd/ZYe j'eXƒZZd0Z[d1Z\e j'e[ƒZ]dZ^dZ_dZ`dZadZbd Zcd!Zdd"ZedZfd#Zgd2d3„Zhd4d „Zid5d6„Zjd7d8„ZkGd9d „d elƒZmGd:d;„d;ƒZnGd<d=„d=ƒZoGd>d?„d?ƒZpdd@ddAddBddBddBd dBd!dCd"dDddEd#dFd&dCddGddHd+dIdJdKdLdMdNdOiZqdPdQ„ZrdRdS„ZsdTdU„ZtGdVdW„dWƒZuGdXdY„dYƒZvGdZd[„d[ejwƒZxGd\d „d ƒZyGd]d „d eyƒZzdd^d_„Z{e|d`krTe{ƒdS)azP 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/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 <4sQ2H2L4QsPKc Cs-yt|ƒrdSWntk r(YnXdS)NTF)Ú _EndRecDataÚOSError)ÚfprrrÚ_check_zipfile§s   r.cCsid}yJt|dƒr*td|ƒ}n%t|dƒ�}t|ƒ}WdQRXWntk rdYnX|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 cCsoy|j|tdƒWntk r0|SYnX|jtƒ}t|ƒtkrV|Stjt|ƒ\}}}}|tkr„|S|dksœ|dkr¨t dƒ‚|j|tt dƒ|jt ƒ}t|ƒt krå|Stjt |ƒ\ }}} } } } } }}}|t kr%|S||t <| |t<| |t<| |t<||t<||t<||t<|S)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@saeZdZdZd$Zdd%dd„Zdd„Zddd„Zd d!„Zd"d#„Z dS)&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|…}tjdkrmtj|krm|jtjdƒ}||_||_|ddkr›tdƒ‚t |_ d|_ d|_ t jdkrÑd|_n d|_t|_t|_d|_d|_d|_d|_d|_dS)Nrú/i¼z+ZIP does not support timestamps before 1980rLÚwin32r)rYÚfindÚchrÚosÚsepÚreplacer3rZÚ ValueErrorrr[rXr\ÚsysÚplatformr]Ú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 d…dk}| sÈ|j rÜ|jd |j ƒ| sì|j r!|jtks |j |j kr!|jd |j ƒ|jd ƒd j |ƒS)Nz<%s filename=%rz compress_type=%sriÿÿz filemode=%rz external_attr=%#xrrjz file_size=%rz compress_size=%rú>Úéÿÿÿÿ)Ú __class__rr3r[rrSÚcompressor_namesÚgetrcÚstatÚfilemodergrfÚjoin)rur4ÚhiÚloÚisdirrrrÚ__repr__js(     zZipInfo.__repr__NcCs|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd @rsd}}}n|j}|j}|j}|j}d} |d krÁ|tkp¾|tk}|rùd } |tj| dtj | ƒd ||ƒ}|tks|tkr5|s#t d ƒ‚d}d}t } |j t krVtt| ƒ} n|j tkrttt| ƒ} t| |jƒ|_t| |jƒ|_|jƒ\} } tjtt|j|j| |j |||||t| ƒt|ƒƒ } | | |S)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_||_|j|_t|dƒrä|j|_tdƒ|_n d|_dS)NFrLrÚUrre)Ú_fileobjÚ _decrypterÚ_close_fileobjr[Ú_compress_typerfÚ_compress_leftrgÚ_leftrÕÚ _decompressorÚ_eofÚ _readbufferÚ_offsetÚ _universalÚnewlinesÚmoder3Únamer1reÚ _expected_crcÚcrc32Ú _running_crc)ruràrñÚzipinfoZ decrypterZ close_fileobjrrrrvÄs(             zZipExtFile.__init__cCs¡d|jj|jjfg}|jsz|jd|j|jfƒ|jtkr‡|jdt j |j|jƒƒn |jdƒ|jdƒdj |ƒS)Nz<%s.%sz name=%r mode=%rz compress_type=%sz [closed]rwrx) rzrrÚclosedrSròrñrèrr{r|r)rur4rrrrƒås      zZipExtFile.__repr__cCs |j ra|dkra|jjd|jƒd}|dkra|j|j|…}||_|S|js}tjj||ƒSd}x|dks¤t|ƒ|kr›|jdƒ}|dkrÃ|S|j j |ƒ}|j dƒ}|dk rD|j dkrg|_ ||j kr'|j j |ƒ|jt|ƒ7_|dS|j dƒ}|dkry|d|t|ƒ…}|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|_n|jt|ƒ8_|j|j|jd…S)z6Returns buffered bytes without advancing the position.Nri)r7rírîr/)rurßrùrrrrý%s zZipExtFile.peekcCsdS)NTr)rurrrÚreadable2szZipExtFile.readablecCsm|dks|dkrj|j|jd…}d|_d|_x#|jse||j|jƒ7}qCW|S||j}|t|jƒkr¯|j|j|…}||_|S|t|jƒ}|j|jd…}d|_d|_x||dkrh|j rh|j|ƒ}|t|ƒkrK||_||_||d|…7}P||7}|t|ƒ8}qíW|S)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/5s4          zZipExtFile.readcCsZ|jdkrdSt||jƒ|_|jrV|j|jkrVtd|jƒ‚dS)NzBad CRC-32 for file %r)rórôrõrìrrò)ruÚnewdatarrrÚ _update_crcVs zZipExtFile._update_crccCsp|dks|dkrw|j|jd…}d|_d|_x0|jsr|j|jƒ}|rC||7}PqCW|S||j}|t|jƒkr¼|j|j|…}||_|S|t|jƒ}|j|jd…}d|_d|_|dkrlxf|jsk|j|ƒ}|t|ƒkrW||_||_||d|…7}P|r||7}PqW|S)z7Read up to n bytes with at most one read() system call.NrrL)rírîrìrrr7)rurßrrIrrrrÚread1`s>             zZipExtFile.read1cCsš|js|dkrdS|jtkrf|jj}|t|ƒkru||j|t|ƒƒ7}n|j|ƒ}|jtkr™|jdk|_n°|jtkrt ||j ƒ}|jj ||ƒ}|jj pô|jdkoô|jj |_|jrI||jj ƒ7}n0|jj |ƒ}|jj pC|jdk|_|d|j…}|jt|ƒ8_|jdkr‰d|_|j|ƒ|S)NrrLT)rìrèrrëZunconsumed_tailr7Ú_read2rrérTÚ MIN_READ_SIZErÉrÈrÄrêr )rurßrIrrrr…s2      zZipExtFile._read1cCs•|jdkrdSt||jƒ}t||jƒ}|jj|ƒ}|jt|ƒ8_|sjt‚|jdk r‘t t |j|ƒƒ}|S)NrrL) rérTr Úminrår/r7ÚEOFErrorræÚbytesÚmap)rurßrIrrrr ©szZipExtFile._read2c s/z|jr|jjƒWdtƒjƒXdS)N)rçrårÝÚsuper)ru)rzrrrݹs zZipExtFile.closeéi@ryry)rrrrrr ÚreÚcompilerþrvrƒrürýrr/r r rr rÝrr)rzrrã¶s  2 ! % $ rãc@sœeZdZdZdZdZdeddd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z ddd„Zdd„Zdd„Zdd„Zedd„ƒZejdd„ƒZddd„Zddd d!„Zddd"d#„Zdddd$d%„Zed&d'„ƒZd(d)„Zd*d+„Zddd,d-„Zdd.d/„Zd0d1„Zd2d3„Z d4d5„Z!d6d7„Z"dS)8r 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', 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. NÚrTcCsà|dkrtdƒ‚t|ƒ||_d|_d|_i|_g|_||_||_d|_ d |_ t |t ƒr#d|_ ||_dd dd dd dd d d d dd di}||}xyytj||ƒ|_Wn.tk r||kr||}wÑ‚YnXPqÑWn'd|_ ||_t|ddƒ|_d|_tjƒ|_d|_yD|dkr‡|jƒn'|dkr/d|_y|jjƒ|_Wn<ttfk rðt|jƒ|_d|_d|_Yq®Xy|jj|jƒWq®ttfk r+d|_Yq®Xn|dkr¢y!|jƒ|jj|jƒWq®tk rž|jjddƒd|_|jjƒ|_Yq®Xn tdƒ‚Wn*|j}d|_|j |ƒ‚YnXdS)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.rÚwÚxÚaz+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNrLr0zw+bzx+bzr+bÚwbZxbrròTrz"Mode must be 'r', 'w', 'x', or 'a')rrrr)rr)!rœrÒÚ _allowZip64Ú _didModifyÚdebugÚ NameToInfoÚfilelistrÑrñr²Ú_commentrµÚstrÚ _filePassedr3rúr2r-r,ÚgetattrÚ _fileRefCntÚ threadingÚRLockrÚÚ _seekableÚ_RealGetContentsrNÚ start_dirÚAttributeErrorrár5rÚ_fpclose)rurÛrñrÑÚ allowZip64ZmodeDictr~r-rrrrvÕs|                                  zZipFile.__init__cCs|S)Nr)rurrrÚ __enter__)szZipFile.__enter__cCs|jƒdS)N)rÝ)ruÚtypeÚvalueÚ tracebackrrrÚ__exit__,szZipFile.__exit__cCs¯d|jj|jjfg}|jdk rˆ|jrN|jd|jƒn#|jdk rq|jd|jƒ|jd|jƒn |jdƒ|jdƒdj|ƒS)Nz<%s.%sz file=%rz filename=%rz mode=%rz [closed]rwrx) rzrrr-r"rSr3rñr)rur4rrrrƒ/s    zZipFile.__repr__cCs–|j}yt|ƒ}Wntk r9tdƒ‚YnX|sLtdƒ‚|jdkret|ƒ|t}|t}|t|_ |t ||}|t t kr¶|t t8}|jdkrâ||}td|||ƒ|||_|j|jdƒ|j|ƒ}tj|ƒ}d}xi||kr‘|jtƒ} t| ƒtkrbtdƒ‚tjt| ƒ} | ttkr�tdƒ‚|jdkr©t| ƒ|j| tƒ} | d} | d @râ| jd ƒ} n| jd ƒ} t| ƒ} |j| tƒ| _|j| t ƒ| _!| t"| _#| dd …\ | _$| _%| _&| _'| _(| _)} }| _*| _+| _,| j&t-kr¨t.d | j&dƒ‚| dd…\| _/| _0| _1| | _2|d?d|d?d@|d@| d?| d?d@| d@df| _3| j4ƒ| j#|| _#|j5j6| ƒ| |j7| j8<|t| t| t| t }|jdkr)td|ƒq)WdS)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<r6r)r5r/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¡rrSrr3)rur-rHZsize_cdZ offset_cdÚconcatZinferredrIr3Úcentdirr3ÚflagsrÚ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Únamelist‹szZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the archive.)r)rurrrÚinfolist�szZipFile.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 ÚSizerÛz%d-%02d-%02d %02d:%02d:%02dNr"z %-46s %s %12d)rKrLrM)r4rrZr3rg)rurÛÚzinfoZdaterrrÚprintdir”s  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_sizerNÚfrrrÚtestzip�s 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)ruròÚinforrrÚgetinfoªs   zZipFile.getinfocCsK|r,t|tƒ r,tdt|ƒƒ‚|r>||_n d|_dS)z)Set default password for encrypted files.zpwd: expected bytes, got %sN)rµrÚ TypeErrorr.r²)rur²rrrÚ setpassword³s  zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)r )rurrrrX¼szZipFile.commentcCs€t|tƒs%tdt|ƒƒ‚t|ƒtkrjddl}|jdtddƒ|dt…}||_d|_ dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesÚ stacklevelrT) rµrrUr.r7ÚZIP_MAX_COMMENTÚwarningsÚwarnr r)rurXrYrrrrXÁs   c Cs-|j|d|ƒ�}|jƒSWdQRXdS)z)Return file bytes (as a string) for name.rN)r2r/)ruròr²r-rrrr/Îsz ZipFile.readc Csë|dkrtdƒ‚d|krCddl}|jdtdƒ|rot|tƒ rotd t|ƒƒ‚|js„td ƒ‚t|t ƒrœ|}n|j |ƒ}|j d 7_ t |j|j |j|jƒ}yô|jtƒ}t|ƒtkr td ƒ‚tjt|ƒ}|ttkr9td ƒ‚|j|tƒ}|trg|j|tƒ|jd@r€tdƒ‚|jd@r™tdƒ‚|jd@r¸|jdƒ} n|jdƒ} | |jkrïtd|j|fƒ‚|jd @} d} | r¸|s|j}|s-td|ƒ‚t |ƒ} |jdƒ} t!t"| | dd…ƒƒ} |jd@rˆ|j#d?d@}n|j$d?d@}| d|kr¸td|ƒ‚t%|||| dƒSWn|j&ƒ‚YnXdS)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 closedrzTruncated file headerz Bad magic number for file headeré z$compressed patched data (flag bit 5)é@zstrong encryption (flag bit 6)izutf-8r2z/File name in directory %r and header %r differ.z6File %s is encrypted, password required for extractionrrr«r˜r&zBad password for fileT)rrär[)'rœrYrZÚDeprecationWarningrµrrUr.r-r rTr$rÖrdr+rÚr/ÚsizeFileHeaderr7rr8r9r‹Ú _FH_SIGNATURErŒÚ_FH_FILENAME_LENGTHÚ_FH_EXTRA_FIELD_LENGTHr`rÔr=rYr²r£rRrrhrerãrÝ)ruròrñr²rYrNZzef_fileZfheaderÚfnameZ fname_strZ is_encryptedZzdr“ÚhZ check_byterrrr2Ósr         !              z ZipFile.opencCsIt|tƒs|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)rµr rTrnÚgetcwdÚ_extract_member)ruÚmemberÚpathr²rrrÚextract+s   zZipFile.extractcCs@|dkr|jƒ}x!|D]}|j|||ƒqWdS)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)rIri)rurhZmembersr²rörrrÚ 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|]}|jdƒVqdS)Ú.N)Úrstrip)rGrrrrú Osz1ZipFile._sanitize_windows_name..css|]}|r|VqdS)Nr)rGrrrrrnQs)Ú!_windows_illegal_name_trans_tabler!Ú maketransr7Ú translateÚsplitr)ÚclsÚarcnameÚpathsepr¦ZillegalrrrÚ_sanitize_windows_nameEs  zZipFile._sanitize_windows_namecs¸|jjdtjjƒ}tjjrE|jtjjtjjƒ}tjj|ƒd}dtjjtjjf‰tjjj ‡fdd†|j tjjƒDƒƒ}tjjdkr×|j |tjjƒ}tjj ||ƒ}tjj |ƒ}tjj |ƒ}|r6tjj|ƒ r6tj|ƒ|jd dkrltjj|ƒshtj|ƒ|S|j|d|ƒ�0}t|dƒ�}tj||ƒWd QRXWd QRX|S) zbExtract the ZipInfo object 'member' to a physical file on the path targetpath. rjrrxc3s!|]}|ˆkr|VqdS)Nr)rGr)Úinvalid_path_partsrrrnbsz*ZipFile._extract_member..ú\r²rNry)r3rprnrhroÚaltsepÚ splitdriveÚcurdirÚpardirrrrrvÚnormpathÚdirnameÚexistsÚmakedirsr‚Úmkdirr2ÚshutilZ copyfileobj)rurgZ targetpathr²rtZ upperdirsÚsourceÚtargetr)rwrrfTs* 7  zZipFile._extract_membercCsé|j|jkr8ddl}|jd|jddƒ|jdkrStd ƒ‚|jshtd ƒ‚t|jƒ|j såd}t |j ƒt kr¢d }n-|j tkrºd }n|jtkrÏd }|råt|dƒ‚dS)z6Check for errors before writing a file to the archive.rNzDuplicate name: %rrWrrrrz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedz Files countZFilesizez Zipfile sizez would require ZIP64 extensions)rrr)r3rrYrZrñrœr-rÒr[rr7rÚZIP_FILECOUNT_LIMITrgr„rdr )rurNrYÚrequires_zip64rrrÚ _writecheck{s(        zZipFile._writecheckcCs£|jstdƒ‚tj|ƒ}tj|jƒ}tj|jƒ}|dd…}|dkrj|}tj j tj j |ƒdƒ}x0|dtj tj fkr¾|dd…}q�W|rÏ|d7}t||ƒ}|dd@d>|_|rt|_n$|dkr |j|_n ||_|j|_d|_|j�U|jrd|jj|jƒ|jjƒ|_|jtkr”|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ƒ}|sÐP|t,|ƒ}t-|| ƒ} | r| j.|ƒ}| t,|ƒ} |jj%|ƒqºWWdQRX| rm| j/ƒ}| t,|ƒ} |jj%|ƒ| |_n ||_| |_ ||_|jd @rç| r¡dnd}|jj%t0j1||j |j|jƒƒ|jjƒ|_n‘| r'|j)r'|t*krtdƒ‚| t*kr'tdƒ‚|jjƒ|_|jj|jƒ|jj%|j&| ƒƒ|jj|jƒ|j!j"|ƒ||j#|j$|dd>B|dB}|dd>|d d>B|ddB}g}|jtks‰|jtkr¸|j|jƒ|j|jƒd }d }n|j}|j}|jtkrò|j|jƒd }n |j}|j} d} |rJtj d d t |ƒdd t |ƒ|Œ| } t } |j t krktt| ƒ} n|j tkr‰tt| ƒ} t| |jƒ} t| |jƒ} y…|jƒ\} }tj tt| |j| |j||j |||j||t | ƒt | ƒt |jƒd|j|j|ƒ}Wn‘tk rÅttt| |j| |j|j|j |||j||t |j ƒt | ƒt |jƒd|j|j|fdt!j"ƒ‚YnX|j#j$|ƒ|j#j$| ƒ|j#j$| ƒ|j#j$|jƒq W|j#j%ƒ}t |jƒ}||j&}|j&}d}|t'kr\d}n'|tkrqd}n|tkrƒd}|r7|j(s¢t)|dƒ‚tj t*t+ddddd||||ƒ }|j#j$|ƒtj t,t-d|dƒ}|j#j$|ƒt.|dƒ}t.|d ƒ}t.|d ƒ}tj t/t0dd||||t |j1ƒƒ }|j#j$|ƒ|j#j$|j1ƒ|j#j2ƒdS)Nri¼r$rr!rrr&r lÿÿzr:r;rrQrPr rÄ)rurNrŽr�r�r\rgrfrdZ extra_datar‘r^rJr3r`rCZpos2Z centDirCountZ centDirSizeZ centDirOffsetr†Z zip64endrecZ zip64locrecrHrrrr“Ns¬ &&            !            zZipFile._write_end_recordcCsF|jdkst‚|jd8_|j rB|j rB|jƒdS)Nrr)r$r·r"rÝ)rur-rrrr+³szZipFile._fpclose)#rrrrr-rorrvr-r1rƒr(rIrJrOrQrTrVÚpropertyrXÚsetterr/r2rirjÚ classmethodrvrfr‡râr‘r’rÝr“r+rrrrr Ás: T    N    X  ' h?   ec@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)rurÛrñrÑr,Úoptimizerrrrv½szPyZipFile.__init__rxNcCsŸ|rR||ƒ rR|jrNtjj|ƒr4dnd}td||fƒdStjj|ƒ\}}tjj|ƒr1tjj|dƒ}tjj|ƒrP|r¼d||f}n|}|jrÞtd|d|ƒ|j|d d…|ƒ\}} |jrtd | ƒ|j || ƒtj |ƒ} | j dƒxé| D]} tjj|| ƒ} tjj | ƒ\} }tjj| ƒrÈtjjtjj| dƒƒrI|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|dd…d krStdƒ‚|j|d d…|ƒ\}} |jr‹td| ƒ|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.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. rhrÛz%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ž)rrnrhr‚r4rrrÚisfileÚ _get_codenamerâÚlistdirÚremoveÚsplitextÚwritepyrœ)ruÚpathnameÚbasenamer�ZlabelÚdirròZinitnamercrtZdirlistr3rhÚrootZextrrrr¤Ãsv  "    !            "  zPyZipFile.writepyc síd ‡fdd†}|d}|d}tjj|ddƒ}tjj|ddƒ}tjj|ddƒ}ˆjdkrðtjj|ƒrÃtj|ƒjtj|ƒjkrÃ|} } q·tjj|ƒrtj|ƒjtj|ƒjkr|} |} q·tjj|ƒrMtj|ƒjtj|ƒjkrM|} |} q·tjj|ƒr’tj|ƒjtj|ƒjkr’|} |} q·||ƒrãt j j d kr¹|} n!t j j dkrÔ|} n|} |} q·|} } nLjjd kr|} |} nT|} ˆjdkr,|} n6ˆjdkrD|} nd j ˆjƒ} t | ƒ‚tjj| ƒo•tj| ƒjtj|ƒjks·||d ˆjƒs·|} } tjj| ƒd} |rãd || 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|jƒdSWYdd}~XnXdS)NrZ CompilingÚdoraiseTr›F)Ú py_compilerr4rÚPyCompileErrorÚmsg)rÛr›rªÚerr)rurrÚ_compiles    z)PyZipFile._get_codename.._compilez.pyz.pycÚ optimizationrxrrz"invalid value for 'optimize': {!r}r›z%s/%sryry)Ú importlibÚutilÚcache_from_sourceršrnrhrŸr}rŒrrrDr›Úformatrqrr) rur¥r¦r®Zfile_pyZfile_pycZ pycache_opt0Z pycache_opt1Z pycache_opt2rtrcr¬Z archivenamer)rurr s`  $ $ $ $          $ zPyZipFile._get_codenamery)rrrrrrvr¤r rrrrr ºs Qc s«ddl}|jdƒ}|dkr:tjdd…}| sQ|ddkrht|ƒtjdƒ|ddkrËt|ƒdkr¡t|ƒtjdƒt|dd ƒ�}|jƒWdQRXnÜ|ddkrSt|ƒdkrt|ƒtjdƒt|dd ƒ�}|j ƒ}WdQRX|rFtd j |ƒƒtd ƒnT|ddkr½t|ƒd krŒt|ƒtjdƒt|dd ƒ�}|j |dƒWdQRXnê|ddkr§t|ƒd kröt|ƒtjdƒ‡fd d†‰t|ddƒ�‰}x|dd…D]m}t j j|ƒ}|skt j jt j j|ƒƒ}|dt jt jfkrŒd}ˆ|||ƒq/WWdQRXdS)NraE Usage: zipfile.py -l zipfile.zip # Show listing of a zipfile zipfile.py -t zipfile.zip # Test if a zipfile is valid zipfile.py -e zipfile.zip target # Extract zipfile into target dir zipfile.py -c zipfile.zip src ... # Create zipfile from sources rú-lú-cú-eú-trrz.The following enclosed file is corrupted: {!r}z Done testingrcsœtjj|ƒr(|j||tƒnptjj|ƒr˜|rP|j||ƒxEtj|ƒD]4}ˆ|tjj||ƒtjj||ƒƒq`WdS)N)rnrhrŸrârr‚r¡r)ÚzfrhÚzippathZnm)ÚaddToZiprrrº•szmain..addToZiprrx)r´rµr¶r·)ÚtextwrapÚdedentrrÚargvr4Úexitr7r rOrQr³rjrnrhr¦r~r{r|)Úargsr»ZUSAGEr¸Zbadfilerhr¹r)rºrÚmaingsT               rÀÚ__main__)}rrúrnrÚimportlib.utilr°rrrŠr}r‚r8Zbinasciir%Ú ImportErrorZdummy_threadingrÏrôrÐr¾Ú__all__Ú Exceptionrr rrr„r…rXrrrrrtr‡rˆr‰rArQrPr†rOr?r@rArBrCrDrErVr5r6r9r;r8r: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‹rŒr_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_SIZErarbr: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 r rÀrrrrrÚs.                         + =²=   ÿ ÿÿû­B