o !QdZ]@sB ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZz ddlZejZWneyPdZejZYnwzddlZWn eybdZYnwzddlZWn eytdZYnwgdZGdddeZGdddeZeZZdZdZdZdZd Zd Zd Z d Z!d Z"dZ#dZ$dZ%dZ&dZ'e (e&Z)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2dZ3dZ4dZ5e (e4Z6dZ7dZ8dZ9dZ:dZ;dZd Z?dZ@dZAdZBd ZCdZDd ZEdZFd ZGd!ZHd"ZId#ZJd$ZKe (eJZLdZMdZNdZOdZPdZQdZRdZSdZTd ZUdZVdZWdZXd%ZYd&ZZe (eYZ[d'Z\d(Z]e (e\Z^dZ_dZ`dZadZbdZcdZddZedZfd ZgdZhd)Zie jd*Zkd+d,Zld-d.Zmd/d0Znd1d2Zod3d4ZpGd5d6d6eqZrdasd7d8Ztd9d:ZuGd;d<d<ZvGd=d>d>Zwidd?dd@ddAddAddAddAddBddCd dDddEddBd dFd dGd"dHdIdJdKdLdMdNZxdOdPZydrdQdRZzdSdTZ{GdUdVdVZ|GdWdXdXZ}GdYdZdZej~ZGd[d\d\ej~ZGd]d^d^ZGd_d`d`eZdadbZdcddZejZ dedfZGdgdhdheZGdidjdjeZdrdkdlZGdmdndnZdrdodpZedqkredSdS)sN) BadZipFile BadZipfileerror ZIP_STORED ZIP_DEFLATED ZIP_BZIP2ZIP_LZMA is_zipfileZipInfoZipFile PyZipFile LargeZipFilePathc@ eZdZdS)rN__name__ __module__ __qualname__rr./opt/alt/python310/lib64/python3.10/zipfile.pyr+rc@r)r Nrrrrrr /rr i -.?s<4s4H2LHsPK z<4s4B4HL2L5H2LsPK z <4s2B4HL2L2HsPKz<4sLQLsPKz <4sQ2H2L4QsPKiPKrrrr s      r c Cs z ||tdWn ty|YSw|t}t|tkr$|Stt|\}}}}|tkr4|S|dks<|dkr@t d||tt d|t }t|t krW|Stt |\ }}} } } } } }}}|t krm|S||t <| |t<| |t<| |t<||t<||t<||t<|S)Nr rrz3zipfiles that span multiple disks are not supported)seeksizeEndCentDir64Locatorr<r@r2structr1structEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64structEndArchive64stringEndArchive64_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 _EndRecData64s>      rZc Csd |dd|}z |t dWn tyYdSw|}t|tkrV|ddtkrV|dddkrVtt |}t |}| d| |tt |t |St |dtd}||d|}|t}|dkr|||t}t|tkrdSt tt |}|t}||t|t|}| || ||t |||||SdS)Nrr r"sr/i)rFtellsizeEndCentDirr<r@r2stringEndArchiverHr1structEndArchivelistr3rZmaxrfind_ECD_COMMENT_SIZE) rUZfilesizerXrWZmaxCommentStartr7ZrecDataZ commentSizecommentrrrr;sD         r;c@sZeZdZ dZdddZddZdd d Zd d Zd dZe dddddZ ddZ dS)r ) orig_filenamerD date_time compress_type_compresslevelrdr5 create_systemrYextract_versionreserved flag_bitsvolume internal_attr external_attr header_offsetCRC compress_size file_size _raw_timeNoNamerrrrrcCs||_|td}|dkr|d|}tjdkr%tj|vr%|tjd}||_||_|ddkr5tdt |_ d|_ d|_ d|_ tjdkrJd|_nd|_t|_t|_d|_d|_d|_d|_d|_d|_d|_dS)Nr/rwz+ZIP does not support timestamps before 1980r/Zwin32r!)refindchrossepreplacerDrf ValueErrorrrgrhrdr5sysplatformriDEFAULT_VERSIONrYrjrkrlrmrnrorrrs)selfrDrfZ null_byterrr__init__Zs4    zZipInfo.__init__cCsd|jj|jfg}|jtkr|dt|j|j|jd?}|jd@}|r2|dt ||r;|d|| }|rD|j rL|d|j |rQ|j rd|jtks\|j |j krd|d|j |d d |S) Nz<%s filename=%r compress_type=%sr+rz filemode=%rz external_attr=%#xz file_size=%rz compress_size=%r>) __class__rrDrgrr3compressor_namesgetrostatfilemodeis_dirrsrrr4)rrEhiloisdirrrr__repr__s,         zZipInfo.__repr__NcCsz |j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd @r4d}}}n |j}|j}|j}|j}d} |durN|tkpM|tk}|rbd } |t| dt | d ||}|tksj|tkrv|spt d d }d }t } |j t krtt| } n |j tkrtt| } t| |j|_t| |j|_|\} } ttt|j|j| |j |||||t| t| } | | |S)Nrrwr&rr#r r!r(r"rzz |jd|jfWSty|jd|jdBfYSw)Nasciiutf-8)rDencoderlUnicodeEncodeErrorrrrrrs  zZipInfo._encodeFilenameFlagscCs6|j}tj}t|dkr|d|dd\}}|dt|kr'td||f|dkr|d|d}zD|jdvrLd}|d|dd\|_|dd}|jd krdd }|d|dd\|_|dd}|jd krvd }|d|dd\|_Wntjytd |d dw||dd}t|dks dSdS)Nr"r.z"Corrupt extra field %04x (size=%d)r)lrz File sizez|}tj tj |d}|dtj tjfvrd|dd}|dtj tjfvsT|rj|d7}|||}|jd @d >|_|rd|_|jd O_|S|j|_|S) Nrr$rwrv;)rr;rrrxrr+) isinstancer{PathLikefspathrS_ISDIRst_modetime localtimest_mtimepathnormpath splitdriver|altseprorsst_size) clsrDarcnamerstrmtimerfzinforrr from_files6        zZipInfo.from_filecCs |jddkS)NrxrDrrrrrszZipInfo.is_dir)rurvN) rrr __slots__rrrrr classmethodrrrrrrr @s + . %r cCs0tdD]}|d@r|d?dA}q|dL}q|S)Nrrl q[)range)crcr9rrr_gen_crcs  rcsldddtdurttttdatfddfdd|D]}|q&fd d }|S) NixV4igE#ixV4cs |d?||Ad@AS)Nrr)Zchr)crctablerrcrc326sz_ZipDecrypter..crc32cs<|d@d@ddd@d?dS)Nrrirr)c)rkey0key1key2rr update_keys:s z"_ZipDecrypter..update_keyscsP t}|j}|D]}dB}|||dAd?d@N}|||q t|S)Nr rrr) bytearrayr3bytes)rXrEr3rk)rrrr decrypterDs z _ZipDecrypter..decrypter) _crctabler`maprr)pwdprr)rrrrrrr _ZipDecrypter,s   rc@s,eZdZddZddZddZddZd S) LZMACompressorcCs d|_dSr)_comprrrrrTs zLZMACompressor.__init__cCsFtdtji}tjtjttj|gd|_tdddt ||S)NidfilterszrVrr>rrrrs z_Tellable.__init__cCs|j|}|j|7_|Sr)r>writerV)rrXrrrrrs z_Tellable.writecCr r)rVrrrrr\r z_Tellable.tellcC|jdSr)r>rrrrrrz_Tellable.flushcCrr)r>rrrrrrrz_Tellable.closeN)rrrrrr\rrrrrrrs  rcseZdZ dZdZdZ  d'ddZdd Zd d Zd(d dZ d)ddZ ddZ d(ddZ ddZ ddZddZddZfddZd d!Zd*d#d$Zd%d&ZZS)+ ZipExtFilei@iiNFcCs&||_||_||_|j|_|j|_|j|_t |j|_ d|_ d|_ d|_ d|_||_|j|_t|dr=|j|_td|_nd|_d|_z|r\||_|j|_|j|_|j|_d|_Wn tyfYnwd|_|r|j d@ry|j!d?d@}n|jd?d@}|"}||krt#d |j$dSdS) NFr/rrqTrrrzBad password for file %r)%_fileobj_pwd_close_fileobjrg_compress_typerr_compress_leftrs_leftr _decompressor_eof _readbuffer_offsetnewlinesmoderDnamerBrq _expected_crcr _running_crc _seekablerr\_orig_compress_start_orig_compress_size_orig_file_size_orig_start_crcAttributeError _decrypterrlrt_init_decrypterrre)rrr%zipinforZ close_fileobjZ check_bytehrrrrsN      zZipExtFile.__init__cCs4t|j|_|jd}|jd8_||dS)Nrr()rrr/rr@r)rrrrrr0Ks  zZipExtFile._init_decryptercCsvd|jj|jjfg}|js,|d|j|jf|jtkr+|dt |j|jn|d|dd |S)N<%s.%sz name=%r mode=%rr [closed]rr) rrrclosedr3r&r%rrrrr4rrErrrrVs    zZipExtFile.__repr__rcCsN |dkr |jd|jd}|dkr |j|j|}||_|Stj||S)Nr r)r"ryr#ioBufferedIOBasereadline)rlimitr8linerrrr:dszZipExtFile.readlinercCst |t|j|jkr/||}t||jkr&||j|jd|_d|_n |jt|8_|j|j|jdS)Nri)r2r"r#r@)rrchunkrrrpeekts zZipExtFile.peekcCs|jrtddS)NI/O operation on closed file.T)r5r~rrrrreadableszZipExtFile.readablecCs$ |jrtd|dus|dkr.|j|jd}d|_d|_|js,|||j7}|jr!|S||j}|t|jkrG|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkr|js||}|t|kr||_||_||d|7} |S||7}|t|8}|dkr|jrc|S)Nzread from closed file.rr/)r5r~r"r#r!_read1MAX_Nr2)rrbufendrXrrrr@s@     zZipExtFile.readcCsD|jdurdSt||j|_|jr|j|jkr td|jdSdS)NzBad CRC-32 for file %r)r'rr(r!rr&)rnewdatarrr _update_crcs zZipExtFile._update_crccCs |dus |dkr.|j|jd}d|_d|_|js,||j}|r)||7} |S|jr|S||j}|t|jkrG|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkr|js||}|t|kr||_||_||d|7} |S|r||7} |S|jrc|SNrr/)r"r#r!rArBr2)rrrCrXrDrrrread1sJ     zZipExtFile.read1cCs |js|dkr dS|jtkr$|jj}|t|kr#|||t|7}n||}|jtkr5|jdk|_n<|jtkrat ||j }|j ||}|jj pT|jdkoT|jj |_|jr`||j 7}n|j |}|jj po|jdk|_|d|j}|jt|8_|jdkrd|_|||S)Nrr/T)r!rrr Zunconsumed_tailr2_read2rrra MIN_READ_SIZErrrrrFrrrrrAs8          zZipExtFile._read1cCsd|jdkrdSt||j}t||j}|j|}|jt|8_|s&t|jdur0||}|SrG) rrarJminrr@r2EOFErrorr/rrrrrIs      zZipExtFile._read2cs>z|jr|jWtdSWtdStwr)rrrsuperrrrrr s  zZipExtFile.closecCs|jrtd|jSNr?)r5r~r)rrrrrszZipExtFile.seekablercCsJ|jrtd|jstd|}|dkr|}n|dkr#||}n|dkr-|j|}ntd||jkr9|j}|dkr?d}||}||j}|dkrY|t|j krY||_d}n1|dkr|j |j |j |_|j|_|j|_d|_ d|_t|j|_d|_|}|jdur||dkrt|j|}||||8}|dks|S) Nzseek on closed file.!underlying stream is not seekablerrr zCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r/F)r5r~r)r8UnsupportedOperationr\r,r#r2r"rrFr*r-r(r+rrrrr r!r/r0rK MAX_SEEK_READr@)rrVr Zcurr_posZnew_posZ read_offsetZ buff_offsetZread_lenrrrrFsN         zZipExtFile.seekcCs>|jrtd|jstd|j|jt|j|j }|S)Nztell on closed file.rP) r5r~r)r8rQr,rr2r"r#)rZfileposrrrr\Js  zZipExtFile.tell)NFrrr)rrrrBrJrRrr0rr:r>r@r@rFrHrArIrrrFr\ __classcell__rrrNrr s, 3   # %$  2rcs@eZdZddZeddZddZddZfd d ZZ S) _ZipWriteFilecCs8||_||_||_t|j|j|_d|_d|_d|_ dSr) _zinfo_zip64_zipfilerrgrh _compressor _file_size_compress_size_crc)rzfrrrrrrTs z_ZipWriteFile.__init__cCs|jjSr)rXr>rrrrr^sz_ZipWriteFile._fileobjcCsdS)NTrrrrrwritablebz_ZipWriteFile.writablecCs|jrtdt|ttfrt|}nt|}|j}|j|7_t ||j |_ |j r:|j |}|j t|7_ |j||SrO)r5r~rrrr2 memoryviewnbytesrZrr\rYrr[rr)rrXrarrrres   z_ZipWriteFile.writec sf|jrdSzt|jr(|j}|jt|7_|j||j|j _ n|j |j _ |j |j _ |j |j _|j jd@r_|jrBdnd}|jt|t|j j |j j |j j|j|j_n7|jst|j tkrktd|jtkrttd|j|j_|j|j j|j|j |j|j|jj|jj|j |j |jj|j j<Wd|j_ dSd|j_ w)Nrzd$d%Zd?d&d'Zd@d(d)Zed*d+Zd,d-Zd.d/Z  d@d0d1Z d?d2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dS)Ar NrTrc CsB |dvr tdt|||_d|_d|_i|_g|_||_||_||_ d|_ d|_ ||_ t |tjr9t|}t |trqd|_||_dddd dd d d }||} z t|||_Wntyn||vrm||}YqRw n d|_||_t|dd|_d|_t|_d |_d|_z|dkr|WdS|dvrd |_z|j |_!Wnt"tfyt#|j|_d|_!d|_YWdSwz |j$|j!WWdSt"tfyd|_YWdSw|dkrz||j$|j!WWdSt%y |j$ddd |_|j |_!YWdSwtd|j} d|_|&| )N)rgwxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'Frr/rAw+bx+br+bwbZxb)rgrhrirjrmrkrlTrr&rg)rhrirjr z"Mode must be 'r', 'w', 'x', or 'a')'r~r _allowZip64 _didModifydebugrerdrrr%r_comment_strict_timestampsrr{rrstr _filePassedrDr8rCr>r<getattr _fileRefCnt threadingRLockrr)r_RealGetContentsr\rcr.rrFr_fpclose) rrr%r allowZip64rrZmodeDictrr>rrrrs         zZipFile.__init__cCs|Srrrrrr __enter__r_zZipFile.__enter__cCs |dSrr)rtypevalue tracebackrrr__exit__ zZipFile.__exit__cCsd|jj|jjfg}|jdur2|jr|d|jn |jdur)|d|j|d|jn|d|dd|S)Nr3z file=%rz filename=%rz mode=%rr4rr) rrrr>rur3rDr%r4r6rrrr"s     zZipFile.__repr__c Cs |j}zt|}Wn tytdw|std|jdkr%t||t}|t}|t|_ |t ||}|t t krF|t t8}|jdkrV||}td||||||_|jdkrdtd||jd||}t|}d}||krb|t} t| tkrtdtt| } | ttkrtd|jdkrt| || t} | d } | d @r| 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 }|jdkr\td|||ks|dSdS)NzFile is not a zip filerr zgiven, inferred, offsetrz Bad offset for central directoryzTruncated central directoryz&Bad magic number for central directoryr#rrcp437rzzip file version %.1fr'r*r-r&rwrr(rtotal)9r>r;r<rrqprintrSrT _ECD_COMMENTrr _ECD_LOCATIONrNrMrKrGrcrFr@r8BytesIOsizeCentralDirr2rHr1structCentralDir _CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHdecoder _CD_EXTRA_FIELD_LENGTHr5_CD_COMMENT_LENGTHrd_CD_LOCAL_HEADER_OFFSETrprYrirjrkrlrgrqrrrsMAX_EXTRACT_VERSIONrrmrnrortrfrrdr3rerD)rr>rWZsize_cdZ offset_cdconcatZinferredrXrcentdirrDflagsritdrrrrz0s                             zZipFile._RealGetContentscCs dd|jDS)NcSsg|]}|jqSrr).0rXrrr sz$ZipFile.namelist..rdrrrrnamelistszZipFile.namelistcC |jSrrrrrrinfolistszZipFile.infolistcCsN tdd|d|jD]}d|jdd}td|j||jf|dq dS)Nz%-46s %19s %12s)z File Namez Modified ZSize)rz%d-%02d-%02d %02d:%02d:%02dr$z %-46s %s %12d)rrdrfrDrs)rrrdaterrrprintdirs zZipFile.printdirc Csz d}|jD]4}z$||jd}||r ||sWdn1s&wYWqty:|jYSwdS)Nirg)rdrCrDr@r)rZ chunk_sizerfrrrtestzips    zZipFile.testzipcCs& |j|}|durtd||S)Nz(There is no item named %r in the archive)rerKeyError)rr&inforrrgetinfos zZipFile.getinfocCs: |rt|tstdt|j|r||_dSd|_dS)Npwd: expected bytes, got %s)rr TypeErrorrrr)rrrrr setpasswords   zZipFile.setpasswordcCrr)rrrrrrrdszZipFile.commentcCs^t|tstdt|jt|tkr'ddl}|jdtdd|dt}||_ d|_ dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr  stacklevelT) rrrrrr2ZIP_MAX_COMMENTwarningswarnrrrp)rrdrrrrrds    cCs< ||d| }|WdS1swYdSNrgrCr@)rr&rr>rrrr@s$z ZipFile.readF force_zip64c s |dvr td|rt|tstdt|j|r#|dkr#tdjs*tdt|tr2|}n|dkrCt|}j|_ j |_ n |}|dkrSj ||dSjrZtdjd 7_tj|jjjfd d }z|t}t|tkrtd tt|}|ttkrtd ||t}|tr||t|jd@rt d|jd@rt d|t!d@r|"d} n|"d} | |j#krtd|j#|f|jd @} | r|sj$}|st%d|nd}t&||||dWS|')N>rhrgzopen() requires mode "r" or "w"rrhz'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedrr rcsjSr)rrrrrszZipFile.open..zTruncated file headerz Bad magic number for file header z$compressed patched data (flag bit 5)@zstrong encryption (flag bit 6)rrrz/File name in directory %r and header %r differ.z6File %r is encrypted, password required for extractionT)(r~rrrrrr>r rrgrrhr_open_to_writerrwrrpr{rr@sizeFileHeaderr2rrHr1r _FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrlr_FH_GENERAL_PURPOSE_FLAG_BITSrrerrrr) rr&r%rrrZzef_fileZfheaderfnameZ fname_strZ is_encryptedrrrrCs~                z ZipFile.opencCs|r |js td|jrtdd|_d|_d|_|jtkr%|jdO_|js/|jdO_|j s5d|_ |jo@|p@|j dt k}|jrK|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.rr rg?T)ror~rrrrqrlrgrr)rorsrr>rFrcr\rp _writecheckrprrrU)rrrrrrrr*s4     zZipFile._open_to_writecCs, |dur t}nt|}||||Sr)r{getcwdr_extract_member)rmemberrrrrrextractSs   zZipFile.extractcCsJ |dur |}|durt}nt|}|D] }||||qdSr)rr{rrr)rrmembersrr1rrr extractall`s  zZipFile.extractallcCs` |j}|sd}t|dt|}||_||}dd||D}|dd|D}|S)Nz:<>|"?*_css|]}|dVqdS).N)rstriprrirrr {z1ZipFile._sanitize_windows_name..css|]}|r|VqdSrrrrrrr}s)!_windows_illegal_name_trans_tablert maketransr2 translatesplitr4)rrpathseptableZillegalrrr_sanitize_windows_nameqs zZipFile._sanitize_windows_namec s t|ts ||}|jdtjj}tjjr"|tjjtjj}tj |d}dtjj tjj ftjj fdd| tjjD}tjjdkrT||tjj}tj ||}tj|}tj|}|rttj|stt||rtj|st||S|j||d,}t|d}t||Wdn1swYWd|SWd|S1swY|S) Nrxrrc3s|] }|vr|VqdSrrrZinvalid_path_partsrrrs z*ZipFile._extract_member..\rrn)rr rrDr}r{rr|rrcurdirpardirr4rrrdirnameexistsmakedirsrrmkdirrCshutil copyfileobj)rrZ targetpathrrZ upperdirssourcetargetrrrrs>  &      ( zZipFile._extract_membercCs |j|jvrddl}|jd|jdd|jdvrtd|js%tdt|j|j sPd}t |j t kr9d}n|j tkrAd }n|jtkrHd }|rRt|d dSdS) NrzDuplicate name: %rr!rrhrirjz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closed Files countZFilesizez Zipfile size would require ZIP64 extensions)rDrerrr%r~r>rrgror2rdZIP_FILECOUNT_LIMITrsrrpr )rrrrequires_zip64rrrrs2     zZipFile._writecheckc Cs |jstd|jrtdtj|||jd}|r#d|_d|_n|dur+||_ n|j |_ |dur7||_ n|j |_ |r|j H|jrM|j|j|j|_|j tkr_|jdO_||d|_|j|||j|j<|j|d|j|_WddS1swYdSt|d.}||d }t||d Wdn1swYWddSWddS1swYdS) N7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsrrr TFrArhi ) r>r~rr rrsrrrrqrgrrhrrr)rFrcr\rprrlrrprdr3rerDrrrCrr)rrDrrgrrsrcdestrrrrsL     "Pz ZipFile.writec Cs4 t|tr |d}t|ts=t|ttddd}|j|_|j|_ |j ddkr9d|_ |j dO_ nd|_ n|}|j sFt d |jrMt d |durT||_|dur[||_ t||_|j-|j|d d  }||Wdn1s{wYWddSWddS1swYdS) Nrr$)rDrfrrxiAr+rrz?Can't write to ZIP archive while an open writing handle exists.rh)r%)rrtrr rrrrgrrhrDror>r~rr2rsrrCr)rZzinfo_or_arcnamerXrgrrrrrrwritestrsD     "zZipFile.writestrcCs |dSrr~rrrr__del__s zZipFile.__del__c Cs |jdurdS|jrtdza|jdvrG|jrU|j|jr&|j|j| Wdn21s4wYW|j}d|_| |dSW|j}d|_| |dSW|j}d|_| |dSW|j}d|_| |dS|j}d|_| |w)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>rr~r%rprr)rFrc_write_end_recordr{rrrrrs<   z ZipFile.closecCs |jD]}|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}g}|jtks8|jtkrI||j||jd }d }n|j}|j}|jtkr]||jd }n|j}|j} d} |rt| d } t j d d t |ddt |g|R| } t } |j tkrtt| } n |j tkrtt| } t| |j} t| |j} |\} }t tt| |j| |j||j |||j||t | t | t |jd|j|j|}|j||j| |j| |j|jq|j }t |j}||j!}|j!}d}|t"krd}n|tkrd}n|tkrd}|rV|j#s#t$|dt t%t&ddddd|||| }|j|t t't(d|d}|j|t)|d}t)|d }t)|d }t t*t+dd||||t |j, }|j||j|j,|j-dkr~|j.|j/dS)Nrrwr&rr#r r!r(r"rrSr.QrrzCentral directory offsetzCentral directory sizer,rrrj)0rdrfrsrrrr3rpr5r:rHrr2rrgrrarrrrjrYrrrrirkrqrdrnror>rr\rcrror rLrMrIrJrKr_r^rrr%truncater)rrrrrr5rsrrrpZ extra_datarrjrYrDrlrZpos2Z centDirCountZ centDirSizeZ centDirOffsetrZ zip64endrecZ zip64locrecrWrrrr5s $$                                    zZipFile._write_end_recordcCs.|jd8_|js|js|dSdSdSNr)rwrurrrrrr{s  zZipFile._fpcloser)rgN)F)NN)NNN)#rrrr>rrrr}rrrzrrrrrrrfrdsetterr@rCrrrrrrrrrrrrr{rrrrr sR ZP        b )  * 2 ) ^r c@s2eZdZ deddfddZd dd Zd d ZdS) r rgTrcCstj|||||d||_dS)N)r%rr|)r r _optimize)rrr%rr|optimizerrrrs  zPyZipFile.__init__rNcCs t|}|r#||s#|jr!tj|rdnd}td||fdStj|\}}tj|r.tj|d}tj|r|rHd||f}n|}|jrTtd|d|| |dd |\}} |jrhtd | | || t t |} | d| D]Y} tj|| } tj| \} }tj| rtjtj| dr|j| ||d q||d kr|r|| s|jrtd | q|| | dd |\}} |jrtd | | || q|dS|jrtd|t t |D]D} tj|| } tj| \} }|d kr+|r|| s|jrtd | q| | dd |\}} |jr%td | | || qdS|d dd kr;td| |dd |\}} |jrPtd| | || dS)Nrrz%s %r skipped by filterfuncz __init__.py%s/%szAdding package inasrZAdding) filterfunc.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding file)r{rrqrrrrr4isfile _get_codenamersortedlistdirremovesplitextwritepyr)rpathnamebasenamerZlabeldirr&ZinitnamerrZdirlistrDrrootZextrrrrs                zPyZipFile.writepyc s dfdd }|d}|d}tjj|dd}tjj|dd}tjj|d d}jdkrtj|rDt|jt|jkrD|} } ntj|r[t|jt|jkr[|} |} ntj|rrt|jt|jkrr|} |} nztj|rt|jt|jkr|} |} nc||rt j j d kr|} n t j j dkr|} n|} |} nH|} } nCjd kr|} |} n|} jdkr|} njd kr|} n d j} t | tj| rt| jt|jks||jd s|} } tj| d} |rd || f} | | fS)Nrc sbddl}jr td|z |j|d|dWdS|jy0}z t|jWYd}~dSd}~ww)NrZ CompilingT)doraiserF) py_compilerqrcompilePyCompileErrormsg)rrrerrrrr_compiles  z)PyZipFile._get_codename.._compilerz.pycr) optimizationrr rz"invalid value for 'optimize': {!r})rrr) importlibutilcache_from_sourcerr{rrrrrrrformatr~r) rrrrZfile_pyZfile_pycZ pycache_opt0Z pycache_opt1Z pycache_opt2rrrZ archivenamerrrrsb                zPyZipFile._get_codename)rN)rrrrrrrrrrrr s  Rr cCs tt|ddSr) itertoolsislice _ancestry)rrrr_parentsHsrccsP |tj}|r"|tjkr&|Vt|\}}|r$|tjksdSdSdSdSr)r posixpathr|r)rtailrrrr[s rcCs tt|j|Sr)r  filterfalseset __contains__)ZminuendZ subtrahendrrr _differenceusrcsReZdZ eddZfddZddZddZfd d Ze d d Z Z S) CompleteDirscCs.tjtt|}dd|D}tt||S)Ncss|]}|tjVqdSr)rr|)rrrrrrrz-CompleteDirs._implied_dirs..)r chain from_iterablerr_deduper)namesparentsZas_dirsrrr _implied_dirsszCompleteDirs._implied_dirscs tt|}|t||Sr)rMrrr`r)rrrNrrrszCompleteDirs.namelistcCs t|Sr)rrrrrr _name_setrzCompleteDirs._name_setcCs. |}|d}||vo||v}|r|S|SNrx)r)rr&rrZ dir_matchrrr resolve_dirs  zCompleteDirs.resolve_dircsF zt|WSty"|dr||vrt|dYSw)Nrxr)rMrrendswithrr )rr&rNrrrs zCompleteDirs.getinfocCs: t|tr|St|ts||Sd|jvrt}||_|Sr)rrr r%r)rrrrrmakes   zCompleteDirs.make) rrr staticmethodrrrrrrr!rTrrrNrr}s    rcs*eZdZ fddZfddZZS) FastLookupcFtt |jWdS1swYtt||_|jSr) contextlibsuppressr.Z_FastLookup__namesrMr#rrrNrrr  zFastLookup.namelistcr$r)r%r&r.Z_FastLookup__lookuprMr#rrrNrrrr'zFastLookup._name_set)rrrrrrTrrrNrr#s r#cOst|d||fS)Nr!)r8 text_encoding)encodingargskwargsrrr_extract_text_encodingsr,c@seZdZ dZd&ddZd'dddd Zed d Zed d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#ZeZed$d%ZdS)(rz>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})rcCs t||_||_dSr)r#r!rat)rrr-rrrr! s z Path.__init__rgNrcOs |r t||d}|s|dkrt||jj|j||d}d|vr1|s+|r/td|St|i|\}}}t j ||g|Ri|S)Nrrgrbz*encoding args invalid for binary operation) rIsADirectoryErrorrFileNotFoundErrorrrCr-r~r,r8 TextIOWrapper)rr%rr*r+Zzip_modestreamr)rrrrC. sz Path.opencCst|jjp |jjSr)pathlibrr-r&rDrrrrr&B z Path.namecCst|jj|jSr)r3rrrDjoinpathr-rrrrrDF r4z Path.filenamecOsZt|i|\}}}|jd|g|Ri| }|WdS1s&wYdSr)r,rCr@)rr*r+r)strmrrr read_textJ s$zPath.read_textcCs6|d }|WdS1swYdS)NrAr)rr6rrr read_bytesO s $zPath.read_bytescCst|jd|jdkSr)rrr-r)rrrrr _is_childS szPath._is_childcCs||j|Sr)rr)rr-rrr_nextV rz Path._nextcCs|j p |jdSr)r-r rrrrrY sz Path.is_dircCs|o| Sr)rrrrrris_file\ z Path.is_filecCs|j|jvSr)r-rrrrrrr_ sz Path.existscCs.|stdt|j|j}t|j|S)NzCan't listdir a file)rr~rr:rrfilterr9)rZsubsrrriterdirb s z Path.iterdircCst|jj|jSr)rr4rrDr-rrrr__str__h r<z Path.__str__cCs|jj|dS)Nr) _Path__reprr rrrrrk rz Path.__repr__cGs&tj|jg|R}||j|Sr)rr4r-r:rr)rothernextrrrr5n sz Path.joinpathcCs6|js|jjSt|jd}|r|d7}||Sr)r-rDparentrrrr:)rZ parent_atrrrrCt s  z Path.parent)r)rg)rrrr@rrCrfr&rDr7r8r9r:rr;rr>r?rr5 __truediv__rCrrrrrs.M    rc s ddl}d}|j|d}|jdd}|jdddd d |jd d d ddd|jdddddd|jddddd ||}|jdurm|j}t|d }|}Wdn1sYwY|rgtd |tddS|j dur|j }t|d }| WddS1swYdS|j dur|j \}}t|d}| |WddS1swYdS|jdur|jd} |j} fddt| d1}| D]%} tj| } | stjtj| } | dtjtjfvrd} || | qWddS1swYdSdS) Nrz3A simple command-line interface for zipfile module.) descriptionT)Zrequiredz-lz--list zShow listing of a zipfile)metavarhelpz-ez --extractr )rFz zExtract zipfile into target dir)nargsrGrHz-cz--create+)zzzCreate zipfile from sourcesz-tz--testzTest if a zipfile is validrgz.The following enclosed file is corrupted: {!r}z Done testingcsvtj|r|||tdStj|r7|r|||tt|D]}|tj||tj||q$dSdSr) r{rrrrrrrr4)r]rzippathZnmaddToZiprrrM s   zmain..addToZiprhr)argparseArgumentParserZadd_mutually_exclusive_group add_argument parse_argstestr rrr r`rrrZcreatepopr{rrrrr) r*rNrEparsergrouprr]ZbadfilerZzip_namefilesrrKrrLrmain~ sh              "    "     $rW__main__r)Zbinasciiimportlib.utilrr8r r{rrrrHrrxrr%r3rr ImportErrorrr__all__ Exceptionrr rrrrrrrrrrrrrrr_r^rr]rNrOrPrQrRrSrTrcrrrrrrZ_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_SIZErrrZ_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESrrrrrZ_FH_EXTRACT_VERSIONZ_FH_EXTRACT_SYSTEMrZ_FH_COMPRESSION_METHODZ_FH_LAST_MOD_TIMEZ_FH_LAST_MOD_DATEZ_FH_CRCZ_FH_COMPRESSED_SIZEZ_FH_UNCOMPRESSED_SIZErrrIrJrGrLrMrKZ_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_CENTDIRrbZStructr0r:r?r rZr;objectr rrrrrrrrrrrr9rrUr r rrdictfromkeysrrrr#r,rrWrrrrrs              +=\&      (KUw/<  . =