QfVdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z e jZ ddlZ ddlZgdZGddeZGddeZexZZdZd Zd ZdZd Zd Zd Zd ZdZdZ dZ!dZ"dZ#dZ$ejJe#Z&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.d Z/dZ0dZ1dZ2ejJe1Z3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;d ZdZ?d Z@dZAd ZBd ZCd!ZDd"ZEd#ZFdZGdZHd ZId$ZJd%ZKd&ZLd'ZMd(ZNejJeMZOdZPdZQdZRdZSdZTdZUdZVdZWd ZXdZYdZZdZ[d)Z\d*Z]ejJe\Z^d+Z_d,Z`ejJe_ZadZbdZcdZddZedZfdZgdZhdZid ZjdZkd-Zlejd.Znd/Zod0Zpd1Zqd2Zrd3Zsd4ZtGd5d6euZvdawd7Zxd8ZyGd9d:ZzGd;d<Z{idd=dd>dd?dd?dd?dd?dd@ddAd dBddCdd@d dDd dEd#dFdGdHdIdJdKdLZ|dMZ}d^dNZ~dOZGdPdQZGdRdSZGdTdUejZGdVdWejZGdXdYZGdZd[eZd^d\Zdd]lmZmZy#e$rdZ ejZ Y$wxYw#e$rdZY-wxYw#e$rdZY6wxYw)_zP Read and write ZIP files. XXX references to utf-8 need further investigation. N) BadZipFile BadZipfileerror ZIP_STORED ZIP_DEFLATED ZIP_BZIP2ZIP_LZMA is_zipfileZipInfoZipFile PyZipFile LargeZipFilePathc eZdZy)rN)__name__ __module__ __qualname__7/opt/alt/python312/lib64/python3.12/zipfile/__init__.pyrr'srrceZdZdZy)rzu Raised when writing a zipfile, the zipfile requires ZIP64 extensions and those extensions are disabled. N)rrr__doc__rrrrr+srri -.?s<4s4H2LHsPK z<4s4B4HL2L5H2LsPK  @iz <4s2B4HL2L2HsPKz<4sLQLsPKz <4sQ2H2L4QsPKiPK t|ry y#t$rYywxYw)NTF) _EndRecDataOSErrorfps r_check_zipfilerHs2 r?      s  cd} t|drt|}|St|d5}t|}ddd|S#1swY|SxYw#t$rY|SwxYw)zQuickly 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. FreadrFrbN)hasattrrHopenrE)filenameresultrGs rr r sr F 8V $#x0F M h%'+& M & M   M s2A A AA A A A AAc  |j|tz d|jt}t |tk7r|St j t|\}}}}|tk7r|S|dk7s|dkDr td|j|tz tz d|jt}t |tk7r|St j t|\ }}} } } } } }}}|tk7r|S||t<| |t<| |t<| |t <||t"<||t$<||t&<|S#t$r|cYSwxYw)zM Read the ZIP64 end-of-archive records and use that to update endrec r"rr!z3zipfiles that span multiple disks are not supported)seeksizeEndCentDir64LocatorrErJr6structr5structEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64structEndArchive64stringEndArchive64_ECD_SIGNATURE_ECD_DISK_NUMBER_ECD_DISK_START_ECD_ENTRIES_THIS_DISK_ECD_ENTRIES_TOTAL _ECD_SIZE _ECD_OFFSET)fpinoffsetendrecdatasigdisknoreloffdisksszcreate_version read_versiondisk_numdisk_dirdircount dircount2dirsize diroffsets r _EndRecData64rqs^ &22A6 99, -D 4y++ !'/H$!OC ''  {eaiNOO IIf..1AA1E 99% &D 4y$$   ($/0C^\8X)Wi    !F>'F &F?%-F !"!*F F9#F; ME  sD== E  E c|jdd|j} |jt d|j }t |tk(rt|ddt k(rh|dddk(r`tjt|}t|}|jd|j|tz t|t |St|dz tz d}|j|d|j }|jt }|dk\r|||tz}t |tk7ryttjt|}|t}||tz|tz|z}|j||j||zt|||z|z |Sy#t$rYywxYw) zReturn 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.rr"Nr$sri)rQtellsizeEndCentDirrErJr6stringEndArchiverSr5structEndArchivelistr7rqmaxrfind_ECD_COMMENT_SIZE) r`filesizercrbmaxCommentStartr=recData commentSizecomments rrDrDs IIaOyy{H  >/1% 99;D D ^# Qq %% RS [ /6F|  c h/0TN?F;;(g.?COIIoq! 99;D JJ' (E zuU>12 w<> )fmm$4g>?./ u^+E.,@,LM g o-.T?U#:X#E#% % W sF== G G c|jtd}|dk\r|d|}tjdk7r2tj|vr |j tjd}tj rEtj dk7r2tj |vr |j tj d}|S)zzTerminate the file name at the first null byte and ensure paths always use forward slashes as the directory separator.r/)findchrossepreplacealtsep)rN null_bytes r_sanitize_filenamerUs  c!f%IA~Ai( vv}8+##BFFC0 yyRYY#%"))x*?##BIIs3 OrcTeZdZdZdZd dZdZddZdZdZ e dd d d Z d Z y)r z>Class with attributes describing each file in the ZIP archive.) orig_filenamerN date_time compress_type_compresslevelrr9 create_systemriextract_versionreserved flag_bitsvolume internal_attr external_attr header_offsetCRC compress_size file_size _raw_time _end_offsetc||_t|}||_||_|ddkr t dt |_d|_d|_d|_ tjdk(rd|_ nd|_ t|_t|_d|_d|_d|_d|_d|_d|_d|_d|_y)Nrz+ZIP does not support timestamps before 1980rwin32r#)rrrNr ValueErrorrrrrr9sysplatformrDEFAULT_VERSIONrirrrrrrrrr)selfrNrs r__init__zZipInfo.__init__s%&h/  " Q<$ JK K("  <<7 "!"D "#D -.  rcd|jjd|jg}|jtk7r<|j dt j|j|jz|jdz }|jdz}|r'|j dtj|z|r|j d|z|j}|r |jr|j d|jz|r |jrJ|jtk7s|j|jk7r|j d |jz|j d d j|S) N) __class__rrNrrr7compressor_namesgetrstatfilemodeis_dirrrr8)rrOhiloisdirs r__repr__zZipInfo.__repr__s;'+~~'>'> NO    + MM-*..t/A/A/3/A/ACC D  2 %   & ( MM.4==+<< = MM.3 4  MM/DNN: ;$,,   : - ^^t11 1 MM-0B0BB C cwwvrNc|j}|ddz dz|ddzz|dz}|ddz|d dzz|ddzz}|jtzrdx}x}}n$|j}|j}|j }|j }d} ||tkDxs |tkD}|r>d } |tj| dtj| d z ||z}d }d }t} |jtk(rtt| } n#|jt k(rtt"| } t| |j$|_t| |j&|_|j)\} } tjt*t,|j$|j.| |j|||||t1| t1| } | | z|zS) zReturn the per-file header as a bytes object. When the optional zip64 arg is None rather than a bool, we will decide based upon the file_size and compress_size, if known, False otherwise. rrr(r!r%r"r#r*r$z>5 5./ /C /-)((C ..MI  = +J}{/JE CFKK()6??3+?+A9m]]E"I&M'K    *m[9K   8 +lK8K";0D0DE!+t/B/BC"779)-/?!114==)!//'3*I ]CJ 8  5((rc |jjd|jfS#t$r1|jjd|jtzfcYSwxYw)Nasciiutf-8)rNencoderUnicodeEncodeError_MASK_UTF_FILENAMErs rrzZipInfo._encodeFilenameFlagss[ V==''0$..@ @! V==''0$..CU2UU U Vs&)7A#"A#c|j}tj}t|dk\r2|d|dd\}}|dzt|kDrt d||fz|dk(r|d|dz} |j dvrd}|d|dd\|_|dd}|j d k(rd }|d|dd\|_|dd}|jd k(rd }|d|dd\|_ne|dk(r`|d|dz} |d|dd\}} |dk(rC| |k(r>|ddjd} | rt| |_ nddl } | jdd||dzd}t|dk\r1yy#tj$rt d d dwxYw#tj$r} t d| d} ~ wt$r} t d| d} ~ wwxYw)Nr$r2z"Corrupt extra field %04x (size=%d)r!)lrz File sizezCorrupt unicode path extra field (0x7075): invalid utf-8 bytes)r9rSr5r6rrrrrdecoderrNwarningswarnUnicodeDecodeError) r filename_crcr9r5tplnrcfield up_version up_name_crcup_unicode_nameres r _decodeExtrazZipInfo._decodeExtras %jAoE5!9-FB!tc%j  !ER!PQQV|Qr!t}F~~)MM +*0tBQx*@#ABx))[8 /.4T48.D+*#ABx))[8 /.4T48.D+*vQr!t} n.4UD!H.E+J !Q;,+F*.qr(//'*B*,>,ODM+$MM*S`aMb "Q$%LEO%jAo&||F$'B(-wk&;q#ABajRVVRYY//abkGajRVVRYY//  sNGGY'!zzF2r9 EO   4 '  !jjEO rc |jjdrytjjrM|jjtjj tjjfSy)z2Return True if this archive member is a directory.rTF)rNendswithrrrrrs rrzZipInfo.is_dirGsQ == ! !# & 77>>==))277;;*GH Hr)NoNamerN) rrrr __slots__rrrrr classmethodrrrrrr r hsJHI0  J,.)`V +!Z#D##J rr cLtdD]}|dzr |dz dz }|dz}|S)Nrr!l q[)range)crcrAs r_gen_crcrYs5 1X 7!8z)C AIC  Jrcdddt"tttt datfdfd|D] }| fd}|S)NixV4igE#ixV4c&|dz ||z dzz S)z(Compute the CRC32 primitive on one byte.rr)chrcrctables rcrc32z_ZipDecrypter..crc32ss qHcBh$%6777rc\|dzzdzdzdzdzdz y)Nrrir!r)cr key0key1key2s r update_keysz"_ZipDecrypter..update_keyswsEQ~t $ 2y 1$ 2TRZ&rct}|j}|D](}dz}|||dz zdz dzz}|||*t|S)zDecrypt a bytes object.r"r!rr) bytearrayr7bytes)rcrOr7r krrs r decrypterz _ZipDecrypter..decrypters\AqA 1!9"d* *A N 1I  V}r) _crctablerxmaprr) pwdprr r rrrrs @@@@@@r _ZipDecrypterris^ D D DXuSz23 H8'A  rc$eZdZdZdZdZdZy)LZMACompressorcd|_yr)_comprs rrzLZMACompressor.__init__s  rc.tjdtji}tjtjtj tj|g|_tjdddt||zS)Nidfiltersz?FE4##$E 100..t/@/@/3/?/?!e)/LNKDL##AIJ/D ((.<<## rN)rrrrr7rrrr1r1s  rr1storeshrinkreduceimplodetokenizedeflate deflate64bzip2r$terselz77awavpackbppmdc|tk(ry|tk(rts tdy|tk(rt s tdy|t k(rts tdytd)Nz.Compression requires the (missing) zlib modulez-Compression requires the (missing) bz2 modulez.Compression requires the (missing) lzma modulez(That compression method is not supported) rrzlib RuntimeErrorrbz2r r$NotImplementedError) compressions r_check_compressionrNsj   $@B B  !?A A  @B B""LMMrcX|tk(rZ|%tj|tjdStjtjtjdS|t k(r+|t j|St jS|tk(r tSy)N) rrI compressobjDEFLATEDZ_DEFAULT_COMPRESSIONrrK BZ2Compressorr r)r compresslevels r_get_compressorrVs $  $##M4==#F F : :DMM3OO ) #  $$$]3 3  "" ( "rc4t||tk(ry|tk(rtjdS|t k(rt jS|tk(r tStj|}|rtd||fztd|fz)NrPzcompression type %d (%s)zcompression type %d) rNrrrI decompressobjrrKBZ2Decompressorr r1rrrL)rdescrs r_get_decompressorr[s}% " , &!!#&& ) #""$$ ( "!! $$]3 %&@MSXCY&YZ Z%&;}>N&NO Orc.eZdZdZdZddZddZdZy) _SharedFilecl||_||_||_||_||_|j |_yr)_file_pos_close_lock_writingseekable)rfileposcloselockwritings rrz_SharedFile.__init__ s0       rc|jSr)r`rs rrtz_SharedFile.tells yyrc |j5|jr td|jj |||jj |_|j cdddS#1swYyxYw)Nz}Can't reposition in the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rbrcrr_rQrtr`)rrawhences rrQz_SharedFile.seeksc ZZ}} "JKK JJOOFF + )DI99  ZZs A"A99Bc>|j5|jr td|jj |j |jj |}|jj|_|cdddS#1swYyxYw)NyCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)rbrcrr_rQr`rJrtrnrcs rrJz_SharedFile.read!ss ZZ}} "JKK JJOODII &::??1%D )DI  ZZs A$rY{wxYw) NFrrrTrrr zBad password for file %r)'_fileobj_pwd_close_fileobjr_compress_typer_compress_leftr_leftr[ _decompressor_eof _readbuffer_offsetnewlinesmoderNnamerLr _expected_crcr  _running_crc _seekablerdrt_orig_compress_start_orig_compress_size_orig_file_size_orig_start_crc _orig_crcAttributeError _decrypterrrr_init_decrypterrJr)rrrrzipinfor close_fileobj check_bytehs rrzZipExtFile.__init__Us  +%33%33&& .t/B/BC    $$ 7E "!(D  %c D !%D  !,3LLN)+2+@+@('.'8'8$'+'8'8$!%!3!3!%   #<<%//14< &kkR/47 $$&AJ"#=@U@U#UVV     sA0F44 G?Gct|j|_|jj d}|xj dzc_|j|dS)Nrr*)rrrrrJr)rrs rrzZipExtFile._init_decryptersM' 2 ##B' r!v&r**rcd|jjd|jjg}|js{|j d|j d|j |jtk7rN|j dtj|j|jzn|j d|j ddj|S) Nr.z name=z mode=r [closed]rr) rrrclosedr7rrrrrrr8rrOs rrzZipExtFile.__repr__s"nn77"nn99;<{{ MM 499E F""j0 1.2243F3F373F3FHHI MM+ & cwwvrc|dkrP|jjd|jdz}|dkDr"|j|j|}||_|Stjj ||S)zrRead and return a line from the stream. If limit is specified, at most limit bytes will be read. r r!)rrrioBufferedIOBasereadline)rlimitr>lines rrzZipExtFile.readlinesn 19  %%eT\\:Q>A1u'' a8     ))$66rcx|t|j|jz kDrp|j|}t||jkDr)||j|jdz|_d|_n|xjt|zc_|j|j|jdzS)z6Returns buffered bytes without advancing the position.Nri)r6rrrJ)rrpchunks rpeekzZipExtFile.peeks s4##$t||3 3IIaLE5zDLL(#(4+;+;DLLM+J#J    E *  dllS.@AArc2|jr tdy)NI/O operation on closed file.T)rrrs rreadablezZipExtFile.readables ;;<= =rc|jr td||dkr`|j|jd}d|_d|_|js+||j |j z }|js+|S||jz}|t|jkr"|j|j|}||_|S|t|jz }|j|jd}d|_d|_|dkDri|js]|j |}|t|kr||_||_||d|z } |S||z }|t|z}|dkDr |js]|S)zRead and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached. zread from closed file.Nrr)rrrrr_read1MAX_Nr6)rrpbufendrcs rrJzZipExtFile.readsk ;;56 6 9A""4<<=1C"D DLiit{{4::..iiJ$,, T%%& &""4<<4CDLJ #d&&' 't||}- !eDII;;q>D3t9}#'   tBQx  4KC TNA!eDII rc|jyt||j|_|jr2|j|jk7rt d|j zyy)NzBad CRC-32 for file %r)rr rrrr)rnewdatas r _update_crczZipExtFile._update_crcs]    % !'4+<+<= 99**d.@.@@5 AB BA9rc||dkrg|j|jd}d|_d|_|js2|j|j}|r||z } |S|js2|S||jz}|t |jkr"|j|j|}||_|S|t |jz }|j|jd}d|_d|_|dkDr[|jsO|j|}|t |kr||_||_||d|z } |S|r||z } |S|jsO|S)z7Read up to n bytes with at most one read() system call.Nrr)rrrrrr6)rrprrcrs rread1zZipExtFile.read1sb 9A""4<<=1C"D DLii{{4::.4KCJ ii J$,, T%%& &""4<<4CDLJ #d&&' 't||}- q5ii{{1~s4y='+D$#$DL48OC 4KC ii rc|js|dkry|jtk(rE|jj}|t |kDr2||j |t |z z }n|j |}|jtk(r|jdk|_n|jtk(rt||j}|jj||}|jjxs(|jdkxr|jj |_|jre||jjz }nG|jj|}|jjxs|jdk|_|d|j}|xjt |zc_|jdkrd|_|j||S)NrrT)rrrrunconsumed_tailr6_read2rrry MIN_READ_SIZEr7r5r/rrros rrzZipExtFile._read1s 99Q   , .%%55D3t9} AD M22;;q>D   * ,++q0DI  L 0At))*A%%00q9D++//@,,1@!//??? Iyy**0022%%006D**..J$2E2E2JDIKTZZ  c$i ::?DI  rc:|jdkryt||j}t||j}|jj |}|xjt |zc_|st|j|j|}|S)Nrr) rryrminrrJr6EOFErrorrros rrzZipExtFile._read2:s   ! # 4%% & 4&& '}}!!!$ s4y(N ?? &??4(D rc |jr|jjt| y#t| wxYwr)rrrgsuper)rrs rrgzZipExtFile.closeJs4 "" ##% GMOEGMOs &8AcH|jr td|jSNr)rrrrs rrdzZipExtFile.seekableQs ;;<= =~~rcL|jr td|jstjd|j }|t jk(r|}nG|t jk(r||z}n.|t jk(r|j|z}n td||jkDr |j}|dkrd}||z }||jz}|dk\r#|t|jkr ||_ d}n[|jtk(r|j |dkDr|d|_|t|j|jz z}|j$j'|t j|xj(|zc_d}d|_ d|_ n|dkr|j$j'|j*|j,|_|j0|_|j2|_|j|_d|_ d|_ t7|j|_d|_|}|j |j=|dkDr2t?|j@|}|jC|||z}|dkDr2|j S)Nzseek on closed file.!underlying stream is not seekablezCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)rrF)"rrrrUnsupportedOperationrtrSEEK_SETSEEK_CURSEEK_ENDrrr6rrrrrrrQrrrrrrrr[rrrr MAX_SEEK_READrJ)rrarlcurr_posnew_pos read_offset buff_offsetread_lens rrQzZipExtFile.seekVsR ;;34 4~~))*MN N99; R[[ G r{{ "'G r{{ "**V3GCD D T)) )**G Q;G( !DLL0 !  c$2B2B.C C&DLK  J .4??3J{]^!%D  3t//04<<? ?K MM  {BKK 8 JJ+ %JK"D DL 1_ MM  t88 9 $ 4 4D !%D "&":":D --DJ"D DL!243F3F!GD DI!K*$$&Ao4--{;H IIh  8 #KAo yy{rc|jr td|jstjd|j |j z t|jz |jz}|S)Nztell on closed file.r) rrrrrrrr6rr)rfileposs rrtzZipExtFile.tells` ;;34 4~~))*MN N&&3c$:J:J6KKdllZr)NFrsr!)rrrrrrrrrrrrrrJrrrrrgrdrrrQrt __classcell__rs@rrrGs EMM37$1Wh + 7 B !FC#J"H  #%++=~rrc@eZdZdZedZdZdZfdZxZ S) _ZipWriteFilec||_||_||_t|j|j |_d|_d|_d|_ yrx) _zinfo_zip64_zipfilerVrr _compressor _file_size_compress_size_crc)rzfrrs rrz_ZipWriteFile.__init__sL   *5+>+>+0+?+?A rc.|jjSr)rrGrs rrz_ZipWriteFile._fileobjs}}rcy)NTrrs rwritablez_ZipWriteFile.writablesrc|jr tdt|ttfr t |}nt |}|j}|xj|z c_t||j|_ |jr9|jj|}|xjt |z c_ |jj||Sr)rrrrrr6 memoryviewnbytesrr rrr,rrr{)rrcrs rr{z_ZipWriteFile.writes ;;<= = dUI. /YFd#D[[F 6!$ *   ##,,T2D   3t9 ,  D! rc |jry t| |jro|jj }|xj t |z c_|jj||j |j_ n|j|j_ |j|j_ |j|j_|js<|jt kDr t#d|j t kDr t#d|jj$t&zr|jrdnd}|jjt)j*|t,|jj|jj|jj|jj/|j0_n|jj/|j0_|jj5|jj6|jj|jj9|j|jj5|j0j2|j0j:j=|j|j|j0j>|jj@<d|j0_!y#d|j0_!wxYw)Nz*File size too large, try using force_zip64z0Compressed size too large, try using force_zip64z ' +/--*<*<*> ' ""4;;#<#<= ##DKK$:$:4;;$GH ""4==#:#:; MM " " ) )$++ 6=A[[DMM $ $T[[%9%9 :%*DMM "UDMM "s LL88M ) rrrrpropertyrrr{rgrrs@rrrs0  &++++rrc"eZdZdZdZdZdeddfddddZdZdZ d Z d Z d Z d Z d$d ZdZdZdZedZej(dZd$dZd%dddZd&dZd'dZd(dZedZdZdZ d(dZ d'dZd)dZ d Z!d!Z"d"Z#d#Z$y)*r 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. NrT)rmetadata_encodingc|dvr tdt|||_d|_d|_i|_g|_||_||_||_ d|_ d|_ ||_ ||_ |jr|dk7r tdt|tj rtj"|}t|t$r;d|_||_d d d d d d dd}||} t+j,|| |_n d|_||_t3|dd|_d|_t7j8|_d|_d|_ |dk(r|jAy|dvrNd|_ |j.jC|_" |j.jG|jDy|dk(r7 |jA|j.jG|jDytd#t0$r| |vr|| } Y1wxYw#tHt0f$r d|_YywxYw#tHt0f$r+tK|j.|_d|_"d|_YywxYw#tL$rE|j.jGddd|_|j.jC|_"YywxYw#|j.} d|_|jO| xYw)z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.)rwxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNrrz5metadata_encoding is only supported for reading filesrKw+bx+br+bwbxb)rrrrrrrTr!r)rrrr"z"Mode must be 'r', 'w', 'x', or 'a')(rrN _allowZip64 _didModifydebugrrrMrUrr_comment_strict_timestampsrrrrrstr _filePassedrNrrMrGrEgetattr _fileRefCnt threadingRLockrbrrc_RealGetContentsrtrrQrrvr_fpclose) rrerrM allowZip64rUrrmodeDictrrGs rrzZipFile.__init__ s + +JK K;'%  &*  "3!2  ! !dckGI I dBKK (99T?D dC  D  DM"U%$T$@H~H ggdH5DG  D DG#D&$7DM__&  ' s{%%'##' /%)WW\\^DN/ T^^4 4))+GGLL0!!EFFc8+#+H#5  @+G4/)./'0+'0DG%&DN%*DN+ "4GGLLA&'+DO%)WW\\^DN4 BDG MM"  s)HK* K6H9%H<K5I68 KHHH63K5H66K97I30K2I33K6A KKKK'K.c|Srrrs r __enter__zZipFile.__enter__ls rc$|jyrrg)rtypevalue tracebacks r__exit__zZipFile.__exit__os  rcd|jjd|jjg}|jt|jr|j d|jzn*|j |j d|j z|j d|jzn|j d|j ddj|S) Nrrz file=%rz filename=%rz mode=%rrrr) rrrrGrr7rNrr8rs rrzZipFile.__repr__rs"nn77"nn99;< 77  j47723* nt}}<= MM*tyy0 1 MM+ & cwwvrc |j} t|}|s td|jdkDr t ||t }|t}|t|_ |t|z |z }|ttk(r|ttzz}|jdkDr||z}t d|||||z|_|jdkr td|j!|jd|j#|}t%j&|}d}||kr|j#t(} t+| t(k7r tdt-j.t0| } | t2t4k7r td|jdkDr t | |j#| t6} t9| } | t:} | t<zr| j?d } n| j?|j@xsd } tC| } |j#| tD| _#|j#| tH| _%| tL| _'| dd \ | _(| _)| _*| _+| _,| _-}}| _.| _/| _0| jTtbkDrted | jTd z z| dd\| _3| _4| _5|| _6|dz dz|dz dz|dz|dz |dz dz|dzdzf| _7| jq| | jN|z| _'|jrju| | |jv| jx<|t(z| t6z| tDz| tHz}|jdkDr t d|||kr|j}t{|jrddD]}||_>|jN}y#t$r tdwxYw)z/Read in the table of contents for the ZIP file.zFile is not a zip filer!r"zgiven, inferred, offsetrz Bad offset for central directoryzTruncated central directoryz&Bad magic number for central directoryrcp437rzzip file version %.1fr)r,r/r(rr%rr*r totalc|jSr)r)rs rz*ZipFile._RealGetContents..s e.A.ArT)keyreverseN)?rGrDrErrprintr^r_ _ECD_COMMENTr _ECD_LOCATIONrYrXrVrRrrQrJrBytesIOsizeCentralDirr6rSr5structCentralDir _CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHr  _CD_FLAG_BITSrrrr _CD_EXTRA_FIELD_LENGTHr9_CD_COMMENT_LENGTHr_CD_LOCAL_HEADER_OFFSETrrirrrrrrrrMAX_EXTRACT_VERSIONrLrrrrrrrr7rrNsortedr)rrGrbsize_cd offset_cdconcatinferredrcrcentdirrNorig_filename_crcflagsrtd end_offsetrs rrzZipFile._RealGetContentss WW 7 _F56 6 ::> &M#;' |,  &09< . !%7 7 '*AA BF ::> )H +Y& I"V+ >>A ?@ @ "www ZZ goggn-G7|~- !>??mm$4g>G}%)99 !IJJzzA~gwww':;AG(: ;AO5zr t=d|t@tBzr|jEd} n|jEjFxsd} | |jHk7rt'd|jHd|d|jJC|jM|jNz|jJkDrt'd|jHd|j8tPz} | rQ|s jR}|r1t|tTs!tWdtY|jZz|st]d|zd}t_||||dS#|jaxYw)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. >rrzopen() requires mode "r" or "w"rz'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedrMrnr!cjSr)rcrsrrzZipFile.open..Qs $--rzTruncated file headerz Bad magic number for file header)rlz$compressed patched data (flag bit 5)zstrong encryption (flag bit 6)rrzFile name in directory z and header z differ.NzOverlapped entries: z (possible zip bomb)rFz6File %r is encrypted, password required for extractionT)1rrGrr rMrrUrrD_open_to_writercrr]rrrbrJsizeFileHeaderr6rrSr5r _FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrQr_MASK_COMPRESSED_PATCHrL_MASK_STRONG_ENCRYPTION_FH_GENERAL_PURPOSE_FLAG_BITSrrrrrrtr_MASK_ENCRYPTEDrrrGrrrJrrg) rrrrrNrzef_filefheaderfname fname_str is_encrypteds ` rrMz ZipFile.open"s z !>? ? DCKFG GwwDF F dG $E S[DME"&"2"2E #'#5#5E LL&E 3;&&u+&F F ==FG G Atww(;(;#}}djj:OQ4 mmN3G7|~- !899mm$4g>G}%)99 !CDDMM'*=">?E-. g&<=a H!77)*PQQ!88)*JKK458JJ!LL1 !LL)?)?)J7K E/// **E344!!- %"5"558I8II #78K8K7NNb!cdd!??_> GGLL ("gglln   e&&u-. T5%00rc|tj}ntj|}|j|||S)alExtract 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'. You can specify the password to decrypt the file using 'pwd'. )rgetcwdr_extract_member)rmemberrrs rextractzZipFile.extracts6 <99;D99T?D##FD#66rc||j}|tj}ntj|}|D]}|j |||y)a?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(). You can specify the password to decrypt all files using 'pwd'. N)r4rrdrre)rrmembersrrs r extractallzZipFile.extractallsM ?mmoG <99;D99T?DG  $ 4rc|j}|s+d}tj|dt|z}||_|j |}d|j |D}|j d|D}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*_c3>K|]}|jdyw)z .N)rstrip.0rs r z1ZipFile._sanitize_windows_name..sB+Aa188D>+Asc3&K|] }|s| ywrrros rrqz1ZipFile._sanitize_windows_name..s7'QQq's)!_windows_illegal_name_trans_tabler maketransr6 translatesplitr8)rrpathseptableillegals r_sanitize_windows_namezZipFile._sanitize_windows_namest55GMM'3W+=>E49C 1##E*B7==+AB,,7'77rct|ts|j|}|jj dt j j}t j jrB|j t j jt j j}t j j|d}dt j jt j jft j jjfd|jt j jD}t j jdk(r*|j|t j j}|s|js t!dt j j||}t j j#|}t j j%|}|r4t j j'|st j(||jr6t j j+|st j,||S|j/||5}t/|d5}t1j2||d d d d d d |S#1swYxYw#1swY|SxYw) zbExtract the ZipInfo object 'member' to a physical file on the path targetpath. rr!rc3*K|] }|vr| ywrr)rprinvalid_path_partss rrqz*ZipFile._extract_member..s##C.H&'/A&A$%.Hs\zEmpty filename.)rrN)rr rDrNrrrrrrcurdirpardirr8rvrzrrrdirnameexistsmakedirsrmkdirrMshutil copyfileobj) rrf targetpathrr upperdirssourcetargetr}s @rrezZipFile._extract_members&'*\\&)F//))#rww{{; 77>>oobggnnbggkkBG''$$W-a0 "''.."''..A''++""#CgmmBGGKK.H#CC 77;;$ 11'277;;GGv}}./ /WW\\*g6 WW%%j1 GGOOJ/ RWW^^I6 KK " ==?77==,$  YYv3Y '6 *d #v   vv .$($ #(s$4 K6K*K6*K3 /K66Lc|j|jvr$ddl}|jd|jzd|jdvr t d|j s t dt|j|js]d}t|jtk\rd }n+|jtkDrd }n|jtkDrd }|rt!|d zyy) z6Check for errors before writing a file to the archive.rNzDuplicate name: %rr#rrrrz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closed Files countFilesizez Zipfile size would require ZIP64 extensions)rNrrrrrrGrNrrr6rZIP_FILECOUNT_LIMITrrrr)rrrrequires_zip64s rrbzZipFile._writechecks >>T__ ,  MM.?AM N 99O +EF FwwFH H5../!N4==!%88!.;.!+$${2!/">#D$EFF rc.|js td|jr tdtj |||j }|j r d|_d|_|j|y|||_ n|j|_ |||_ n|j|_ t|d5}|j|d5}tj ||dddddddy#1swYxYw#1swYyxYw) zLPut the bytes from filename into the archive under the name arcname.7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsrrNrKri )rGrrcr rrrrrrrrMrrUrMrr)rrNrrrUrsrcdests rr{z ZipFile.write%swwIK K ==P !!(G484K4K"M <<>"#E EI JJu (&3#&*&6&6#('4$'+'9'9$h%diis.Ct""3f5/D%%.C.C%%s$D C?.D ?D D  Dct|tr|jd}t|tst|t j t jdd}|j |_|j|_ |jjdrd|_ |xjdzc_ n d|_ n|}|js td |jr td |||_|||_ t!||_|j$5|j'|d 5}|j)|ddddddy#1swYxYw#1swYyxYw) 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.rNr&)rNrriAr-r`rz?Can't write to ZIP archive while an open writing handle exists.r)r)rrrr rrrMrrUrrNrrrGrrcr6rrbrMr{)rzinfo_or_arcnamercrrUrrs rwritestrzZipFile.writestrFs; dC ;;w'D*G4%5&*nnTYY[&A"1&EGE"&"2"2E #'#5#5E ~~&&s+&3###t+#&1#$EwwIK K ==Q   $"/E   $#0E d) ZZ5s+t 4 ,Z++Zs$'E*;E E*E' #E**E3ct|tr|}|jstdt|tr^|}|j ds|dz }t|}d|_d|_d|zdzdz|_d|_ |xjdzc_n td|j5|jr%|jj|j|jj!|_|j$t&k(r|xj(t*zc_|j-|d|_|j0j3|||j4|j6<|jj9|j;d |jj!|_d d d y #1swYy xYw) z+Creates a directory inside the zip archive.z/The given ZipInfo does not describe a directoryrri@rr-zExpected type str or ZipInfoTFN)rr rrrrrrrrrGrbrrGrQrrtrrr rrarbrrr7rrNr{r)rzinfo_or_directory_namerrdirectory_names rrz ZipFile.mkdirosb -w 7+E<<> !RSS / 54N!**3/#%N+E"#E EI$+dNf#<"CE EO   4 ' :; ; ZZ~~ T^^,"&'',,.E ""h.#::   U #"DO MM  '.3DOOENN + GGMM%**51 2!WW\\^DNZZs 3DGGc$|jy)z2Call the "close()" method in case the user forgot.Nr rs r__del__zZipFile.__del__s  rc|jy|jr td |jdvrb|jrV|j 5|j r%|jj|j|jddd|j}d|_|j|y#1swY.xYw#|j}d|_|j|wxYw)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) rGrcrrrrbrrQr_write_end_recordrrys rrgz ZipFile.closes 77?  ==PQ Q yyO+ZZ~~ T^^4**, BDG MM"  Z BDG MM" s$&C AB;C;CC&C-c |jD]}|j}|ddz dz|ddzz|dz}|ddz|d dzz|ddzz}g}|jtkDs|jtkDr;|j |j|j |jd }d }n|j}|j}|j tkDr|j |j d }n |j }|j} d} |rHt| d } tjd d t|zzddt|zg|| z} t} |jtk(rtt | } n#|jt"k(rtt$| } t| |j&} t| |j(} |j+\} }tjt,t.| |j0| |j2||j|||j4||t| t| t|j6d|j8|j:|}|j<j?||j<j?| |j<j?| |j<j?|j6|j<jA}t|j}||jBz }|jB}d}|tDkDrd}n|tkDrd}n |tkDrd}|r|jFstI|dztjtJtLddddd|||| }|j<j?|tjtNtPd|d}|j<j?|tS|d}tS|d }tS|d }tjtTtVdd||||t|jX }|j<j?||j<j?|jX|jZdk(r|j<j]|j<j_y)Nrrr(r!r%r"r#r*r$rrr2QrrzCentral directory offsetzCentral directory sizer,rrr)0rrrrrr7rr9rBrSrr6rrrryrr rrrirrr!rrrrrrrGr{rtrrrrrWrXrTrUrrwrvrrtruncater/)rrrrrr9rrr extra_datarrrirNrr-pos2 centDirCount centDirSize centDirOffsetr zip64endrec zip64locrecrbs rrzZipFile._write_end_records]]EB!ut|)BqEQJ6A>GerkBqEQJ."Q%1*=GE,%% 3 U__- U001& * !OO % 3 3 ""[0 U001 * % 3 3 JK)*d; #[[CE N*qU|-&+-/9: , ""i/!-= $$0!, < !+u/D/DEO e.B.BCN"'"<"<"> Hikk"2"2N"'"5"5"+U-@-@'7"'))]I"%h-Z#emmBT"#U%8%8%:M:M"/1G GGMM' " GGMM( # GGMM* % GGMM%-- (g#jww||~4==) T^^+   - -*N [ (7N ; &5N ##">#D$EFF ++"$6BAq, ],K GGMM+ & ++))1dA7K GGMM+ &|V4Lk:6K z:M-/?<(-T]]9KM  f  dmm$ 99  GG     rc|jdkDsJ|xjdzc_|js|js|jyyy)Nrr!)rrrgrys rrzZipFile._fpclose sI!### A(8(8 HHJ)9rr)rN)F)NN)NNN)i)%rrrrrGrsrrr rrrr4r6r<r@rDrHrrsetterrJrMrQrgrjrrzrerbr{rrrrgrrrrrr r s , B(,%"%:$#^:>RV^@ T-l9 &  ^^   dEdL(1T 75$  +ZF.'+046D48'!R!,F,\|rr c.eZdZdZdeddfdZd dZdZy) r zDClass to create ZIP archives with Python library files and packages.rTrtcFtj|||||||_y)N)rrMr)r r _optimize)rrerrMroptimizes rrzPyZipFile.__init__s't$K$.  0!rNctj|}|rI||sA|jr4tjj |rdnd}t |d|dytjj |\}}tjj |rtjj|d}tjj|r|r|d|}n|}|jrt d|d ||j|d d |\}} |jr t d | |j|| ttj|} | jd| D]$} tjj|| } tjj| \} }tjj | rStjjtjj| ds|j| || |dk(s|r#|| s|jrt d| z|j| d d |\}} |jr t d | |j|| 'y|jr t d|ttj|D]} tjj|| } tjj| \} }|dk(sK|r#|| s|jrt d| zp|j| d d |\}} |jr t d | |j|| y|d ddk7r t!d|j|d d |\}} |jr t d| |j|| y)aAdd 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. rre z skipped by filterfuncNz __init__.pyrzAdding package inasrAdding) filterfunc.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding file)rrrrrrrvr8isfile _get_codenamer{r(listdirremovesplitextwritepyrJ)rpathnamebasenamerlabeldirrinitnamer\rdirlistrNrrootexts rrzPyZipFile.writepys99X& j2zz"$''--"9vuhGH GGMM(+ T 77== "ww||Hm>"'',,t]*KL LLx4>)@%j.>#zz %&E&L M$)-););D2J#zz %&E&L M$)-););D2J._compiless\ zzk4( ""4"I,, cgg s4A"AA"rz.pycr) optimizationr!r"rz"invalid value for 'optimize': {!r})rrrs) importlibutilcache_from_sourcerrrrrrrr/rformatrrv) rrrrfile_pyfile_pyc pycache_opt0 pycache_opt1 pycache_opt2rr\r archivenames ` rrzPyZipFile._get_codenamels e#f$ ~~77b7Q  ~~77a7P  ~~77a7P >>R x(''(#,,0@0I0II"**%''...'','00BGGG4D4M4MM%"''...'','00BGGG4D4M4MM%"''...'','00BGGG4D4M4MM%"G$yy))Q. ,++q0 , ,&G&--EG~~"$"">>Q&(E^^q((E>EEdnnUC$S/)GGNN5)GGEN++rwww/?/H/HH$..A&--EGggmmG,Q/ %-{;K{##r)rN)rrrrrrrrrrrr r s!N"%: 2" P'dP$rr cddl}d}|j|}|jd}|jdddd |jd d d dd|jddddd|jdddd |jddd |j |}|j }|j [|j }t|d|5}|j}dddrtdj|tdy|j4|j}t|d|5}|jdddy|j8|j\}} t|d|5}|j| dddy|j|r0td t j"!t!j$d"|jj'd} |j} fd#t| d$5}| D]} t(j*j-| } | szShow listing of a zipfile)metavarhelpz-ez --extractr")rz zExtract zipfile into target dir)nargsrrz-cz--create+)zzzCreate zipfile from sourcesz-tz--testzTest if a zipfile is validz--metadata-encodingz z2Specify encoding of member names for -l, -e and -tr)rz.The following enclosed file is corrupted: {!r}z Done testingz/Non-conforming encodings not supported with -c.r:r!c tjj|r|j||tytjj |r~|r|j||t tj|D]H}|tjj||tjj||Jyyr) rrrr{rrr(rr8)rrzippathnmaddToZips rrzmain..addToZipsww~~d#w 5t$HHT7+ D!12BRWW\\$3RWW\\'25NP3%rrr)argparseArgumentParseradd_mutually_exclusive_group add_argument parse_argsrtestr r@rrrxr<rgrjcreaterstderrexitpoprrrrrr)argsrrparsergroupencodingrrbadfilerzip_namefilesrrrs @rmainrsGK  $ $ $ =F  / / / >E tX{79 t[<=? tZs39; tX{8: -|QS   T "D%%H yyii S# :bjjlG;  BII'R S n  ii S# :b KKM; :  !ll V S# :b MM& !; :   Czz # HHQK;;??1%  PXs #r''**40 gg..rwwt/DEGr299bii88 GT7+ $ #) !!; :; : ; :.$ #s1J4KK BK4J>K  KK")r CompleteDirsr)rbinasciiimportlib.utilrrrrrrSrrrrIr  ImportErrorrKr$__all__ ExceptionrrrrrrrKrrrr rrrrr'rwrvrrurYrZr[r\r]r^r_r{rrrr!rr _CD_CREATE_VERSION_CD_CREATE_SYSTEM_CD_EXTRACT_VERSION_CD_EXTRACT_SYSTEMr#_CD_COMPRESS_TYPE_CD_TIME_CD_DATE_CD_CRC_CD_COMPRESSED_SIZE_CD_UNCOMPRESSED_SIZEr"r$r%_CD_DISK_NUMBER_START_CD_INTERNAL_FILE_ATTRIBUTES_CD_EXTERNAL_FILE_ATTRIBUTESr&rYrarrVrWrrrrRrS_FH_EXTRACT_VERSION_FH_EXTRACT_SYSTEMrX_FH_COMPRESSION_METHOD_FH_LAST_MOD_TIME_FH_LAST_MOD_DATE_FH_CRC_FH_COMPRESSED_SIZE_FH_UNCOMPRESSED_SIZErTrUrTrUrRrWrXrV_CD64_SIGNATURE_CD64_DIRECTORY_RECSIZE_CD64_CREATE_VERSION_CD64_EXTRACT_VERSION_CD64_DISK_NUMBER_CD64_DISK_NUMBER_START_CD64_NUMBER_ENTRIES_THIS_DISK_CD64_NUMBER_ENTRIES_TOTAL_CD64_DIRECTORY_SIZE_CD64_OFFSET_START_CENTDIRrStructr4rBrHr rqrDrobjectr rrrrr1rrNrVr[r]rvrrrr r r_pathrrrrrr!s    JJE     9    #        !12    $  !12     !!  #   "  !12  ! %))&//*CD"""6??#56!" #fmmE** (V:x&ivi`   #L"".8wxxx  x  x yzy{   !"#(N&  P$%!%!P(T""Tn P+B%%P+h\ \ ~k$k$\C,LcG D NNE  C  Ds4I I$I2 I! I!$I/.I/2I=<I=