grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B Ö p–‘Û·Ùã@s dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z yddl Z e j Z Wnek r„dZ e j Z YnXy ddlZWnek rªdZYnXy ddlZWnek rÐdZYnXddddddd d d d d dg ZGdd„deƒZGdd„deƒZeZZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$e  %e#¡Z&dZ'dZ(dZ)dZ*dZ+d Z,d!Z-d"Z.dZ/d#Z0d$Z1d%Z2e  %e1¡Z3dZ4dZ5dZ6dZ7dZ8d Z9d!Z:d"Z;dZd'Z?dZ@d(ZAdZBd)ZCd*ZDd+ZEd,ZFd-ZGd.ZHe  %eG¡ZIdZJdZKdZLdZMdZNd ZOd!ZPd"ZQdZRd#ZSd&ZTd'ZUd/ZVd0ZWe  %eV¡ZXd1ZYd2ZZe  %eY¡Z[dZ\dZ]dZ^dZ_dZ`d Zad!Zbd"ZcdZdd#Zed3Zfe  gd4¡Zhd5d6„Zid7d8„Zjd9d „Zkd:d;„Zldd „d enƒZodapd?d@„ZqdAdB„ZrGdCdD„dDƒZsGdEdF„dFƒZtdGdHdIdIdIdIdJdKdLdMdJdNdOdPdQdRdSdTœZudUdV„ZvdhdWdX„ZwdYdZ„ZxGd[d\„d\ƒZyGd]d^„d^ƒZzGd_d`„d`ej{ƒZ|Gdadb„dbej{ƒZ}Gdcd „d ƒZ~Gddd „d e~ƒZdidedf„Z€e�dgk�rœe€ƒdS)jzP 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@s eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©rrú,/opt/alt/python37/lib64/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 *siÿÿÿiÿÿéé ééé-é.é?s<4s4H2LHsPKéééééééé z<4s4B4HL2L5H2LsPKé é é ééééz <4s2B4HL2L2HsPKz<4sLQLsPKz <4sQ2H2L4QsPKiPKz        r6c@sVeZdZdZdZddd„Zdd„Zdd d „Zd d „Zdd„Z e ddd„ƒZ dd„Z d S)r z>Class with attributes describing each file in the ZIP archive.)Ú orig_filenamer>Ú date_timeÚ compress_typeÚ_compresslevelr^r0Ú create_systemrSÚextract_versionÚreservedÚ flag_bitsÚvolumeÚ internal_attrÚ external_attrÚ header_offsetÚCRCÚ compress_sizeÚ file_sizeÚ _raw_timeÚNoName©i¼rrrrrcCsÈ||_| tdƒ¡}|dkr(|d|…}tjdkrJtj|krJ| tjd¡}||_||_|ddkrjtdƒ‚t |_ d|_ d|_ d|_ tjdkr”d|_nd|_t|_t|_d|_d|_d|_d|_d|_dS)Nrú/i¼z+ZIP does not support timestamps before 1980r*Zwin32r)r_ÚfindÚchrÚosÚsepÚreplacer>r`Ú ValueErrorrrarbr^r0ÚsysÚplatformrcÚDEFAULT_VERSIONrSrdrerfrgrhri)Úselfr>r`Z null_byterrrÚ__init__Ss0   zZipInfo.__init__cCsÜd|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'iÿÿz filemode=%rz external_attr=%#xz file_size=%rz compress_size=%rú>Ú)Ú __class__rr>rarr.Úcompressor_namesÚgetriÚstatÚfilemodeÚis_dirrmrlr/)r{r?ÚhiÚloÚisdirrrrÚ__repr__~s(         zZipInfo.__repr__NcCs||j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd @rfd}}}n|j}|j}|j}|j}d} |d krš|tkp˜|tk}|rÂd } |t | dt  | ¡d ||¡}|tksÒ|tkrê|sÞt d ƒ‚d}d}t } |j t k�rtt| ƒ} n|j tk�rtt| ƒ} t| |jƒ|_t| |jƒ|_| ¡\} } t tt|j|j| |j |||||t| ƒt|ƒ¡ } | | |S)z-Return the per-file header as a bytes object.ri¼r"rrrrr$rrNzrfÚheaderrrrÚ FileHeader”sF$$        zZipInfo.FileHeadercCs>y|j d¡|jfStk r8|j d¡|jdBfSXdS)NÚasciizutf-8i)r>ÚencoderfÚUnicodeEncodeError)r{rrrr�ÂszZipInfo._encodeFilenameFlagscCsŒ|j}tj}�xxt|ƒdk�r†|d|dd…ƒ\}}|dt|ƒkrTtd||fƒ‚|dk�rt|dkrz|d|dd…ƒ}nV|dkr–|d |dd …ƒ}n:|d kr²|d |dd …ƒ}n|dkrÀd}ntd||fƒ‚d}|jdk�rt|ƒ|krôtdƒ‚|||_|d7}|jdk�r:t|ƒ|k�r(tdƒ‚|||_|d7}|jdk�rtt|ƒ|k�r\tdƒ‚|j}|||_|d7}||dd…}qWdS)Nrz|_|rÎd|_|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 Nrrqiÿÿr')Ú isinstancertÚPathLikeÚfspathr‚ÚS_ISDIRÚst_modeÚtimeÚ localtimeÚst_mtimeÚpathÚnormpathÚ splitdriveruÚaltseprirmÚst_size)Úclsr>ÚarcnameÚstr‡Úmtimer`ÚzinforrrÚ from_fileús(       zZipInfo.from_filecCs|jddkS)z2Return True if this archive member is a directory.éÿÿÿÿrq)r>)r{rrrr„szZipInfo.is_dir)rorp)N)N) rrrrÚ __slots__r|rˆr™r�r¢Ú classmethodrµr„rrrrr 9s + .2 !cCs4x.tdƒD]"}|d@r$|d?dA}q |dL}q W|S)Nrrl q[)Úrange)Úcrcr4rrrÚ_gen_crc&s  r»cspd‰d‰d‰tdkr&ttttdƒƒƒat‰‡fdd„‰‡‡‡‡fdd„‰x|D] }ˆ|ƒqNW‡‡fd d „}|S) NixV4i‰gE#i�xV4écs|d?ˆ||Ad@AS)z(Compute the CRC32 primitive on one byte.réÿr)Zchrº)ÚcrctablerrÚcrc32@sz_ZipDecrypter..crc32cs<ˆ|ˆƒ‰ˆˆd@d@‰ˆddd@‰ˆˆd?ˆƒ‰dS)Nr½lÿÿi„rr�r)Úc)r¿Úkey0Úkey1Úkey2rrÚ update_keysDs z"_ZipDecrypter..update_keyscsRtƒ}|j}x<|D]4}ˆdB}|||dAd?d@N}ˆ|ƒ||ƒqWt|ƒS)zDecrypt a bytes object.rrrr½)Ú bytearrayr.Úbytes)rRr?r.rÀÚk)rÃrÄrrÚ decrypterNs  z _ZipDecrypter..decrypter)Ú _crctablerZÚmapr»r¹)ÚpwdÚprÈr)r¿r¾rÁrÂrÃrÄrÚ _ZipDecrypter6s    rÍc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚLZMACompressorcCs d|_dS)N)Ú_comp)r{rrrr|^szLZMACompressor.__init__cCsFt dtji¡}tjtjt tj|¡gd�|_t dddt |ƒ¡|S)NÚid)ÚfilterszÚnamer<rkÚ _expected_crcr¿Ú _running_crcÚ _seekableròrVÚ_orig_compress_startÚ_orig_compress_sizeÚ_orig_file_sizeÚ_orig_start_crcÚAttributeErrorÚ _decrypterrfrnÚ_init_decrypterrär_)r{rùrÚzipinforËZ close_fileobjZ check_byteÚhrrrr|sF       zZipExtFile.__init__cCs4t|jƒ|_|j d¡}|jd8_| |¡dS)Nrr$)rÍrþrrýr:r)r{r˜rrrrRs  zZipExtFile._init_decryptercCsvd|jj|jjfg}|jsX| d|j|jf¡|jtkrb| dt   |j|j¡¡n | d¡| d¡d  |¡S)Nz<%s.%sz name=%r mode=%rz compress_type=%sz [closed]r}r~) rrrÚclosedr.r rrrr€r�r/)r{r?rrrrˆ]s   zZipExtFile.__repr__r¶cCsL|dkr>|j d|j¡d}|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)rrrrÚioÚBufferedIOBaseÚreadline)r{Úlimitr3ÚlinerrrrkszZipExtFile.readlinercCsr|t|jƒ|jkr\| |¡}t|ƒ|jkrJ||j|jd…|_d|_n|jt|ƒ8_|j|j|jd…S)z6Returns buffered bytes without advancing the position.Nri)r-rrr:)r{røÚchunkrrrÚpeek{s zZipExtFile.peekcCsdS)NTr)r{rrrÚreadableˆszZipExtFile.readablecCs |dks|dkrL|j|jd…}d|_d|_x|jsF|| |j¡7}q.W|S||j}|t|jƒkr~|j|j|…}||_|S|t|jƒ}|j|jd…}d|_d|_x^|dk�r|j�s| |¡}|t|ƒkrð||_||_||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. Nrr*)rrrÚ_read1ÚMAX_Nr-)r{røÚbufÚendrRrrrr:‹s4   zZipExtFile.readcCs@|jdkrdSt||jƒ|_|jr<|j|jkr      zZipExtFile.read1cCs"|js|dkrdS|jtkrH|jj}|t|ƒkrR|| |t|ƒ¡7}n | |¡}|jtkrj|jdk|_nx|jtkrÂt ||j ƒ}|j  ||¡}|jj p¨|jdko¨|jj |_|jrâ||j  ¡7}n |j  |¡}|jj pÞ|jdk|_|d|j…}|jt|ƒ8_|jdk�rd|_| |¡|S)Nrr*T)rrrrZunconsumed_tailr-Ú_read2rrr[Ú MIN_READ_SIZErÝrÜrØrr%)r{rørRrrrr Ûs2           zZipExtFile._read1cCsd|jdkrdSt||jƒ}t||jƒ}|j |¡}|jt|ƒ8_|sLt‚|jdk r`| |¡}|S)Nrr*) rr[r(Úminrýr:r-ÚEOFErrorr)r{rørRrrrr'ÿs      zZipExtFile._read2cs&z|jr|j ¡Wdtƒ ¡XdS)N)rÿrýrõÚsuper)r{)rrrrõszZipExtFile.closecCs|jS)N)r )r{rrrròszZipExtFile.seekablercCsB|jst d¡‚| ¡}|dkr&|}n.|dkr8||}n|dkrL|j|}ntdƒ‚||jkrd|j}|dkrpd}||}||j}|dkr¤|t|jƒkr¤||_d}nf|dk�r |j   |j ¡|j |_ |j|_|j|_d|_d|_t|jƒ|_d|_|}|jdk �r | ¡x.|dk�r8t|j|ƒ}| |¡||8}�q W| ¡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 rÚUnsupportedOperationrVrrwrr-rrýr@r rr rrrrërrrrrr)Ú MAX_SEEK_READr:)r{rPr÷Zcurr_posZnew_posZ read_offsetZ buff_offsetZread_lenrrrr@sH           zZipExtFile.seekcCs0|jst d¡‚|j|jt|jƒ|j}|S)Nz!underlying stream is not seekable)r rr,rrr-rr)r{ZfileposrrrrVIs zZipExtFile.tell)NF)r¶)r)r¶)r)rrrrr!r(r-r|rrˆrrrr:r%r&r r'rõròr@rVÚ __classcell__rr)rrrüs( 2    ! %$  0rücs@eZdZdd„Zedd„ƒZdd„Zdd„Z‡fd d „Z‡Z S) Ú _ZipWriteFilecCs8||_||_||_t|j|jƒ|_d|_d|_d|_ dS)Nr) Ú_zinfoÚ_zip64Ú_zipfilerêrarbÚ _compressorÚ _file_sizeÚ_compress_sizeÚ_crc)r{Úzfr´r’rrrr|Qs z_ZipWriteFile.__init__cCs|jjS)N)r2r8)r{rrrrý[sz_ZipWriteFile._fileobjcCsdS)NTr)r{rrrÚwritable_sz_ZipWriteFile.writablecCsf|jrtdƒ‚t|ƒ}|j|7_t||jƒ|_|jrV|j |¡}|jt|ƒ7_|j   |¡|S)NzI/O operation on closed file.) rrwr-r4r¿r6r3r×r5rýrû)r{rRÚnbytesrrrrûbs  z_ZipWriteFile.writec sb|jr dS�zFtƒ ¡|jrR|j ¡}|jt|ƒ7_|j |¡|j|j _ n |j |j _ |j |j _ |j |j _|j jd@rÀ|jr†dnd}|j t |t|j j |j j |j j¡¡|j ¡|j_nn|jsê|j tkrØtdƒ‚|jtkrêtdƒ‚|j ¡|j_|j |j j¡|j |j  |j¡¡|j |jj¡|jj |j ¡|j |jj|j j<Wdd|j_ XdS)Nrzrñ)r{r"r—)rrrrõns>          z_ZipWriteFile.close) rrrr|Úpropertyrýr8rûrõr.rr)rrr/Ps   r/c@seZdZdZdZdZdeddfdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd d!œd"d#„Zd?d$d%„Zd@d&d'„ZdAd(d)„Zed*d+„ƒZd,d-„Zd.d/„ZdBd0d1„ZdCd2d3„Zd4d5„Z d6d7„Z!d8d9„Z"d:d;„Z#dS)Dr ai 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. NÚrTc CsL|dkrtdƒ‚t|ƒ||_d|_d|_i|_g|_||_||_||_ d|_ d|_ t |t jƒrjt  |¡}t |tƒrâd|_||_ddd d dd d d œ}||}x^yt ||¡|_Wn(tk rØ||krÒ||}wž‚YnXPqžWnd|_||_t|ddƒ|_d|_t ¡|_d|_d|_�y|dk�r0| ¡nð|dk�rºd|_y|j ¡|_ Wn2t!tfk �r‚t"|jƒ|_d|_ d|_Yn6Xy|j #|j ¡Wn t!tfk �r¶d|_YnXnf|dk�ry| ¡|j #|j ¡Wn6t$k �r|j #dd¡d|_|j ¡|_ YnXntdƒ‚Wn$|j}d|_| %|¡‚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'FrNr*r;zw+bzx+bzr+bÚwbZxb)r?r@rArBzr+bzw+bzx+brr Tr?)r@rArBrz"Mode must be 'r', 'w', 'x', or 'a')&rwrèÚ _allowZip64Ú _didModifyÚdebugr=r<rçrérrËÚ_commentr£rtr¤r¥ÚstrÚ _filePassedr>rr=r8r7ÚgetattrÚ _fileRefCntÚ threadingÚRLockrðr rñÚ_RealGetContentsrVr;rrúr@rÚ_fpclose) r{rórrçÚ allowZip64réZmodeDictrƒr8rrrr|¸s„             zZipFile.__init__cCs|S)Nr)r{rrrÚ __enter__szZipFile.__enter__cCs | ¡dS)N)rõ)r{ÚtypeÚvalueÚ tracebackrrrÚ__exit__szZipFile.__exit__cCs‚d|jj|jjfg}|jdk rd|jr8| d|j¡n|jdk rR| d|j¡| d|j¡n | d¡| d¡d |¡S)Nz<%s.%sz file=%rz filename=%rz mode=%rz [closed]r}r~) rrrr8rIr.r>rr/)r{r?rrrrˆs    zZipFile.__repr__c Cs¾|j}y t|ƒ}Wntk r.tdƒ‚YnX|s)r{r8rQZsize_cdZ offset_cdÚconcatZinferredrRrXÚcentdirr>ÚflagsrAÚtÚdrrrrN%sp                4       zZipFile._RealGetContentscCsdd„|jDƒS)z+Return a list of file names in the archive.cSsg|] }|j‘qSr)r>)Ú.0rRrrrú usz$ZipFile.namelist..)r<)r{rrrÚnamelistsszZipFile.namelistcCs|jS)zJReturn a list of class ZipInfo instances for files in the archive.)r<)r{rrrÚinfolistwszZipFile.infolistcCsPtdd|d�x:|jD]0}d|jdd…}td|j||jf|d�qWdS)z+Print a table of contents for the zip file.z%-46s %19s %12s)z File Namez Modified ZSize)róz%d-%02d-%02d %02d:%02d:%02dNr z %-46s %s %12d)rYr<r`r>rm)r{rór´ZdaterrrÚprintdir|s  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)r<r=r>r:r)r{Z chunk_sizer´ÚfrrrÚtestzip…s  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=r�ÚKeyError)r{r ÚinforrrÚgetinfo’s   zZipFile.getinfocCs6|r t|tƒs tdt|ƒjƒ‚|r,||_nd|_dS)z)Set default password for encrypted files.zpwd: expected bytes, got %sN)r£rÆÚ TypeErrorrRrrË)r{rËrrrÚ setpassword›s zZipFile.setpasswordcCs|jS)z.The comment text associated with the ZIP file.)rG)r{rrrr^¤szZipFile.commentcCs^t|tƒstdt|ƒjƒ‚t|ƒtkrNddl}|jdtdd�|dt…}||_ d|_ dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr)Ú stacklevelT) r£rÆrvrRrr-ÚZIP_MAX_COMMENTÚwarningsÚwarnrGrE)r{r^rzrrrr^©s    c Cs"| |d|¡� }| ¡SQRXdS)zReturn file bytes for name.r?N)r=r:)r{r rËr8rrrr:¶sz ZipFile.readF)Ú force_zip64c s|dkrtdƒ‚|r0t|tƒs0tdt|ƒjƒ‚|rD|dkrDtdƒ‚ˆjsRtdƒ‚t|tƒrb|}n,|dkr„t|ƒ}ˆj|_ ˆj |_ n ˆ  |¡}|dkr¤ˆj ||d�Sˆjr²tdƒ‚ˆjd 7_tˆj|jˆjˆj‡fd d „ƒ}�y| t¡}t|ƒtk�rtd ƒ‚t t|¡}|ttk�r&td ƒ‚| |t¡}|t�rL| |t¡|jd@�r`t dƒ‚|jd@�rtt dƒ‚|jd@�rŒ| !d¡} n | !d¡} | |j"k�r´td|j"|fƒ‚|jd @} | �rä|�sЈj#}|�sèt$d|ƒ‚nd}t%||||dƒS| &¡‚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)r|zyCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.rcsˆjS)N)rñr)r{rrÚìr*zZipFile.open..zTruncated file headerz Bad magic number for file headeré z$compressed patched data (flag bit 5)é@zstrong encryption (flag bit 6)izutf-8rVz/File name in directory %r and header %r differ.z6File %r is encrypted, password required for extractionNT)'rwr£rÆrvrRrr8r rçrarérbruÚ_open_to_writerñrKrìrjrOrðr:ÚsizeFileHeaderr-rrBr,r�Ú _FH_SIGNATUREr‘Ú_FH_FILENAME_LENGTHÚ_FH_EXTRA_FIELD_LENGTHrfrærbr_rËrärürõ) r{r rrËr|r´Zzef_fileZfheaderÚfnameZ fname_strZ is_encryptedr)r{rr=»sp                z ZipFile.opencCsæ|r|jstdƒ‚|jr tdƒ‚t|dƒs0d|_d|_d|_d|_|jt krZ|jdO_|j sn|jdO_|j szd|_ |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.rmrrri€gÍÌÌÌÌÌð?T)rDrwrñr<rmrlrkrfrarr rir‰r8r@r;rVrjÚ _writecheckrErûr™r/)r{r´r|r’rrrr€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)rtÚgetcwdr¥Ú_extract_member)r{Úmemberr«rËrrrÚextractHs  zZipFile.extractcCsL|dkr| ¡}|dkr"t ¡}n t |¡}x|D]}| |||¡q2WdS)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)rnrtr‡r¥rˆ)r{r«ÚmembersrËrrrrÚ extractallUs   zZipFile.extractallcCs^|j}|s(d}t |dt|ƒ¡}||_| |¡}dd„| |¡Dƒ}| dd„|Dƒ¡}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*Ú_css|]}| d¡VqdS)Ú.N)Úrstrip)rlrArrrú psz1ZipFile._sanitize_windows_name..css|]}|r|VqdS)Nr)rlrArrrr�rs)Ú!_windows_illegal_name_trans_tablerHÚ maketransr-Ú translateÚsplitr/)r°r±ÚpathsepÚtableZillegalrrrÚ_sanitize_windows_namefs zZipFile._sanitize_windows_namec sLt|tƒs| |¡}|j dtjj¡}tjjrB| tjjtjj¡}tj  |¡d}dtjj tjj f‰tjj  ‡fdd„|  tjj¡Dƒ¡}tjjdkr¦| |tjj¡}tj  ||¡}tj |¡}tj |¡}|rætj |¡sæt |¡| ¡�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)rlrA)Úinvalid_path_partsrrr�†sz*ZipFile._extract_member..ú\)rËrCN)r£r rur>rvrtr«rur®r­ÚcurdirÚpardirr/r”r—r¬ÚdirnameÚexistsÚmakedirsr„r‡Úmkdirr=ÚshutilÚ copyfileobj)r{r‰Z targetpathrËr±Z upperdirsÚsourceÚtargetr)r˜rrˆus.  &        zZipFile._extract_membercCs¢|j|jkr(ddl}|jd|jdd�|jdkr:tdƒ‚|jsHtdƒ‚t|jƒ|j sžd}t |j ƒt krpd }n|j tkr€d }n|jtkrŽd }|ržt|d ƒ‚dS) z6Check for errors before writing a file to the archive.rNzDuplicate name: %rr)rx)r@rArBz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedz Files countZFilesizez Zipfile sizez would require ZIP64 extensions)r>r=rzr{rrwr8rèrarDr-r<ÚZIP_FILECOUNT_LIMITrmr‰rjr )r{r´rzÚrequires_zip64rrrr†Ÿs(     zZipFile._writecheckc CsJ|jstdƒ‚|jrtdƒ‚t ||¡}| ¡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 ¡|_WdQRXnCan't write to ZIP archive while an open writing handle existsrNrTFr;r@i )r8rwrñr rµr„rlrkrarçrbrérðr r@r;rVrjrrfr†rEr<r.r=r>rûr™r=r r¡)r{r>r±rarér´ÚsrcÚdestrrrrû¶s>       z ZipFile.writec Csøt|tƒr| d¡}t|tƒsxt|t t ¡¡dd…d�}|j|_|j|_ |j ddkrpd|_ |j dO_ q|d |_ n|}|j sŠt d ƒ‚|jr˜t 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`r¶rqiýAr'i€z7Attempt to write to ZIP archive that was already closedz?Can't write to ZIP archive while an open writing handle exists.r@)r)r£rHr›r r¨r©rçrarérbr>rir8rwrñr-rmrðr=rû)r{Zzinfo_or_arcnamerRrarér´r§rrrÚwritestræs4    zZipFile.writestrcCs | ¡dS)z2Call the "close()" method in case the user forgot.N)rõ)r{rrrÚ__del__szZipFile.__del__c Cs||jdkrdS|jrtdƒ‚zB|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@rArB) r8rñrwrrErðr r@r;Ú_write_end_recordrO)r{r8rrrrõs z ZipFile.closecCsr�xP|jD�]D}|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}g}|jtksv|jtkr˜| |j¡| |j¡d }d }n |j}|j}|jtkrÀ| |j¡d }n|j}|j} d} |�rt| d ƒ} t j d d t |ƒddt |ƒf|žŽ| } t } |j tk�r(tt| ƒ} n|j tk�r>tt| ƒ} t| |jƒ} t| |jƒ} yZ| ¡\} }t   tt| |j| |j||j |||j||t | ƒt | ƒt |jƒd|j|j|¡}Wnltk �rttt| |j| |j|j |j |||j||t |j!ƒt | ƒt |jƒd|j|j|ft"j#d�‚YnX|j$ %|¡|j$ %| ¡|j$ %| ¡|j$ %|j¡q W|j$ &¡}t |jƒ}||j'}|j'}d}|t(k�rŒd}n|tk�rœd}n|tk�rªd}|�r*|j)�sÄt*|dƒ‚t   t+t,ddddd||||¡ }|j$ %|¡t   t-t.d|d¡}|j$ %|¡t/|dƒ}t/|d ƒ}t/|d ƒ}t   t0t1dd||||t |j2ƒ¡ }|j$ %|¡|j$ %|j2¡|j$ 3¡dS)Nri¼r"rrrrr$rlÿÿ)rzrxÚstderrr8rûrVr;r¤rDr rFrGrCrDr)rYrXrGrØ)r{r´r“r”r•r0rmrlrjZ extra_datar–rdrSr>rfrhZpos2Z centDirCountZ centDirSizeZ centDirOffsetr¥Z zip64endrecZ zip64locrecrQrrrrª)s®$$                                     zZipFile._write_end_recordcCs4|jdkst‚|jd8_|js0|js0| ¡dS)Nrr)rKÚAssertionErrorrIrõ)r{r8rrrrO�s zZipFile._fpclose)N)N)r?N)F)NN)NNN)NNN)NN)$rrrrr8r‘rr|rQrUrˆrNrnrorprrrurwr>r^Úsetterr:r=r€rŠrŒr¸r—rˆr†rûr¨r©rõrªrOrrrrr žs@ XN     b +  * 0 (fc@s4eZdZdZdeddfdd„Zd d d „Zd d „ZdS)r zDClass to create ZIP archives with Python library files and packages.r?Tr¶cCstj|||||d�||_dS)N)rrçrP)r r|Ú _optimize)r{rórrçrPÚoptimizerrrr|™s zPyZipFile.__init__r~NcCsÄt |¡}|rD||ƒsD|jr@tj |¡r,dnd}td||fƒdStj |¡\}}tj |¡�rptj |d¡}tj |¡�r¼|r�d||f}n|}|jr¨td|d|ƒ|  |d d …|¡\}} |jrÐtd | ƒ|  || ¡t t  |¡ƒ} |   d¡xÄ| D]¼} tj || ¡} tj | ¡\} }tj | ¡�rTtj tj | d¡¡�r¶|j| ||d �qú|d krú|�r€|| ƒ�s€|jrútd| ƒqú|  | d d …|¡\}} |j�rªtd | ƒ|  || ¡qúWn²|j�rÎtd|ƒxðt t  |¡ƒD]Œ} tj || ¡} tj | ¡\} }|d k�rÞ|�r2|| ƒ�s2|j�rÞtd| ƒ�qÞ|  | d d …|¡\}} |j�r\td | ƒ|  || ¡�qÞWnP|d d…d k�rŠtdƒ‚|  |d d …|¡\}} |j�r´td| ƒ|  || ¡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. r«róz%s %r skipped by filterfuncNz __init__.pyz%s/%szAdding package inÚasréýÿÿÿZAdding)Ú filterfuncz.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding file)rtr¥rFr«r‡rYr”r/ÚisfileÚ _get_codenamerûÚsortedÚlistdirÚremoveÚsplitextÚwritepyrä)r{ÚpathnameÚbasenamerµZlabelÚdirr Zinitnamer…r±Zdirlistr>r«ÚrootZextrrrr¼Ÿsx                zPyZipFile.writepyc sd‡fdd„ }|d}|d}tjj|dd�}tjj|dd�}tjj|d d�}ˆjdk�r\tj |¡rˆt |¡jt |¡jkrˆ|} } nÒtj |¡r¶t |¡jt |¡jkr¶|} |} n¤tj |¡rät |¡jt |¡jkrä|} |} nvtj |¡�rt |¡jt |¡jk�r|} |} nD||ƒ�rRt j j d k�r4|} nt j j dk�rH|} n|} |} n|} } n’ˆjd k�rr|} |} n<|} ˆjdk�rˆ|} n&ˆjd k�rš|} nd   ˆj¡} t | ƒ‚tj | ¡�rÖt | ¡jt |¡jk�sî||ˆ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). r¶c s`ddl}ˆjrtd|ƒy|j|d|d�Wn.|jk rZ}zt|jƒdSd}~XYnXdS)NrZ CompilingT)Údoraiser²F)Ú py_compilerFrYÚcompileÚPyCompileErrorÚmsg)rór²rÂÚerr)r{rrÚ_compileøs  z)PyZipFile._get_codename.._compilez.pyz.pycr~)Ú optimizationrrrz"invalid value for 'optimize': {!r})r²z%s/%s)r¶)Ú importlibÚutilÚcache_from_sourcer±rtr«r¶r‚rªrxrir²Úformatrwr”) r{r½r¾rÇZfile_pyZfile_pycZ pycache_opt0Z pycache_opt1Z pycache_opt2r±r…rÅZ archivenamer)r{rr·ñs`             zPyZipFile._get_codename)r~N)rrrrrr|r¼r·rrrrr –s  Rc sÌddl}d}|j|d�}|jdd�}|jdddd d �|jd d d ddd�|jdddddd�|jddddd �| |¡}|jdk rÆ|j}t|dƒ�}| ¡}WdQRX|rºtd  |¡ƒtdƒ�n|j dk rö|j }t|dƒ�}|  ¡WdQRXnÒ|j dk �r.|j \}}t|dƒ�}|  |¡WdQRXnš|jdk �rÈ|j d¡} |j} ‡fdd„‰t| dƒ�`}xX| D]P} tj | ¡} | �s”tj tj | ¡¡} | dtjtjfk�r¬d} ˆ|| | ƒ�qjWWdQRXdS) Nrz3A simple command-line interface for zipfile module.)Ú descriptionT)Zrequiredz-lz--listz zShow listing of a zipfile)ÚmetavarÚhelpz-ez --extractr)z z zExtract zipfile into target dir)ÚnargsrÎrÏz-cz--createú+)zzzCreate zipfile from sourcesz-tz--testzTest if a zipfile is validr?z.The following enclosed file is corrupted: {!r}z Done testingcsttj |¡r| ||t¡nTtj |¡rp|r8| ||¡x6tt |¡ƒD]$}ˆ|tj ||¡tj ||¡ƒqHWdS)N) rtr«r¶rûrr‡r¸r¹r/)r7r«ÚzippathZnm)ÚaddToZiprrrÓls   zmain..addToZipr@r~)ÚargparseÚArgumentParserZadd_mutually_exclusive_groupÚ add_argumentÚ parse_argsZtestr rrrYrÌrZrprŠrŒZcreateÚpoprtr«r¾rœršr›) ÚargsrÔrÍÚparserÚgroupr¦r7ZbadfileršZzip_nameÚfilesr«rÒr)rÓrÚmainDsT                    rÝÚ__main__)N)N)‚rrrtÚimportlib.utilrÉrxr¨r‚r rBZbinasciirLrãr¿Ú ImportErrorrårÒÚ__all__Ú Exceptionrr rrr‰r¤ryrrrrrzrŒr�rŽrfrYrXr‹rWrHrIrJrKrLrMrNr]rZr[r^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_SIZErarcrdZ_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESrer�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_SIZErƒr„rCrDrArFrGrEZ_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:ZStructr+r5r9r rTr6Úobjectr rÉr»rÍrÎrÙr€rèrêrërìrúrrür/r r rÝrrrrrÚs>             +=m& &AN}/ <